Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Simon Marchi <simon.marchi@polymtl.ca>,
	Simon Marchi <simon.marchi@efficios.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2 3/3] gdb: introduce scoped debug prints
Date: Wed, 6 Jan 2021 08:15:33 +0100	[thread overview]
Message-ID: <9a67618e-369d-614c-a2bb-06ae17bb9395@suse.de> (raw)
In-Reply-To: <c0e9a1d1-4ebc-8241-9f49-58a235c40baa@polymtl.ca>

On 1/6/21 2:00 AM, Simon Marchi wrote:
> On 2021-01-05 4:54 p.m., Simon Marchi wrote:
>> On 2021-01-05 4:26 p.m., tdevries wrote:
>>> Yeah, that's not a bad idea.
>>>
>>> The only bit that concerns me is that there's already a -prompt switch for gdb_test_multiple, which does not add on the terminating '$', while this version does.
>>>
>>> It's probably a good idea to have the -prompt switch to behave the same in both cases.
>>
>> Hmm I see.  Intuitively, I'd try to make gdb_test_multiple add
>> the terminating $.  Do you foresee some problems with that?
>>
>> The prompt passed to gdb_test_multiple only appears to be used
>> for the various failing cases, so I don't expect that to change
>> any passing test (I'll give it a try).
> 
> Well, now that I think of it a bit more, it would be much easier and safer
> to just make my gdb_test_sequence's -prompt work like gdb_test_multiple's -prompt,
> and have the caller add the $ itself.
> 
> Updated patch below.

Thanks, LGTM.

- Tom

> 
> From 23d207b6f391312f82fcaeae9936c97470461415 Mon Sep 17 00:00:00 2001
> From: Simon Marchi <simon.marchi@polymtl.ca>
> Date: Tue, 05 Jan 2021 11:02:07 -0500
> Subject: [PATCH] gdb/testsuite: fix race in gdb.threads/signal-while-stepping-over-bp-other-thread.exp
> 
> Commit 3ec3145c5dd6 ("gdb: introduce scoped debug prints") updated some
> tests using "set debug infrun" to handle the fact that a debug print is
> now shown after the prompt, after an inferior stop.  The same issue
> happens in gdb.threads/signal-while-stepping-over-bp-other-thread.exp.
> If I run it in a loop, it eventually fails like these other tests.
> 
> The problem is that the testsuite expects to see $gdb_prompt followed by
> the end of the buffer.  It happens that expect reads $gdb_prompt and the
> debug print at the same time, in which case the regexp never matches and
> we get a timeout.
> 
> The fix is the same as was done in 3ec3145c5dd6, make the testsuite
> believe that the prompt is the standard GDB prompt followed by that
> debug print.
> 
> Since that test uses gdb_test_sequence, and the expected prompt is in
> gdb_test_sequence, add a -prompt switch to gdb_test_sequence to override
> the prompt used for that call.
> 
> gdb/testsuite/ChangeLog:
> 
> 	* lib/gdb.exp (gdb_test_sequence): Accept -prompt switch.
> 	* gdb.threads/signal-while-stepping-over-bp-other-thread.exp:
> 	Pass prompt containing debug print to gdb_test_sequence.
> 
> Change-Id: I33161c53ddab45cdfeadfd50b964f8dc3caa9729
> ---
> 
> diff --git a/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp b/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
> index fe84253..2807485 100644
> --- a/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
> +++ b/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
> @@ -102,7 +102,7 @@
>  gdb_test "set debug infrun 1"
>  
>  set test "step"
> -gdb_test_sequence $test $test {
> +gdb_test_sequence $test $test -prompt "$gdb_prompt \\\[infrun\\\] fetch_inferior_event: exit\r\n$"  {
>      "need to step-over"
>      "resume_1: step=1,"
>      "signal arrived while stepping over breakpoint"
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 3f61da8..140e396 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -1401,6 +1401,9 @@
>  # EXPECTED_OUTPUT_LIST is a list of regexps of expected output, which are
>  # processed in order, and all must be present in the output.
>  #
> +# The -prompt switch can be used to override the prompt expected at the end of
> +# the output sequence.
> +#
>  # It is unnecessary to specify ".*" at the beginning or end of any regexp,
>  # there is an implicit ".*" between each element of EXPECTED_OUTPUT_LIST.
>  # There is also an implicit ".*" between the last regexp and the gdb prompt.
> @@ -1413,16 +1416,32 @@
>  #    0 if the test passes,
>  #   -1 if there was an internal error.
>  
> -proc gdb_test_sequence { command test_name expected_output_list } {
> +proc gdb_test_sequence { args } {
>      global gdb_prompt
> +
> +    parse_args {{prompt ""}}
> +
> +    if { $prompt == "" } {
> +	set prompt "$gdb_prompt $"
> +    }
> +
> +    if { [llength $args] != 3 } {
> +	error "Unexpected # of arguments, expecting: COMMAND TEST_NAME EXPECTED_OUTPUT_LIST"
> +    }
> +
> +    lassign $args command test_name expected_output_list
> +
>      if { $test_name == "" } {
>  	set test_name $command
>      }
> +
>      lappend expected_output_list ""; # implicit ".*" before gdb prompt
> +
>      if { $command != "" } {
>  	send_gdb "$command\n"
>      }
> -    return [gdb_expect_list $test_name "$gdb_prompt $" $expected_output_list]
> +
> +    return [gdb_expect_list $test_name $prompt $expected_output_list]
>  }
>  
>  \f
> 
> 

  reply	other threads:[~2021-01-06  7:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16 20:47 [PATCH v2 1/3] gdb: make "set debug timestamp" work nice with new debug printouts Simon Marchi via Gdb-patches
2020-12-16 20:47 ` [PATCH v2 2/3] gdb: use infrun_debug_printf in print_target_wait_results Simon Marchi via Gdb-patches
2020-12-16 20:47 ` [PATCH v2 3/3] gdb: introduce scoped debug prints Simon Marchi via Gdb-patches
2020-12-22 21:35   ` Simon Marchi via Gdb-patches
2021-01-04 17:02     ` Simon Marchi via Gdb-patches
2021-01-05  9:01       ` Tom de Vries
2021-01-05  9:23         ` Tom de Vries
2021-01-05 15:33           ` Simon Marchi via Gdb-patches
2021-01-05 17:02             ` Simon Marchi via Gdb-patches
2021-01-05 21:26               ` tdevries
2021-01-05 21:54                 ` Simon Marchi via Gdb-patches
2021-01-06  1:00                   ` Simon Marchi via Gdb-patches
2021-01-06  7:15                     ` Tom de Vries [this message]
2021-01-06 19:05                       ` Simon Marchi via Gdb-patches

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=9a67618e-369d-614c-a2bb-06ae17bb9395@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    --cc=simon.marchi@polymtl.ca \
    /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