Relocation test fix for target=i686-mingw32 and host=i686-pc-linux

ali_anwar ali_anwar@codesourcery.com
Wed Jul 10 10:32:00 GMT 2013


Hi,

Attached patch fixes a test case failure for target=i686-mingw32 and 
host=i686-pc-linux.

Loading file to 0x00 is causing gdb to throw error,"A problem internal 
to GDB has been detected, further debugging may prove unreliable."

Debugging revealed that call to coff_i386_reloc from 
dwarf2_build_frame_info sets the section_htable to 0x00. Right after, we 
try to get "got = bfd_get_section_by_name (unit->abfd, ".got");" and end 
up with gdb error as hash table is no more valid at this point.

Also please note that issue is not experienced with main, instead of 
hack implemented in the test case's c file i.e. relocate.c.

Regards,
-Ali
-------------- next part --------------
Index: gdb/testsuite/gdb.base/relocate.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/relocate.exp,v
retrieving revision 1.20
diff -u -r1.20 relocate.exp
--- gdb/testsuite/gdb.base/relocate.exp	27 Jun 2013 18:53:49 -0000	1.20
+++ gdb/testsuite/gdb.base/relocate.exp	10 Jul 2013 10:20:42 -0000
@@ -53,11 +53,19 @@
 gdb_reinitialize_dir $srcdir/$subdir
 
 # Load the object file.
-gdb_test "add-symbol-file ${binfile} 0" \
+if {[istarget "i686-pc-mingw32"] && [ishost "i686-pc-linux-gnu"]} {
+    gdb_test "add-symbol-file ${binfile} 100" \
 	"Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
-	"add-symbol-file ${testfile}.o 0" \
-	"add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.text_addr = 0x0\[\r\n\]+\\(y or n\\) " \
+	"add-symbol-file ${testfile}.o 100" \
+	"add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.text_addr = 0x64\[\r\n\]+\\(y or n\\) " \
 	"y"
+} else {
+    gdb_test "add-symbol-file ${binfile} 0" \
+        "Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
+        "add-symbol-file ${testfile}.o 0" \
+        "add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.text_addr = 0x0\[\r\n\]+\\(y or n\\) " \
+        "y"
+}
 
 # Print the addresses of static variables.
 set static_foo_addr [get_var_address static_foo]
@@ -99,14 +107,25 @@
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 
-gdb_test_no_output "set \$offset = 0x10000"
+if {[istarget "i686-pc-mingw32"] && [ishost "i686-pc-linux-gnu"]} {
+    gdb_test_no_output "set \$offset = 0x68"
 
-# Load the object file.
-gdb_test "add-symbol-file ${binfile} \$offset" \
+    # Load the object file.
+    gdb_test "add-symbol-file ${binfile} \$offset" \
 	"Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
 	"add-symbol-file ${testfile}.o \$offset" \
-	"add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.text_addr = 0x10000\[\r\n\]+\\(y or n\\) " \
+	"add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.text_addr = 0x68\[\r\n\]+\\(y or n\\) " \
 	"y"
+} else {
+    gdb_test_no_output "set \$offset = 0x10000"
+
+    # Load the object file.
+    gdb_test "add-symbol-file ${binfile} \$offset" \
+        "Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
+        "add-symbol-file ${testfile}.o \$offset" \
+        "add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.text_addr = 0x10000\[\r\n\]+\\(y or n\\) " \
+        "y"
+}
 
 # Print the addresses of functions.
 set new_function_foo_addr [get_var_address function_foo]
@@ -120,14 +139,15 @@
 
 # Now try loading the object as an exec-file; we should be able to print
 # the values of variables after we do this.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_file_cmd ${binfile}
-
-# Check the values of the variables.
-gdb_test "print static_foo" "\\\$$decimal = 1"
-gdb_test "print static_bar" "\\\$$decimal = 2"
-gdb_test "print global_foo" "\\\$$decimal = 3"
-gdb_test "print global_bar" "\\\$$decimal = 4"
+if {!([istarget "i686-pc-mingw32"] && [ishost "i686-pc-linux-gnu"])} {
+    gdb_exit
+    gdb_start
+    gdb_reinitialize_dir $srcdir/$subdir
+    gdb_file_cmd ${binfile}
+    
+    # Check the values of the variables.
+    gdb_test "print static_foo" "\\\$$decimal = 1"
+    gdb_test "print static_bar" "\\\$$decimal = 2"
+    gdb_test "print global_foo" "\\\$$decimal = 3"
+    gdb_test "print global_bar" "\\\$$decimal = 4"
+}


More information about the Gdb-patches mailing list