This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Unset tcl variable addr to avoid clashing


On Friday, April 10 2015, Yao Qi wrote:

> From: Yao Qi <yao.qi@linaro.org>
>
> Hi,
> I see some tcl ERRORs in gdb.sum recently:
>
> ERROR: tcl error sourcing ../../../../../binutils-gdb/gdb/testsuite/gdb.base/dmsym.exp.
> ERROR: can't set "addr": variable is array
>     while executing
> "set addr "0x\[0-9a-zA-Z\]+""
>     (file "../../../../../binutils-gdb/gdb/testsuite/gdb.base/dmsym.exp" line 45)
>     invoked from within
> "source ../../../../../binutils-gdb/gdb/testsuite/gdb.base/dmsym.exp"
>     ("uplevel" body line 1)
>     invoked from within
> "uplevel #0 source ../../../../../binutils-gdb/gdb/testsuite/gdb.base/dmsym.exp"
>     invoked from within
> "catch "uplevel #0 source $test_file_name""
>
> It is OK to run single dmsym.exp.  This error is caused by the name
> clashing with coredump-filter.exp, and it can be reproduced,

It seems that coredump-filter.exp is causing lots of headaches
lately...  Sorry about that.

>  $ make check RUNTESTFLAGS='coredump-filter.exp dmsym.exp exception.exp stepi-random-signal.exp'
>
> as variable addr is used in all of them.  This patch is to unset array
> addr, but manually unset variables isn't good to me.  Is there any
> approaches we can do to avoid name clashing?

FWIW, there is not strong reason to keep the variable name as "addr" in
the testcase.  So, an easier solution would be to rename the variable to
something else, like "coredump_var_addr" (I think this name is unique
enough).  The patch below does that.

WDYT?

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/

gdb/testsuite/ChangeLog:
2015-04-11  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.base/coredump-filter.exp: Rename variable "addr" to
	"coredump_var_addr" to avoid naming conflict with other
	testcases.

diff --git a/gdb/testsuite/gdb.base/coredump-filter.exp b/gdb/testsuite/gdb.base/coredump-filter.exp
index f3203be..8c94e94 100644
--- a/gdb/testsuite/gdb.base/coredump-filter.exp
+++ b/gdb/testsuite/gdb.base/coredump-filter.exp
@@ -38,7 +38,7 @@ proc do_save_core { filter_flag core ipid } {
 }
 
 proc do_load_and_test_core { core var working_var working_value } {
-    global hex decimal addr
+    global hex decimal coredump_var_addr
 
     set core_loaded [gdb_core_cmd "$core" "load core"]
     if { $core_loaded == -1 } {
@@ -47,9 +47,9 @@ proc do_load_and_test_core { core var working_var working_value } {
     }
 
     # Access the memory the addresses point to.
-    gdb_test "print/x *(char *) $addr($var)" "\(\\\$$decimal = <error: \)?Cannot access memory at address $hex\(>\)?" \
+    gdb_test "print/x *(char *) $coredump_var_addr($var)" "\(\\\$$decimal = <error: \)?Cannot access memory at address $hex\(>\)?" \
 	"printing $var when core is loaded (should not work)"
-    gdb_test "print/x *(char *) $addr($working_var)" " = $working_value.*" \
+    gdb_test "print/x *(char *) $coredump_var_addr($working_var)" " = $working_value.*" \
 	"print/x *$working_var ( = $working_value)"
 }
 
@@ -163,7 +163,7 @@ foreach item $all_anon_corefiles {
 	set test "print/x $name"
 	gdb_test_multiple $test $test {
 	    -re " = \($hex\)\r\n$gdb_prompt $" {
-		set addr($name) $expect_out(1,string)
+		set coredump_var_addr($name) $expect_out(1,string)
 	    }
 	}
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]