gdb/ChangeLog: 2016-01-11 Luis Machado bz 18964 * mips-tdep.c (mips_gdbarch_init): Sanity check ELF e_machine field and bail out if it is not MIPS-compatible. gdb/testsuite/ChangeLog: 2016-01-11 Luis Machado bz 18964 * gdb.arch/i376-biarch-core.exp: Handle the core file not being recognized. Use variables for repeating test names. --- gdb/mips-tdep.c | 6 ++++++ gdb/testsuite/gdb.arch/i386-biarch-core.exp | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index ca17864..cdfd80e 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -8208,6 +8208,12 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) int dspacc; int dspctl; + /* Sanity check the e_machine field. */ + if (info.abfd + && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour + && elf_elfheader (info.abfd)->e_machine != EM_MIPS) + return NULL; + /* Fill in the OS dependent register numbers and names. */ if (info.osabi == GDB_OSABI_IRIX) { diff --git a/gdb/testsuite/gdb.arch/i386-biarch-core.exp b/gdb/testsuite/gdb.arch/i386-biarch-core.exp index 607b947..a4c0541 100644 --- a/gdb/testsuite/gdb.arch/i386-biarch-core.exp +++ b/gdb/testsuite/gdb.arch/i386-biarch-core.exp @@ -28,13 +28,14 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir set test "complete set gnutarget" +set text_test ".text is readable" 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" + untested $text_test return } } @@ -62,8 +63,19 @@ if {$corestat(size) != 102400} { # 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. -gdb_test "core-file ${corefile}" ".*" "core-file" +set test "core-file" +gdb_test_multiple "core-file ${corefile}" $test { + -re ".* no core file handler recognizes format\r\n$gdb_prompt $" { + # Make sure we handle cases where the core file isn't even properly + # loaded due to architecture incompatibilities. + untested $text_test + 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" +gdb_test "x/bx $address" "\r\n\[ \t\]*$address:\[ \t\]*0xf4\[ \t\]*" $text_test -- 1.9.1