Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb/testsuite] Detect gdb prompt after monitor exit
Date: Tue, 15 Sep 2020 16:17:38 +0200	[thread overview]
Message-ID: <2bdf800f-1f54-871c-0769-e833873cc099@suse.de> (raw)
In-Reply-To: <4c088e4f-0c8d-62da-215e-b7062296cb33@palves.net>

On 9/15/20 3:05 PM, Pedro Alves wrote:
> On 9/14/20 8:21 PM, Tom de Vries wrote:
> 
>> After issuing a "monitor exit" command, we should always get a prompt back, so
>> check for that.
>>
>> Tested on x86_64-linux.
>>
>> Any comments?
>>
> 
> Good find.
>> @@ -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"
>> +		    }
>> +		}
>> +	    }
> 
> So if we get the prompt first, we go back to waiting for the eof.
> But if the eof is first, we currently don't continue waiting for
> the prompt.  Do we really need this new block of code instead
> of just putting:
> 
>     if {!$read_prompt} {
>       exp_continue
>     }
> 
> in the eof case?
> 

AFAIU, if we do that, and we first hit the server_spawn_id case, we'll
do exp_continue, after which we'll hit the gdb_spawn_id case, after
which we'll do exp_continue ... after which we should run into the
timeout.  I couldn't trigger that though.

Anyway, this seems to work:
...
index a2cc80f28d..24733275ae 100644
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -451,13 +451,20 @@ 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 have_prompt 0
            expect {
                -i "$gdb_spawn_id" -re "$gdb_prompt $" {
-                   exp_continue
+                   if { [info exists server_spawn_id] } {
+                       set have_prompt 1
+                       exp_continue
+                   }
                }
                -i "$server_spawn_id" eof {
                    wait -i $expect_out(spawn_id)
                    unset server_spawn_id
+                   if { ! $have_prompt } {
+                       exp_continue
+                   }
                }
                timeout {
                    warning "Timed out waiting for EOF in server after
$monitor_exit"
...

I do wonder though about unsetting server_spawn_id and doing
exp_continue while we still have the clause -i $server_spawn_id eof.  I
wonder this is supported behaviour.

Thanks,
- Tom


  reply	other threads:[~2020-09-15 14:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-14 19:21 Tom de Vries
2020-09-15 13:05 ` Pedro Alves
2020-09-15 14:17   ` Tom de Vries [this message]
2020-09-16 10:59     ` Pedro Alves
2020-09-16 12:55       ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2bdf800f-1f54-871c-0769-e833873cc099@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox