[PATCH] Fix gdb.base/shreloc.exp: (msymbol) relocated functions have different addresses fail in cygwin

Hui Zhu teawater@gmail.com
Mon Sep 9 08:41:00 GMT 2013


Hi,

I got fail with gdb.base/shreloc.exp in cygwin:
shell grep -E " fn_[12]([ ^G]+.*)?$"
/home/hzhu/bg/gdb/testsuite/gdb.base/shreloc.txt^M
[20] A 0x0 fn_1 section .text^M
[21] A 0x0 fn_2 section .text^M
[35] T 0x40010e0 fn_1 section .text^M
[30] T 0x4310e0 fn_2 section .text^M
(gdb) PASS: gdb.base/shreloc.exp: get_msym_addrs fn_[12]
FAIL: gdb.base/shreloc.exp: (msymbol) relocated functions have
different addresses
The reason is because the address of fn_1 and fn_2 is same.
But I checked the file with nm:
$ nm gdb.base/shreloc.exe | grep fn
004050c0 I __imp__fn_1
004050cc I __imp__fn_2
00000000 A _fn_1
00000000 A _fn_2

I think the behavior of GDB to output same address is right.  So I
make a patch to test.

Please help me review it.

Thanks,
Hui

2013-09-09  Hui Zhu  <hui@codesourcery.com>

* gdb.base/shreloc.exp (get_msym_addrs): Add argument "plus_var".
(check_different): Ditto.
-------------- next part --------------
--- a/gdb/testsuite/gdb.base/shreloc.exp
+++ b/gdb/testsuite/gdb.base/shreloc.exp
@@ -157,14 +157,18 @@ proc send_gdb_discard { command } {
     }
 }
 
-proc get_msym_addrs { var msymfile } {
+proc get_msym_addrs { var msymfile { plus_var "" } } {
     # Extract the list of values for symbols matching var in the
     # minimal symbol output file
 
     global gdb_prompt hex
     set result ""
 
-    send_gdb "shell grep -E \" ${var}(\[ \t\]+.*)?\$\" ${msymfile}\n"
+    if { "${plus_var}" == "" } {
+	send_gdb "shell grep -E \" ${var}(\[ \t\]+.*)?\$\" ${msymfile}\n"
+    } else {
+	send_gdb "shell grep -E \" ${plus_var} .* ${var}(\[ \t\]+.*)?\$\" ${msymfile}\n"
+    }
 
     while 1 {
 	gdb_expect {
@@ -201,10 +205,10 @@ proc check_same {var msymfile} {
     }
 }
 
-proc check_different {var msymfile} {
+proc check_different {var msymfile { plus_var "" } } {
     # Check that the minimal symbol values matching var are different
 
-    set addr_list [lsort [get_msym_addrs "${var}" "${msymfile}"]]
+    set addr_list [lsort [get_msym_addrs "${var}" "${msymfile}" "${plus_var}"]]
     set prev ""
 
     if { [llength ${addr_list}] < 2 } {
@@ -236,7 +240,12 @@ if [send_gdb_discard "maint print msymbo
 	fail "(msymbol) relocated extern vars have different addresses"
     }
 
-    if {[check_different "fn_\[12\]" "${msymfile}"]} {
+    if {([istarget "*pc-cygwin"] || [istarget "*pc-mingw32"]) } {
+	set check_str "T"
+    } else {
+	set check_str ""
+    }
+    if {[check_different "fn_\[12\]" "${msymfile}" "${check_str}"]} {
 	pass "(msymbol) relocated functions have different addresses"
     } else {
 	fail "(msymbol) relocated functions have different addresses"


More information about the Gdb-patches mailing list