public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb.threads/thread-specific.exp: Fix uninitialized variable references
@ 2014-03-07 14:38 Maciej W. Rozycki
  2014-03-18 19:53 ` [PING][PATCH] " Maciej W. Rozycki
  2014-03-20 11:24 ` [PATCH] " Pedro Alves
  0 siblings, 2 replies; 6+ messages in thread
From: Maciej W. Rozycki @ 2014-03-07 14:38 UTC (permalink / raw)
  To: gdb-patches

Hi,

 This fixes:

FAIL: gdb.threads/thread-specific.exp: continue to thread-specific breakpoint (timeout)
ERROR: tcl error sourcing .../gdb/testsuite/gdb.threads/thread-specific.exp.
ERROR: can't read "this_breakpoint": no such variable
    while executing
"gdb_test_multiple "info breakpoint $this_breakpoint" "info on bp" {
    -re ".*stop only in thread (\[0-9\]*).*$gdb_prompt $" {
        set this_thread $expe..."
    (file ".../gdb/testsuite/gdb.threads/thread-specific.exp" line 108)
    invoked from within
"source .../gdb/testsuite/gdb.threads/thread-specific.exp"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 source .../gdb/testsuite/gdb.threads/thread-specific.exp"
    invoked from within
"catch "uplevel #0 source $test_file_name""

and then:

FAIL: gdb.threads/thread-specific.exp: continue to thread-specific breakpoint (timeout)
UNTESTED: gdb.threads/thread-specific.exp: info on bp
ERROR: tcl error sourcing .../gdb/testsuite/gdb.threads/thread-specific.exp.
ERROR: can't read "this_thread": no such variable
    while executing
"gdb_test {print $_thread} ".* = $this_thread" "thread var at break""
    (file ".../gdb/testsuite/gdb.threads/thread-specific.exp" line 119)
    invoked from within
"source .../gdb/testsuite/gdb.threads/thread-specific.exp"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 source .../gdb/testsuite/gdb.threads/thread-specific.exp"
    invoked from within
"catch "uplevel #0 source $test_file_name""

Final results:

FAIL: gdb.threads/thread-specific.exp: continue to thread-specific breakpoint (timeout)
UNTESTED: gdb.threads/thread-specific.exp: info on bp
UNTESTED: gdb.threads/thread-specific.exp: thread var at break

Of course the first failure best wasn't there, but failing that the script 
shouldn't crash.

 OK to apply?

2014-03-07  Maciej W. Rozycki  <macro@codesourcery.com>

	gdb/testsuite/
	* gdb.threads/thread-specific.exp: Check for the existence of
	$this_breakpoint and $this_thread before use.

  Maciej

gdb-test-thread-specific-this-foo.diff
Index: gdb-fsf-trunk-quilt/gdb/testsuite/gdb.threads/thread-specific.exp
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/testsuite/gdb.threads/thread-specific.exp	2014-01-03 21:13:59.077575761 +0000
+++ gdb-fsf-trunk-quilt/gdb/testsuite/gdb.threads/thread-specific.exp	2014-03-07 01:46:50.388996822 +0000
@@ -105,13 +105,21 @@ gdb_test_multiple "continue" "continue t
 	}
 }
 
-gdb_test_multiple "info breakpoint $this_breakpoint" "info on bp" {
-    -re ".*stop only in thread (\[0-9\]*).*$gdb_prompt $" {
-	set this_thread $expect_out(1,string)
-	pass "found breakpoint for thread number"
+if { [info exists this_breakpoint] } {
+    gdb_test_multiple "info breakpoint $this_breakpoint" "info on bp" {
+	-re ".*stop only in thread (\[0-9\]*).*$gdb_prompt $" {
+	    set this_thread $expect_out(1,string)
+	    pass "found breakpoint for thread number"
+	}
     }
+} else {
+    untested "info on bp"
 }
 
-gdb_test {print $_thread} ".* = $this_thread" "thread var at break"
+if { [info exists this_thread] } {
+    gdb_test {print $_thread} ".* = $this_thread" "thread var at break"
+} else {
+    untested "thread var at break"
+}
 
 return 0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PING][PATCH] gdb.threads/thread-specific.exp: Fix uninitialized variable references
  2014-03-07 14:38 [PATCH] gdb.threads/thread-specific.exp: Fix uninitialized variable references Maciej W. Rozycki
@ 2014-03-18 19:53 ` Maciej W. Rozycki
  2014-03-20 11:24 ` [PATCH] " Pedro Alves
  1 sibling, 0 replies; 6+ messages in thread
From: Maciej W. Rozycki @ 2014-03-18 19:53 UTC (permalink / raw)
  To: gdb-patches

Ping!

On Fri, 7 Mar 2014, Maciej W. Rozycki wrote:

> Hi,
> 
>  This fixes:
> 
> FAIL: gdb.threads/thread-specific.exp: continue to thread-specific breakpoint (timeout)
> ERROR: tcl error sourcing .../gdb/testsuite/gdb.threads/thread-specific.exp.
> ERROR: can't read "this_breakpoint": no such variable
>     while executing
> "gdb_test_multiple "info breakpoint $this_breakpoint" "info on bp" {
>     -re ".*stop only in thread (\[0-9\]*).*$gdb_prompt $" {
>         set this_thread $expe..."
>     (file ".../gdb/testsuite/gdb.threads/thread-specific.exp" line 108)
>     invoked from within
> "source .../gdb/testsuite/gdb.threads/thread-specific.exp"
>     ("uplevel" body line 1)
>     invoked from within
> "uplevel #0 source .../gdb/testsuite/gdb.threads/thread-specific.exp"
>     invoked from within
> "catch "uplevel #0 source $test_file_name""
> 
> and then:
> 
> FAIL: gdb.threads/thread-specific.exp: continue to thread-specific breakpoint (timeout)
> UNTESTED: gdb.threads/thread-specific.exp: info on bp
> ERROR: tcl error sourcing .../gdb/testsuite/gdb.threads/thread-specific.exp.
> ERROR: can't read "this_thread": no such variable
>     while executing
> "gdb_test {print $_thread} ".* = $this_thread" "thread var at break""
>     (file ".../gdb/testsuite/gdb.threads/thread-specific.exp" line 119)
>     invoked from within
> "source .../gdb/testsuite/gdb.threads/thread-specific.exp"
>     ("uplevel" body line 1)
>     invoked from within
> "uplevel #0 source .../gdb/testsuite/gdb.threads/thread-specific.exp"
>     invoked from within
> "catch "uplevel #0 source $test_file_name""
> 
> Final results:
> 
> FAIL: gdb.threads/thread-specific.exp: continue to thread-specific breakpoint (timeout)
> UNTESTED: gdb.threads/thread-specific.exp: info on bp
> UNTESTED: gdb.threads/thread-specific.exp: thread var at break
> 
> Of course the first failure best wasn't there, but failing that the script 
> shouldn't crash.
> 
>  OK to apply?
> 
> 2014-03-07  Maciej W. Rozycki  <macro@codesourcery.com>
> 
> 	gdb/testsuite/
> 	* gdb.threads/thread-specific.exp: Check for the existence of
> 	$this_breakpoint and $this_thread before use.
> 
>   Maciej
> 
> gdb-test-thread-specific-this-foo.diff
> Index: gdb-fsf-trunk-quilt/gdb/testsuite/gdb.threads/thread-specific.exp
> ===================================================================
> --- gdb-fsf-trunk-quilt.orig/gdb/testsuite/gdb.threads/thread-specific.exp	2014-01-03 21:13:59.077575761 +0000
> +++ gdb-fsf-trunk-quilt/gdb/testsuite/gdb.threads/thread-specific.exp	2014-03-07 01:46:50.388996822 +0000
> @@ -105,13 +105,21 @@ gdb_test_multiple "continue" "continue t
>  	}
>  }
>  
> -gdb_test_multiple "info breakpoint $this_breakpoint" "info on bp" {
> -    -re ".*stop only in thread (\[0-9\]*).*$gdb_prompt $" {
> -	set this_thread $expect_out(1,string)
> -	pass "found breakpoint for thread number"
> +if { [info exists this_breakpoint] } {
> +    gdb_test_multiple "info breakpoint $this_breakpoint" "info on bp" {
> +	-re ".*stop only in thread (\[0-9\]*).*$gdb_prompt $" {
> +	    set this_thread $expect_out(1,string)
> +	    pass "found breakpoint for thread number"
> +	}
>      }
> +} else {
> +    untested "info on bp"
>  }
>  
> -gdb_test {print $_thread} ".* = $this_thread" "thread var at break"
> +if { [info exists this_thread] } {
> +    gdb_test {print $_thread} ".* = $this_thread" "thread var at break"
> +} else {
> +    untested "thread var at break"
> +}
>  
>  return 0
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gdb.threads/thread-specific.exp: Fix uninitialized variable references
  2014-03-07 14:38 [PATCH] gdb.threads/thread-specific.exp: Fix uninitialized variable references Maciej W. Rozycki
  2014-03-18 19:53 ` [PING][PATCH] " Maciej W. Rozycki
@ 2014-03-20 11:24 ` Pedro Alves
  2014-03-21  0:03   ` Maciej W. Rozycki
  1 sibling, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2014-03-20 11:24 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: gdb-patches

On 03/07/2014 02:37 PM, Maciej W. Rozycki wrote:
> Hi,
> 
>  This fixes:
> 
> FAIL: gdb.threads/thread-specific.exp: continue to thread-specific breakpoint (timeout)
> ERROR: tcl error sourcing .../gdb/testsuite/gdb.threads/thread-specific.exp.
> ERROR: can't read "this_breakpoint": no such variable
>     while executing
> "gdb_test_multiple "info breakpoint $this_breakpoint" "info on bp" {
>     -re ".*stop only in thread (\[0-9\]*).*$gdb_prompt $" {
>         set this_thread $expe..."
>     (file ".../gdb/testsuite/gdb.threads/thread-specific.exp" line 108)
>     invoked from within
> "source .../gdb/testsuite/gdb.threads/thread-specific.exp"
>     ("uplevel" body line 1)
>     invoked from within
> "uplevel #0 source .../gdb/testsuite/gdb.threads/thread-specific.exp"
>     invoked from within
> "catch "uplevel #0 source $test_file_name""
> 
> and then:
> 
> FAIL: gdb.threads/thread-specific.exp: continue to thread-specific breakpoint (timeout)
> UNTESTED: gdb.threads/thread-specific.exp: info on bp
> ERROR: tcl error sourcing .../gdb/testsuite/gdb.threads/thread-specific.exp.
> ERROR: can't read "this_thread": no such variable
>     while executing
> "gdb_test {print $_thread} ".* = $this_thread" "thread var at break""
>     (file ".../gdb/testsuite/gdb.threads/thread-specific.exp" line 119)
>     invoked from within
> "source .../gdb/testsuite/gdb.threads/thread-specific.exp"
>     ("uplevel" body line 1)
>     invoked from within
> "uplevel #0 source .../gdb/testsuite/gdb.threads/thread-specific.exp"
>     invoked from within
> "catch "uplevel #0 source $test_file_name""
> 
> Final results:
> 
> FAIL: gdb.threads/thread-specific.exp: continue to thread-specific breakpoint (timeout)
> UNTESTED: gdb.threads/thread-specific.exp: info on bp
> UNTESTED: gdb.threads/thread-specific.exp: thread var at break
> 
> Of course the first failure best wasn't there, but failing that the script 
> shouldn't crash.
> 
>  OK to apply?

Thanks!  Close, but needs a little tweak.

Using "info exists" uses like this isn't safe, given that
in a single dejagnu run that tests multiple .exp test files (like just
plain "make check"), global variables set in previous test files leak
into the current test file.  So what we usually do instead is set
the variable unconditionally upfront to some invalid value, and
then compare against that value.  E.g.:

set this_breakpoint -1
gdb_test_multiple "continue" "continue to thread-specific breakpoint" {
	-re "Breakpoint $main_breakpoint, .* at .*\r\n$gdb_prompt $" {
	    fail "continue to thread-specific breakpoint (wrong breakpoint)"
	}
	-re "Breakpoint (\[0-9\]*), .* at .*\r\n$gdb_prompt $" {
	    set this_breakpoint $expect_out(1,string)
	    pass "continue to thread-specific breakpoint"
	}
}
if { $this_breakpoint == -1 } {
  untested ...
} else {
  ...
}

Of course we could unset the variable instead of setting it
to -1, using 'unset -nocomplain'.  Same thing.  Somehow I'm
inclined to think that pattern is more prone to copy-paste
forgetting to do the unset though, but I'd be fine with it.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gdb.threads/thread-specific.exp: Fix uninitialized variable references
  2014-03-20 11:24 ` [PATCH] " Pedro Alves
@ 2014-03-21  0:03   ` Maciej W. Rozycki
  2014-03-21  9:28     ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: Maciej W. Rozycki @ 2014-03-21  0:03 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Thu, 20 Mar 2014, Pedro Alves wrote:

> Thanks!  Close, but needs a little tweak.
> 
> Using "info exists" uses like this isn't safe, given that
> in a single dejagnu run that tests multiple .exp test files (like just
> plain "make check"), global variables set in previous test files leak
> into the current test file.  So what we usually do instead is set
> the variable unconditionally upfront to some invalid value, and
> then compare against that value.  E.g.:
> 
> set this_breakpoint -1
> gdb_test_multiple "continue" "continue to thread-specific breakpoint" {
> 	-re "Breakpoint $main_breakpoint, .* at .*\r\n$gdb_prompt $" {
> 	    fail "continue to thread-specific breakpoint (wrong breakpoint)"
> 	}
> 	-re "Breakpoint (\[0-9\]*), .* at .*\r\n$gdb_prompt $" {
> 	    set this_breakpoint $expect_out(1,string)
> 	    pass "continue to thread-specific breakpoint"
> 	}
> }
> if { $this_breakpoint == -1 } {
>   untested ...
> } else {
>   ...
> }
> 
> Of course we could unset the variable instead of setting it
> to -1, using 'unset -nocomplain'.  Same thing.  Somehow I'm
> inclined to think that pattern is more prone to copy-paste
> forgetting to do the unset though, but I'd be fine with it.

 OK, I'd prefer keeping the usual case first in the conditional though.  
How about this version then?  I have tested it on the failing system and 
it still works.

2014-03-21  Maciej W. Rozycki  <macro@codesourcery.com>

	gdb/testsuite/
	* gdb.threads/thread-specific.exp: Handle the lack of usable
	$this_breakpoint and $this_thread.

  Maciej

gdb-test-thread-specific-this-foo.diff
Index: gdb-fsf-trunk-quilt/gdb/testsuite/gdb.threads/thread-specific.exp
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/testsuite/gdb.threads/thread-specific.exp	2014-03-18 19:00:40.000000000 +0000
+++ gdb-fsf-trunk-quilt/gdb/testsuite/gdb.threads/thread-specific.exp	2014-03-20 23:48:55.277523035 +0000
@@ -95,6 +95,7 @@ foreach thread [lrange $threads 1 end] {
   gdb_breakpoint "$line thread $thread"
 }
 
+set this_breakpoint -1
 gdb_test_multiple "continue" "continue to thread-specific breakpoint" {
 	-re "Breakpoint $main_breakpoint, .* at .*\r\n$gdb_prompt $" {
 	    fail "continue to thread-specific breakpoint (wrong breakpoint)"
@@ -105,13 +106,22 @@ gdb_test_multiple "continue" "continue t
 	}
 }
 
-gdb_test_multiple "info breakpoint $this_breakpoint" "info on bp" {
-    -re ".*stop only in thread (\[0-9\]*).*$gdb_prompt $" {
-	set this_thread $expect_out(1,string)
-	pass "found breakpoint for thread number"
+set this_thread -1
+if { $this_breakpoint != -1 } {
+    gdb_test_multiple "info breakpoint $this_breakpoint" "info on bp" {
+	-re ".*stop only in thread (\[0-9\]*).*$gdb_prompt $" {
+	    set this_thread $expect_out(1,string)
+	    pass "found breakpoint for thread number"
+	}
     }
+} else {
+    untested "info on bp"
 }
 
-gdb_test {print $_thread} ".* = $this_thread" "thread var at break"
+if { $this_thread != -1 } {
+    gdb_test {print $_thread} ".* = $this_thread" "thread var at break"
+} else {
+    untested "thread var at break"
+}
 
 return 0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gdb.threads/thread-specific.exp: Fix uninitialized variable references
  2014-03-21  0:03   ` Maciej W. Rozycki
@ 2014-03-21  9:28     ` Pedro Alves
  2014-03-21 23:56       ` Maciej W. Rozycki
  0 siblings, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2014-03-21  9:28 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: gdb-patches

On 03/21/2014 12:03 AM, Maciej W. Rozycki wrote:

> 2014-03-21  Maciej W. Rozycki  <macro@codesourcery.com>
> 
> 	gdb/testsuite/
> 	* gdb.threads/thread-specific.exp: Handle the lack of usable
> 	$this_breakpoint and $this_thread.

OK.  Thanks!

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gdb.threads/thread-specific.exp: Fix uninitialized variable references
  2014-03-21  9:28     ` Pedro Alves
@ 2014-03-21 23:56       ` Maciej W. Rozycki
  0 siblings, 0 replies; 6+ messages in thread
From: Maciej W. Rozycki @ 2014-03-21 23:56 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Fri, 21 Mar 2014, Pedro Alves wrote:

> > 	gdb/testsuite/
> > 	* gdb.threads/thread-specific.exp: Handle the lack of usable
> > 	$this_breakpoint and $this_thread.
> 
> OK.  Thanks!

 Applied, thanks.

  Maciej

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-03-21 23:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-07 14:38 [PATCH] gdb.threads/thread-specific.exp: Fix uninitialized variable references Maciej W. Rozycki
2014-03-18 19:53 ` [PING][PATCH] " Maciej W. Rozycki
2014-03-20 11:24 ` [PATCH] " Pedro Alves
2014-03-21  0:03   ` Maciej W. Rozycki
2014-03-21  9:28     ` Pedro Alves
2014-03-21 23:56       ` Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).