Patchwork [03/24] Fix gdb.base/interrupt.exp racy fail against gdbserver

login
register
mail settings
Submitter Pedro Alves
Date April 21, 2015, 6:08 p.m.
Message ID <1429639711-16459-4-git-send-email-palves@redhat.com>
Download mbox | patch
Permalink /patch/6350/
State New
Headers show

Comments

Pedro Alves - April 21, 2015, 6:08 p.m.
Currently, against gdbserver, interrupt.exp occasionaly fails like
this:

 ERROR: Process no longer exists
 UNRESOLVED: gdb.base/interrupt.exp: send end of file

The problem is that we see gdbserver exiting before we match gdb's
output:

 expect: does "\r\n\r\nChild exited with status 0\r\nGDBserver exiting\r\n" (spawn_id exp8) match regular expression "end of file"? Gate "end of file"? gate=no
 expect: read eof
 expect: set expect_out(spawn_id) "exp8"
 expect: set expect_out(buffer) "\r\n\r\nChild exited with status 0\r\nGDBserver exiting\r\n"

Fix this by removing $inferior_spawn_id from the set of spawn ids
expect is watching as soon as we see the "end of file" string out of
the inferior spawn id, using an indirect spawn id list.

Tested on x86-64 Fedora 20, native and gdbserver (both target remote
and extended-remote).

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/interrupt.exp: Rename saw_eof to saw_end_of_file.  Use
	an indirect spawn id list holding $inferior_spawn_id instead of
	$inferior_spawn_id directly.  On "of of file", remove
	$inferior_spawn_id from the indirect list.
---
 gdb/testsuite/gdb.base/interrupt.exp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
Yao Qi - April 23, 2015, 2:28 p.m.
Pedro Alves <palves@redhat.com> writes:

> Fix this by removing $inferior_spawn_id from the set of spawn ids
> expect is watching as soon as we see the "end of file" string out of
> the inferior spawn id, using an indirect spawn id list.
>

Yeah, it is clever to use indirect spawn ids here...

> Tested on x86-64 Fedora 20, native and gdbserver (both target remote
> and extended-remote).
>
> gdb/testsuite/ChangeLog:
> 2015-04-21  Pedro Alves  <palves@redhat.com>
>
> 	* gdb.base/interrupt.exp: Rename saw_eof to saw_end_of_file.  Use

The first sentence can be removed, it is in 02/24.

> 	an indirect spawn id list holding $inferior_spawn_id instead of
> 	$inferior_spawn_id directly.  On "of of file", remove

On "end of file".

> 	$inferior_spawn_id from the indirect list.

Patch is good to me.
Pedro Alves - April 23, 2015, 2:58 p.m.
On 04/23/2015 03:28 PM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
> 
>> Fix this by removing $inferior_spawn_id from the set of spawn ids
>> expect is watching as soon as we see the "end of file" string out of
>> the inferior spawn id, using an indirect spawn id list.
>>
> 
> Yeah, it is clever to use indirect spawn ids here...
> 
>> Tested on x86-64 Fedora 20, native and gdbserver (both target remote
>> and extended-remote).
>>
>> gdb/testsuite/ChangeLog:
>> 2015-04-21  Pedro Alves  <palves@redhat.com>
>>
>> 	* gdb.base/interrupt.exp: Rename saw_eof to saw_end_of_file.  Use
> 
> The first sentence can be removed, it is in 02/24.
> 
>> 	an indirect spawn id list holding $inferior_spawn_id instead of
>> 	$inferior_spawn_id directly.  On "of of file", remove
> 
> On "end of file".
> 
>> 	$inferior_spawn_id from the indirect list.
> 
> Patch is good to me.

Thanks Yao, I fixed ChangeLog and went ahead and pushed in
patches 1-3, in order to plug the race in the buildbots.

Thanks,
Pedro Alves

Patch

diff --git a/gdb/testsuite/gdb.base/interrupt.exp b/gdb/testsuite/gdb.base/interrupt.exp
index 17a9bad..f594ba4 100644
--- a/gdb/testsuite/gdb.base/interrupt.exp
+++ b/gdb/testsuite/gdb.base/interrupt.exp
@@ -205,12 +205,21 @@  if ![file exists $binfile] then {
 
 	set msg "send end of file"
 	send_inferior "\004"
+
+	set spawn_list "$inferior_spawn_id"
+
 	gdb_test_multiple "" $msg {
-	    -i $inferior_spawn_id -re "end of file" {
-		verbose -log "saw \"end of file\": $saw_end_of_file"
+	    -i spawn_list -re "end of file" {
 		set saw_end_of_file 1
 		verbose -log "saw \"end of file\""
 		if {!$saw_inferior_exit} {
+		    # When $inferior_spawn_id != $gdb_spawn_id, such
+		    # as when testing with gdbserver, we may see the
+		    # eof (the process exit, not the string just
+		    # matched) for $inferior_spawn_id before the
+		    # expected gdb output.  Clear this so we no longer
+		    # expect anything out of $inferior_spawn_id.
+		    set spawn_list ""
 		    exp_continue
 		}
 	    }