* [PATCH] gdb/testsuite: fix intermittent failure in gdb.trace/mi-tsv-changed.exp
@ 2026-11-16 22:15 Andrew Burgess
2026-11-17 17:28 ` Keith Seitz
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2026-11-16 22:15 UTC (permalink / raw)
To: gdb-patches; +Cc: Andrew Burgess
When running with the native-gdbserver board I would sometimes see
failures in the test gdb.trace/mi-tsv-changed.exp. Below is a trimmed
down extract from gdb.log which shows some of the most interesting
lines. I had to trim this down as it's an MI test, so there's a lot
of output:
-exec-continue
^running
*running,thread-id="all"
(gdb)
-trace-stop
*stopped,reason="breakpoint-hit",...
(gdb)
PASS: gdb.trace/mi-tsv-changed.exp: create delete modify: trace stop
-trace-list-variables
^done,stop-reason="request",frames="1",...
(gdb)
PASS: gdb.trace/mi-tsv-changed.exp: create delete modify: list trace variables
tvariable $tvar3 = 2
^done,trace-variables={nr_rows="2",nr_cols="3",hdr=...
(gdb)
FAIL: gdb.trace/mi-tsv-changed.exp: create delete modify: tvariable $tvar3 modified to 2 (unexpected output)
&"tvariable $tvar3 = 2\n"
It's maybe hard to see, but the output gets out of sync, the line:
PASS: gdb.trace/mi-tsv-changed.exp: create delete modify: trace stop
indicating that the trace-stop worked is reported after the output:
*stopped,reason="breakpoint-hit",...
which is the inferior hitting a breakpoint as a result of the
-exec-continue. It's not the output corresponding to the -trace-stop.
That output comes later:
^done,stop-reason="request",frames="1",...
which is associated with this PASS line:
PASS: gdb.trace/mi-tsv-changed.exp: create delete modify: list trace variables
What's going wrong here is that the test send -exec-continue, but
never waits for the inferior to stop. GDB then sends the -trace-stop
but the pattern for that is just {.*}. This means that if the
-trace-stop sees the prompt after the breakpoint hit, but not the
prompt after the -trace-stop command, then the tests can get out of
sync. Eventuallt there's a test with a pattern more details than just
{.*}, at which point we get a FAIL reported.
It is easier to reproduce this failure when using the 'read1' target, like:
make -C gdb check-read1 TESTS=gdb.trace/mi-tsv-changed.exp \
RUNTESTFLAGS="--target_board=native-gdbserver"
Fix this by adding a mi_expect_stop call after sending the
-exec-continue. This way we wait for the breakpoint to be hit before
sending the -trace-stop. I've also changed two of the .* patterns to
include at least the first part of the expected output, e.g:
mi_gdb_test "-trace-stop" {.*} "trace stop"
becomes:
mi_gdb_test "-trace-stop" "\\^done,stop-reason=\"request\",.*" \
"trace stop"
Now, if the output gets out of sync we see more failures which makes
it easier to see where things got out of sync.
With this change in place the test passes reliably for me now.
---
gdb/testsuite/gdb.trace/mi-tsv-changed.exp | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
index ded552cb24b..835a5f0deea 100644
--- a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
@@ -117,13 +117,17 @@ proc test_create_delete_modify_tsv { } {
"continue to begin breakpoint"
mi_gdb_test "-trace-start" {.*\^done} "trace start"
mi_send_resuming_command "exec-continue" "continuing to end"
- mi_gdb_test "-trace-stop" {.*} "trace stop"
+ mi_expect_stop "breakpoint-hit" "end" ""\
+ ".*" ".*" {"" "disp=\"keep\""} \
+ "continue to end breakpoint"
+ mi_gdb_test "-trace-stop" "\\^done,stop-reason=\"request\",.*" \
+ "trace stop"
# Force GDB to get the current value of trace state variable.
- mi_gdb_test "-trace-list-variables" ".*" "list trace variables"
+ mi_gdb_test "-trace-list-variables" "\\^done,trace-variables=.*" \
+ "list trace variables"
mi_gdb_test "tvariable \$tvar3 = 2" \
".*=tsv-modified,name=\"tvar3\",initial=\"2\",current=\"6\".*\\^done" \
"tvariable \$tvar3 modified to 2"
-
}
}
base-commit: a729341631f5ddea915cebe722e4ec198ff96c38
--
2.25.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb/testsuite: fix intermittent failure in gdb.trace/mi-tsv-changed.exp
2026-11-16 22:15 [PATCH] gdb/testsuite: fix intermittent failure in gdb.trace/mi-tsv-changed.exp Andrew Burgess
@ 2026-11-17 17:28 ` Keith Seitz
2026-11-23 23:10 ` Andrew Burgess
0 siblings, 1 reply; 3+ messages in thread
From: Keith Seitz @ 2026-11-17 17:28 UTC (permalink / raw)
To: Andrew Burgess, gdb-patches
Hi,
On 11/16/26 2:15 PM, Andrew Burgess wrote:
> Fix this by adding a mi_expect_stop call after sending the
> -exec-continue. This way we wait for the breakpoint to be hit before
> sending the -trace-stop. I've also changed two of the .* patterns to
> include at least the first part of the expected output, e.g:
>
> mi_gdb_test "-trace-stop" {.*} "trace stop"
>
> becomes:
>
> mi_gdb_test "-trace-stop" "\\^done,stop-reason=\"request\",.*" \
> "trace stop"
>
> Now, if the output gets out of sync we see more failures which makes
> it easier to see where things got out of sync.
>
> With this change in place the test passes reliably for me now.
Thank you so much for working on this. Your approach here is spot-on.
Just one really tiny nit:
>. Eventuallt there's a test with a pattern more details than just
> {.*}, at which point we get a FAIL reported.
Typo. :-)
Reviewed-by: Keith Seitz <keiths@redhat.com>
Keith
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb/testsuite: fix intermittent failure in gdb.trace/mi-tsv-changed.exp
2026-11-17 17:28 ` Keith Seitz
@ 2026-11-23 23:10 ` Andrew Burgess
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2026-11-23 23:10 UTC (permalink / raw)
To: Keith Seitz, gdb-patches
Keith Seitz <keiths@redhat.com> writes:
> Hi,
>
> On 11/16/26 2:15 PM, Andrew Burgess wrote:
>> Fix this by adding a mi_expect_stop call after sending the
>> -exec-continue. This way we wait for the breakpoint to be hit before
>> sending the -trace-stop. I've also changed two of the .* patterns to
>> include at least the first part of the expected output, e.g:
>>
>> mi_gdb_test "-trace-stop" {.*} "trace stop"
>>
>> becomes:
>>
>> mi_gdb_test "-trace-stop" "\\^done,stop-reason=\"request\",.*" \
>> "trace stop"
>>
>> Now, if the output gets out of sync we see more failures which makes
>> it easier to see where things got out of sync.
>>
>> With this change in place the test passes reliably for me now.
>
> Thank you so much for working on this. Your approach here is spot-on.
>
> Just one really tiny nit:
>
> >. Eventuallt there's a test with a pattern more details than just
> > {.*}, at which point we get a FAIL reported.
>
> Typo. :-)
Fixed.
>
> Reviewed-by: Keith Seitz <keiths@redhat.com>
I pushed this patch.
Thanks,
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-23 23:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 22:15 [PATCH] gdb/testsuite: fix intermittent failure in gdb.trace/mi-tsv-changed.exp Andrew Burgess
2026-11-17 17:28 ` Keith Seitz
2026-11-23 23:10 ` Andrew Burgess
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox