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: [patch] testsuite gdbserver async+non-stop: Fix racy FAILs


Hi Jan,

On 07/18/2012 10:25 PM, Jan Kratochvil wrote:
> Hi Pedro,
> 
> from the patch:
> +		# In non-stop/async mode gdbserver sends *running first and
> +		# *stopped only after ^connected.
> 
> This causes racy testsuite results in gdbserver mode (usually it works because
> GDB sends -exec-continue only after *stopped is already sent).
> 
> Do you find this solution acceptable or is there going to be rather
> PTRACE_SEIZE usage already etc.?

Yeah, if you're debugging a program that is running (not stopped) in non-stop
mode, "disconnect", and then reconnect, you should find the program still running,
with no *stop coming out.  It seems that is broken though; I always end up with
one thread stopped...  Coupled with that, it's easy to imagine a disconnected
tracing (+observer mode) test that reconnects and expects the program to be
still running, unperturbed, as such is the point of observer mode.

I think that means we'd need to leave mi_gdb_target_cmd handling only the
connection part, and move the mi_expect_interrupt call out of mi_gdb_target_cmd
to some caller (mi_run_cmd_full?), that knows the target will be stopped.
Does that work?  If that's complicated, this looks reasonable enough to me,
and I won't object, leaving sorting this out for when the bits in the paragraph
above are actually fixed/done.

> 
> No regressions on {x86_64,x86_64-m32,i686}-fedora17-linux-gnu in gdbserver
> mode.
> 
> 
> Thanks,
> Jan
> 
> 
> spawn ../gdbserver/gdbserver --once :2371 /unsafegdb/testsuite.unix.-m32/gdb.mi/mi-nonstop-exit^M
> Process /unsafegdb/testsuite.unix.-m32/gdb.mi/mi-nonstop-exit created; pid = 2852^M
> Listening on port 2371^M
> 47-target-select remote localhost:2371^M
> Remote debugging from host 127.0.0.1^M
> =thread-group-started,id="i1",pid="2852"^M
> =thread-created,id="1",group-id="i1"^M
> ~"[New Thread 2852]\n"^M
> *running,thread-id="1"^M
> 47^connected^M
> (gdb) ^M
> 220-exec-continue^M
> 220^error,msg="Cannot execute this command while the selected thread is running."^M
> (gdb) ^M
> *stopped,reason="signal-received",signal-name="0",signal-meaning="Signal 0",frame={addr="0xf7fde0f0",func="??",args=[]},thread-id="1",stopped-threads=["1"],core="7"^M
> =library-loaded,id="/lib/ld-linux.so.2",target-name="/lib/ld-linux.so.2",host-name="/lib/ld-linux.so.2",symbols-loaded="0",thread-group="i1"^M
> &"warning: Skipping deprecated .gdb_index section in /usr/lib/debug/lib/ld-2.15.so.debug, pass --use-deprecated-index-sections to use them anyway\n"^M
> mi_expect_stop: expecting: \*stopped,reason="breakpoint-hit",disp="del",bkptno="[0-9]+",frame={addr="0x[0-9A-Fa-f]+",func="main",args=\[.*\],(?:file="[^
> ]*.*",fullname="(/[^\n]*/|\\\\[^\\]+\\[^\n]+\\|\\[^\\][^\n]*\\|[a-zA-Z]:[^\n]*\\).*",line="[0-9]+"|from=".*")},thread-id="[0-9]+",stopped-threads=[^
> ]*^M
> (=thread-selected,id="[0-9]+"^M
> |=(?:breakpoint-created|breakpoint-deleted)[^
> ]+"^M
> )*
> FAIL: gdb.mi/mi-nonstop-exit.exp: mi runto main (timeout)
> 
> 
> 
> gdb/testsuite/
> 2012-07-18  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	Fix racy FAILs in async/non-stop gdbserver mode.
> 	* lib/mi-support.exp (mi_gdb_target_cmd): Wait for *stopped if present
> 	after ^connected.
> 	(mi_expect_interrupt): Do not call pass for empty $test.
> 
> diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
> index 401565d..1f9ecad 100644
> --- a/gdb/testsuite/lib/mi-support.exp
> +++ b/gdb/testsuite/lib/mi-support.exp
> @@ -338,9 +338,20 @@ proc mi_gdb_target_cmd { targetname serialport } {
>      for {set i 1} {$i <= 3} {incr i} {
>  	send_gdb "47-target-select $targetname $serialport\n"
>  	gdb_expect 60 {
> -	    -re "47\\^connected.*$mi_gdb_prompt" {
> +	    -re "\r\n\\*stopped,.*\r\n47\\^connected.*$mi_gdb_prompt" {
>  		verbose "Set target to $targetname";
> -		return 0;
> +		return 0
> +	    }
> +	    -re "\r\n47\\^connected.*\r\n\\*stopped,.*$mi_gdb_prompt" {
> +		verbose "Set target to $targetname";
> +		return 0
> +	    }
> +	    -re "\r\n47\\^connected.*$mi_gdb_prompt" {
> +		verbose "Set target to $targetname";
> +		# In non-stop/async mode gdbserver sends *running first and
> +		# *stopped only after ^connected.
> +		mi_expect_interrupt ""
> +		return 0
>  	    }
>  	    -re "unknown host.*$mi_gdb_prompt" {
>  	        verbose "Couldn't look up $serialport"
> @@ -1123,7 +1134,9 @@ proc mi_expect_interrupt { test } {
>      verbose -log "mi_expect_interrupt: expecting: \\*stopped,${r}$any\r\n$prompt_re"
>      gdb_expect {
>  	-re "\\*stopped,${r}$any\r\n$prompt_re" {
> -	    pass "$test"
> +	    if {$test != ""} {
> +		pass "$test"
> +	    }
>  	    return 0;
>  	}
>  	-re ".*\r\n$mi_gdb_prompt$" {
> 

-- 
Pedro Alves


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