Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2015-2016 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 | ||
24 | standard_testfile | |
25 | ||
775a3298 JK |
26 | gdb_exit |
27 | gdb_start | |
28 | gdb_reinitialize_dir $srcdir/$subdir | |
29 | ||
30 | set test "complete set gnutarget" | |
31 | gdb_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 | ||
42 | set corebz2file ${srcdir}/${subdir}/${testfile}.core.bz2 | |
43 | set corefile ${objdir}/${subdir}/${testfile}.core | |
44 | # Entry point of the original executable. | |
45 | set address 0x400078 | |
46 | ||
47 | if {[catch "system \"bzip2 -dc ${corebz2file} >${corefile}\""] != 0} { | |
48 | untested "failed bzip2" | |
49 | return -1 | |
50 | } | |
51 | file stat ${corefile} corestat | |
52 | if {$corestat(size) != 102400} { | |
53 | untested "bzip2 produces invalid result" | |
54 | return -1 | |
55 | } | |
56 | ||
97a0c697 JK |
57 | # Wrongly built GDB complains by: |
58 | # "..." is not a core dump: File format not recognized | |
59 | # As the provided test core has 64bit PRSTATUS i386 built GDB cannot parse it. | |
cfa68bae | 60 | # This is just a problem of the test case, real-world elf64-i386 file will have |
97a0c697 JK |
61 | # 32bit PRSTATUS. One cannot prepare elf64-i386 core file from elf32-i386 by |
62 | # objcopy as it corrupts the core file beyond all recognition. | |
775a3298 JK |
63 | # The output therefore does not matter much, just we should not get GDB |
64 | # internal error. | |
65 | gdb_test "core-file ${corefile}" ".*" "core-file" | |
97a0c697 | 66 | |
775a3298 JK |
67 | # Test if at least the core file segments memory has been loaded. |
68 | # https://bugzilla.redhat.com/show_bug.cgi?id=457187 | |
69 | gdb_test "x/bx $address" "\r\n\[ \t\]*$address:\[ \t\]*0xf4\[ \t\]*" ".text is readable" |