Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH][gdb/testsuite] Detect gdb prompt after monitor exit
@ 2020-09-14 19:21 Tom de Vries
  2020-09-15 13:05 ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Tom de Vries @ 2020-09-14 19:21 UTC (permalink / raw)
  To: gdb-patches; +Cc: Pedro Alves

Hi,

With this gdbserver-support.exp patch:
...
@@ -451,8 +451,10 @@ proc gdbserver_exit { is_mi } {
 	    # We use expect rather than gdb_expect because
 	    # we want to suppress printing exception messages, otherwise,
 	    # remote_expect, invoked by gdb_expect, prints the exceptions.
+	    set read_prompt 0
 	    expect {
 		-i "$gdb_spawn_id" -re "$gdb_prompt $" {
+		    set read_prompt 1
 		    exp_continue
 		}
 		-i "$server_spawn_id" eof {
@@ -463,6 +465,7 @@ proc gdbserver_exit { is_mi } {
                    warning "Timed out waiting for EOF in server after $monitor_exit"
                }
 	    }
+	    gdb_assert {$read_prompt}
 	}
     }
     close_gdbserver
...
and with this in parallel:
...
$ stress -c 5
...
we run into this and similar FAILs:
...
FAIL: gdb.multi/multi-target.exp: continue: non-stop=on: $read_prompt
...

In more detail:
...
(gdb) PASS: gdb.multi/multi-target.exp: continue: non-stop=on: inferior 5
Remote debugging from host ::1, port 40712^M
Process build/gdb/testsuite/outputs/gdb.multi/multi-target/multi-target \
  created; pid = 11098^M
monitor exit^M
Killing process(es): 11098^M
FAIL: gdb.multi/multi-target.exp: continue: non-stop=on: $read_prompt
spawn build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory \
  build/gdb/testsuite/../data-directory^M
...

After issuing a "monitor exit" command, we should always get a prompt back, so
check for that.

Tested on x86_64-linux.

Any comments?

Thanks,
- Tom

[gdb/testsuite] Detect gdb prompt after monitor exit

---
 gdb/testsuite/lib/gdbserver-support.exp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
index a2cc80f28d..3636505aab 100644
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -451,8 +451,10 @@ proc gdbserver_exit { is_mi } {
 	    # We use expect rather than gdb_expect because
 	    # we want to suppress printing exception messages, otherwise,
 	    # remote_expect, invoked by gdb_expect, prints the exceptions.
+	    set read_prompt 0
 	    expect {
 		-i "$gdb_spawn_id" -re "$gdb_prompt $" {
+		    set read_prompt 1
 		    exp_continue
 		}
 		-i "$server_spawn_id" eof {
@@ -463,6 +465,15 @@ proc gdbserver_exit { is_mi } {
                    warning "Timed out waiting for EOF in server after $monitor_exit"
                }
 	    }
+	    if { ! read_prompt } {
+		expect {
+		    -i "$gdb_spawn_id" -re "$gdb_prompt $" {
+		    }
+		    timeout {
+			warning "Timed out waiting for prompt after $monitor_exit"
+		    }
+		}
+	    }
 	}
     }
     close_gdbserver


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

end of thread, other threads:[~2020-09-16 12:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14 19:21 [PATCH][gdb/testsuite] Detect gdb prompt after monitor exit Tom de Vries
2020-09-15 13:05 ` Pedro Alves
2020-09-15 14:17   ` Tom de Vries
2020-09-16 10:59     ` Pedro Alves
2020-09-16 12:55       ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox