Re: [PATCH v2 3/3] gdb: introduce scoped debug prints

Tom de Vries
2021-01-05T09:01:49Z

On 1/4/21 6:02 PM, Simon Marchi via Gdb-patches wrote:
>
>> With this patch, gdb.threads/stepi-random-signal.exp becomes flaky. I folded
>> this little fixup in the patch:
>>
>> commit 49c94827cbbe802726f177bc61c6c9d830907ffa
>> Author: Simon Marchi <simon.marchi@polymtl.ca>
>> Date: Tue Dec 22 16:33:40 2020 -0500
>>
>> fixup
>>
>> Change-Id: Ibd2f622df3e76c873fcf82bca7c4c7900654647e
>>
>> diff --git a/gdb/testsuite/gdb.threads/stepi-random-signal.exp b/gdb/testsuite/gdb.threads/stepi-random-signal.exp
>> index 9a8b38c2acf5..689de8fdc632 100644
>> --- a/gdb/testsuite/gdb.threads/stepi-random-signal.exp
>> +++ b/gdb/testsuite/gdb.threads/stepi-random-signal.exp
>> @@ -86,12 +86,13 @@ if {$prev_addr == ""} {
>> set seen 0
>>
>> set test "stepi"
>> -if {[gdb_test_multiple "stepi" "$test" {
>> +set prompt "$gdb_prompt \\\[infrun\\\] fetch_inferior_event: exit\r\n$"
>> +if {[gdb_test_multiple "stepi" "$test" -prompt $prompt {
>> -re {\[infrun\] handle_signal_stop: random signal} {
>> set seen 1
>> exp_continue
>> }
>> - -re "$gdb_prompt $" {
>> + -re "$prompt$" {
>> }
>> }] != 0} {
>> return
>>
>>
>> Simon
>>
>
>
> I pushed this series, including this fix.

Hi Simon,

starting this commit, I run into:
...
51 callme ();^M
gdb_expect_list pattern: //
[infrun] infrun_async: enable=0^M
(gdb) [infrun] fetch_inferior_event: exit^M
FAIL: gdb.threads/signal-while-stepping-over-bp-other-thread.exp: step
(pattern 6 + sentinel) (timeout)
...
which before the commit was:
...
51 callme ();^M
gdb_expect_list pattern: //
[infrun] infrun_async: enable=0^M
(gdb) PASS: gdb.threads/signal-while-stepping-over-bp-other-thread.exp: step
...

Using patch below, the test passes for me again.

[ I first tried to override $gdb_prompt for the duration of
gdb_test_sequence using save_vars, but there's the invariant that the
gdb_prompt variable has an implicit " " after it, which
gdb_test_sequence adds, so that didn't work. ]

Thanks,
- Tom

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 fe842531977..2b3aec6562e 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,12 +102,15 @@ gdb_test "set scheduler-locking off"
gdb_test "set debug infrun 1"

set test "step"
-gdb_test_sequence $test $test {
+send_gdb "$test\n"
+set prompt "$gdb_prompt \\\[infrun\\\] fetch_inferior_event: exit\r\n$"
+gdb_expect_list $test $prompt {
"need to step-over"
"resume_1: step=1,"
"signal arrived while stepping over breakpoint"
"stepped to a different line"
"callme"
+ ""
}

set cnt_after [get_value "args\[$my_number\]" "get count after step"]