Update copyright year range in header of all files managed by GDB
[binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-biarch-core.exp
bloba36153cfe272459ce7ff3f53195bbb7777f23324
1 # Copyright 2015-2023 Free Software Foundation, Inc.
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.
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.
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/>.
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
24 if {![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"]} {
25     verbose "Skipping i386 biarch core test."
26     return
29 standard_testfile
31 clean_restart
33 set gnutargets [get_set_option_choices "set gnutarget"]
34 if { [lsearch -exact $gnutargets elf64-little] == -1 } {
35     untested ".text is readable"
36     return
39 set corebz2file ${srcdir}/${subdir}/${testfile}.core.bz2
40 # Entry point of the original executable.
41 set address 0x400078
43 set corefile [decompress_bz2 $corebz2file]
44 if { $corefile == "" } {
45     untested "failed bzip2"
46     return -1
49 file stat ${corefile} corestat
50 if {$corestat(size) != 102400} {
51     untested "bzip2 produces invalid result"
52     return -1
55 # First check if this particular GDB supports i386, otherwise we should not
56 # expect the i386 core file to be loaded successfully.
57 set archs [get_set_option_choices "set architecture" "i386"]
58 set supports_arch_i386 [expr [lsearch -exact $archs i386] != -1]
60 # Wrongly built GDB complains by:
61 # "..." is not a core dump: File format not recognized
62 # As the provided test core has 64bit PRSTATUS i386 built GDB cannot parse it.
63 # This is just a problem of the test case, real-world elf64-i386 file will have
64 # 32bit PRSTATUS.  One cannot prepare elf64-i386 core file from elf32-i386 by
65 # objcopy as it corrupts the core file beyond all recognition.
66 # The output therefore does not matter much, just we should not get GDB
67 # internal error.
69 # If this particular GDB does not support i386, it is expected GDB will not
70 # recognize the core file.  If it does anyway, it should not crash.
71 set test "load core file"
72 gdb_test_multiple "core-file ${corefile}" $test {
73     -re "no core file handler recognizes format.*\r\n$gdb_prompt $" {
74         if { $supports_arch_i386 } {
75             fail $test
76         } else {
77             pass $test
78             untested ".text is readable (core file unrecognized)"
79             return
80         }
81     }
82     -re "\r\n$gdb_prompt $" {
83         pass $test
84     }
87 # Test if at least the core file segments memory has been loaded.
88 # https://bugzilla.redhat.com/show_bug.cgi?id=457187
89 gdb_test "x/bx $address" "\r\n\[ \t\]*$address:\[ \t\]*0xf4\[ \t\]*" ".text is readable"