[binutils-gdb] Make gdb.arch/i386-biarch-core.exp more robust

Luis Machado luisgpm@sourceware.org
Mon Feb 13 13:14:00 GMT 2017


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=13a66184d0cb485907bfcad15aac0622fd86d25f

commit 13a66184d0cb485907bfcad15aac0622fd86d25f
Author: Luis Machado <lgustavo@codesourcery.com>
Date:   Mon Feb 13 07:12:17 2017 -0600

    Make gdb.arch/i386-biarch-core.exp more robust
    
    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.

Diff:
---
 gdb/testsuite/ChangeLog                     |  5 +++++
 gdb/testsuite/gdb.arch/i386-biarch-core.exp | 31 ++++++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index c1e53b7..db1a4a5 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+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.
+
 2017-02-10  Simon Marchi  <simon.marchi@ericsson.com>
 
 	* gdb.base/new-ui.exp (do_test): Test queries behavior on main
diff --git a/gdb/testsuite/gdb.arch/i386-biarch-core.exp b/gdb/testsuite/gdb.arch/i386-biarch-core.exp
index 4c5f450..fd76369 100644
--- a/gdb/testsuite/gdb.arch/i386-biarch-core.exp
+++ b/gdb/testsuite/gdb.arch/i386-biarch-core.exp
@@ -54,6 +54,18 @@ if {$corestat(size) != 102400} {
     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.
@@ -62,7 +74,24 @@ 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"
+#
+# 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



More information about the Gdb-cvs mailing list