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

Hui Zhu hui_zhu@mentor.com
Sun Nov 24 12:14:00 GMT 2013


Ping.

Thanks,
Hui


-------- Original Message --------
Subject: Re: [PATCH] Fix gdb.base/shreloc.exp: (msymbol) relocated functions have different addresses fail in cygwin
Date: Thu, 12 Sep 2013 15:28:12 +0800
From: Hui Zhu <hui_zhu@mentor.com>
To: Yao Qi <yao@codesourcery.com>
CC: Hui Zhu <teawater@gmail.com>, gdb-patches ml <gdb-patches@sourceware.org>

Hi Yao,

Thanks for your review.

On 09/12/13 14:49, Yao Qi wrote:
> On 09/12/2013 02:31 PM, Hui Zhu wrote:
>> -proc get_msym_addrs { var msymfile } {
>> +proc get_msym_addrs { var msymfile { plus_var "" } } {
>
> 'plus_var' is not good candidate for parameter name.  I'd call it 'mst'
> or 'msym_type'.

Fixed.

>
>>       # 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"
>> +    }
>
> This condition checking is not necessary, we can do
>
>    send_gdb "shell grep -E \"${plus_var} ${var}(\[ \t\]+.*)?\$\" ${msymfile}\n"

Because for the output format is: [ 7] T 0x2aaaaacd058a fn_1 section .text  shreloc1.c
It need a ".*" after "T".  So I change "T" to "T.*" to handle it.

Post a new version according to your comments.

Best,
Hui


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

	* gdb.base/shreloc.exp (get_msym_addrs): Add argument "msym_type".
	(check_different): Ditto.
	((msymbol) relocated functions have different addresses): Add
	argument 'T.*' when call check_different.



-------------- next part --------------
--- a/gdb/testsuite/gdb.base/shreloc.exp
+++ b/gdb/testsuite/gdb.base/shreloc.exp
@@ -157,14 +157,14 @@ proc send_gdb_discard { command } {
     }
 }
 
-proc get_msym_addrs { var msymfile } {
+proc get_msym_addrs { var msymfile { msym_type "" } } {
     # 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"
+    send_gdb "shell grep -E \"${msym_type} ${var}(\[ \t\]+.*)?\$\" ${msymfile}\n"
 
     while 1 {
 	gdb_expect {
@@ -201,10 +201,10 @@ proc check_same {var msymfile} {
     }
 }
 
-proc check_different {var msymfile} {
+proc check_different {var msymfile { msym_type "" } } {
     # 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}" "${msym_type}"]]
     set prev ""
 
     if { [llength ${addr_list}] < 2 } {
@@ -236,7 +236,9 @@ if [send_gdb_discard "maint print msymbo
 	fail "(msymbol) relocated extern vars have different addresses"
     }
 
-    if {[check_different "fn_\[12\]" "${msymfile}"]} {
+    # Msymbol type of "relocated function" should be 'T', so we just
+    # check 'T' type.
+    if {[check_different "fn_\[12\]" "${msymfile}" "T.*"]} {
 	pass "(msymbol) relocated functions have different addresses"
     } else {
 	fail "(msymbol) relocated functions have different addresses"


More information about the Gdb-patches mailing list