mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-30 12:44:10 +08:00
13a66184d0
This test attempts to load a x86 core file no matter what target architectures the tested GDB supports. If GDB doesn't know how to handle a i386 target, it is very likely the core file will not be recognized. In this case we should still attempt to load a core file to make sure GDB doesn't crash or throws an internal error. But we should not proceed to try to read memory unconditionally. This patch makes the test check for proper i386 arch support in GDB and bails out if i386 is not supported and the core file format is not recognized. This addresses the spurious aarch64-elf failures i'm seeing for this test. gdb/testsuite/ChangeLog: 2017-02-13 Luis Machado <lgustavo@codesourcery.com> * gdb.arch/i386-biarch-core.exp: Check for i386 arch support and return if core file is not recognized.
99 lines
3.3 KiB
Plaintext
99 lines
3.3 KiB
Plaintext
# Copyright 2015-2017 Free Software Foundation, Inc.
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# Test ability to load an elf64-i386 core file. The provided core file was
|
|
# elf64-x8664 one but it got binary patched to i386:
|
|
# Elf32_Ehdr.e_machine @0x12..0x13
|
|
# Elf64_Ehdr.e_machine @0x12..0x13
|
|
# #define EM_386 3 /* Intel 80386 */
|
|
# #define EM_X86_64 62 /* AMD x86-64 architecture */
|
|
# patch @0x12: 0x3E -> 0x03
|
|
|
|
standard_testfile
|
|
|
|
gdb_exit
|
|
gdb_start
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
set test "complete set gnutarget"
|
|
gdb_test_multiple "complete set gnutarget " $test {
|
|
-re "set gnutarget elf64-little\r\n(.*\r\n)?$gdb_prompt $" {
|
|
pass $test
|
|
}
|
|
-re "\r\n$gdb_prompt $" {
|
|
pass $test
|
|
untested ".text is readable"
|
|
return
|
|
}
|
|
}
|
|
|
|
set corebz2file ${srcdir}/${subdir}/${testfile}.core.bz2
|
|
set corefile [standard_output_file ${testfile}.core]
|
|
# Entry point of the original executable.
|
|
set address 0x400078
|
|
|
|
if {[catch "system \"bzip2 -dc ${corebz2file} >${corefile}\""] != 0} {
|
|
untested "failed bzip2"
|
|
return -1
|
|
}
|
|
file stat ${corefile} corestat
|
|
if {$corestat(size) != 102400} {
|
|
untested "bzip2 produces invalid result"
|
|
return -1
|
|
}
|
|
|
|
# First check if this particular GDB supports i386, otherwise we should not
|
|
# expect the i386 core file to be loaded successfully.
|
|
set supports_arch_i386 1
|
|
set test "complete set architecture i386"
|
|
gdb_test_multiple $test $test {
|
|
-re "\r\nset architecture i386\r\n(.*\r\n)?$gdb_prompt $" {
|
|
}
|
|
-re "\r\n$gdb_prompt $" {
|
|
set supports_arch_i386 0
|
|
}
|
|
}
|
|
|
|
# Wrongly built GDB complains by:
|
|
# "..." is not a core dump: File format not recognized
|
|
# As the provided test core has 64bit PRSTATUS i386 built GDB cannot parse it.
|
|
# This is just a problem of the test case, real-world elf64-i386 file will have
|
|
# 32bit PRSTATUS. One cannot prepare elf64-i386 core file from elf32-i386 by
|
|
# objcopy as it corrupts the core file beyond all recognition.
|
|
# The output therefore does not matter much, just we should not get GDB
|
|
# internal error.
|
|
#
|
|
# If this particular GDB does not support i386, it is expected GDB will not
|
|
# recognize the core file. If it does anyway, it should not crash.
|
|
set test "load core file"
|
|
gdb_test_multiple "core-file ${corefile}" $test {
|
|
-re "no core file handler recognizes format.*\r\n$gdb_prompt $" {
|
|
if { $supports_arch_i386 } {
|
|
fail $test
|
|
} else {
|
|
pass $test
|
|
untested ".text is readable (core file unrecognized)"
|
|
return
|
|
}
|
|
}
|
|
-re "\r\n$gdb_prompt $" {
|
|
pass $test
|
|
}
|
|
}
|
|
|
|
# Test if at least the core file segments memory has been loaded.
|
|
# https://bugzilla.redhat.com/show_bug.cgi?id=457187
|
|
gdb_test "x/bx $address" "\r\n\[ \t\]*$address:\[ \t\]*0xf4\[ \t\]*" ".text is readable"
|