testsuite: Remove unused global references in gdb_test

Message ID 1453133632-32710-1-git-send-email-simon.marchi@ericsson.com
State New, archived
Headers

Commit Message

Simon Marchi Jan. 18, 2016, 4:13 p.m. UTC
  Those are unused since gdb_test_multiple was added, factoring out most
of the content of gdb_test.

If it was C code, I would push it as obvious, but because TCL is always
full of surprises, I am playing it safe.

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (gdb_test): Remove unused global references.
---
 gdb/testsuite/lib/gdb.exp | 3 ---
 1 file changed, 3 deletions(-)
  

Comments

Pedro Alves Jan. 18, 2016, 4:28 p.m. UTC | #1
On 01/18/2016 04:13 PM, Simon Marchi wrote:
> Those are unused since gdb_test_multiple was added, factoring out most
> of the content of gdb_test.
> 
> If it was C code, I would push it as obvious, but because TCL is always
> full of surprises, I am playing it safe.

Yeah...  And there's one for you here.  :-)

> ---
>  gdb/testsuite/lib/gdb.exp | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 52220d0..f3f53b7 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -976,10 +976,7 @@ proc gdb_test_multiple { command message user_code } {
>  #   -1 if there was an internal error.
>  #  
>  proc gdb_test { args } {
> -    global verbose
>      global gdb_prompt
> -    global GDB
> -    upvar timeout timeout

The upvar should stay.  I think this just follows standard procedure
for expect:

http://www.tcl.tk/man/expect5.31/expect.1.html

    "Expect takes a rather liberal view of scoping. In particular, variables read
     by commands specific to the Expect program will be sought first from the
     local scope, and if not found, in the global scope. For example, this obviates
     the need to place "global timeout" in every procedure you write that uses expect."

See also get_largest_timeout.

So gdb_test_multiple will look at the timeout in the caller, which will be
gdb_test.  And this upvar then makes gdb_test_multiple actually look at the
timeout variable in gdb_test's caller frame.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 52220d0..f3f53b7 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -976,10 +976,7 @@  proc gdb_test_multiple { command message user_code } {
 #   -1 if there was an internal error.
 #  
 proc gdb_test { args } {
-    global verbose
     global gdb_prompt
-    global GDB
-    upvar timeout timeout
 
     if [llength $args]>2 then {
 	set message [lindex $args 2]