]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.arch/i386-biarch-core.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-biarch-core.exp
CommitLineData
b811d2c2 1# Copyright 2015-2020 Free Software Foundation, Inc.
97a0c697
JK
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16# Test ability to load an elf64-i386 core file. The provided core file was
17# elf64-x8664 one but it got binary patched to i386:
18# Elf32_Ehdr.e_machine @0x12..0x13
19# Elf64_Ehdr.e_machine @0x12..0x13
20# #define EM_386 3 /* Intel 80386 */
21# #define EM_X86_64 62 /* AMD x86-64 architecture */
22# patch @0x12: 0x3E -> 0x03
23
24standard_testfile
25
775a3298
JK
26gdb_exit
27gdb_start
28gdb_reinitialize_dir $srcdir/$subdir
29
30set test "complete set gnutarget"
31gdb_test_multiple "complete set gnutarget " $test {
32 -re "set gnutarget elf64-little\r\n(.*\r\n)?$gdb_prompt $" {
33 pass $test
34 }
35 -re "\r\n$gdb_prompt $" {
36 pass $test
37 untested ".text is readable"
38 return
39 }
97a0c697
JK
40}
41
42set corebz2file ${srcdir}/${subdir}/${testfile}.core.bz2
97e94151 43set corefile [standard_output_file ${testfile}.core]
97a0c697
JK
44# Entry point of the original executable.
45set address 0x400078
46
47if {[catch "system \"bzip2 -dc ${corebz2file} >${corefile}\""] != 0} {
48 untested "failed bzip2"
49 return -1
50}
51file stat ${corefile} corestat
52if {$corestat(size) != 102400} {
53 untested "bzip2 produces invalid result"
54 return -1
55}
56
13a66184
LM
57# First check if this particular GDB supports i386, otherwise we should not
58# expect the i386 core file to be loaded successfully.
59set supports_arch_i386 1
60set test "complete set architecture i386"
61gdb_test_multiple $test $test {
62 -re "\r\nset architecture i386\r\n(.*\r\n)?$gdb_prompt $" {
63 }
64 -re "\r\n$gdb_prompt $" {
65 set supports_arch_i386 0
66 }
67}
68
97a0c697
JK
69# Wrongly built GDB complains by:
70# "..." is not a core dump: File format not recognized
71# As the provided test core has 64bit PRSTATUS i386 built GDB cannot parse it.
cfa68bae 72# This is just a problem of the test case, real-world elf64-i386 file will have
97a0c697
JK
73# 32bit PRSTATUS. One cannot prepare elf64-i386 core file from elf32-i386 by
74# objcopy as it corrupts the core file beyond all recognition.
775a3298
JK
75# The output therefore does not matter much, just we should not get GDB
76# internal error.
13a66184
LM
77#
78# If this particular GDB does not support i386, it is expected GDB will not
79# recognize the core file. If it does anyway, it should not crash.
80set test "load core file"
81gdb_test_multiple "core-file ${corefile}" $test {
82 -re "no core file handler recognizes format.*\r\n$gdb_prompt $" {
83 if { $supports_arch_i386 } {
84 fail $test
85 } else {
86 pass $test
87 untested ".text is readable (core file unrecognized)"
88 return
89 }
90 }
91 -re "\r\n$gdb_prompt $" {
92 pass $test
93 }
94}
97a0c697 95
775a3298
JK
96# Test if at least the core file segments memory has been loaded.
97# https://bugzilla.redhat.com/show_bug.cgi?id=457187
98gdb_test "x/bx $address" "\r\n\[ \t\]*$address:\[ \t\]*0xf4\[ \t\]*" ".text is readable"