* [PATCH] [gdb/testsuite] Fix another timeout in gdb.base/bg-execution-repeat.exp
@ 2025-04-14 11:51 Tom de Vries
2025-04-16 15:26 ` Alexandra Petlanova Hajkova
0 siblings, 1 reply; 4+ messages in thread
From: Tom de Vries @ 2025-04-14 11:51 UTC (permalink / raw)
To: gdb-patches
With test-case gdb.base/bg-execution-repeat.exp, occasionally I run into a
timeout:
...
(gdb) c 1&
Will stop next time breakpoint 1 is reached. Continuing.
(gdb) PASS: $exp: c 1&: c 1&
Breakpoint 2, foo () at bg-execution-repeat.c:23
23 return 0; /* set break here */
PASS: $exp: c 1&: breakpoint hit 1
Will stop next time breakpoint 2 is reached. Continuing.
(gdb) PASS: $exp: c 1&: repeat bg command
print 1
$1 = 1
(gdb) PASS: $exp: c 1&: input still accepted
interrupt
(gdb) PASS: $exp: c 1&: interrupt
Program received signal SIGINT, Interrupt.
foo () at bg-execution-repeat.c:24
24 }
PASS: $exp: c 1&: interrupt received
set var do_wait=0
(gdb) PASS: $exp: c 1&: set var do_wait=0
continue&
Continuing.
(gdb) PASS: $exp: c 1&: continue&
FAIL: $exp: c 1&: breakpoint hit 2 (timeout)
...
I can reproduce it reliably by adding a "sleep (1)" before the "do_wait = 1"
in the .c file.
The timeout happens as follows:
- with the inferior stopped at main, gdb continues (command c 1&)
- the inferior hits the breakpoint at foo
- gdb continues (using the repeat command functionality)
- the inferior is interrupted
- inferior variable do_wait gets set to 0. The assumption here is that the
inferior has progressed enough that do_wait is set to 1 at that point, but
that happens not to be the case. Consequently, this has no effect.
- gdb continues
- the inferior sets do_wait to 1
- the inferior enters the wait function, and wait for do_wait to become 0,
which never happens.
Fix this by moving the "do_wait = 1" to before the first call to foo.
Tested on x86_64-linux.
---
gdb/testsuite/gdb.base/bg-execution-repeat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/bg-execution-repeat.c b/gdb/testsuite/gdb.base/bg-execution-repeat.c
index 8e9bae4dfbb..3c0cc763e48 100644
--- a/gdb/testsuite/gdb.base/bg-execution-repeat.c
+++ b/gdb/testsuite/gdb.base/bg-execution-repeat.c
@@ -37,9 +37,9 @@ main (void)
{
alarm (60);
+ do_wait = 1;
foo ();
- do_wait = 1;
wait ();
/* do_wait set to 0 externally. */
base-commit: e25c84752c9df2bf3a999b53afb58e5bebaf3b7c
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [gdb/testsuite] Fix another timeout in gdb.base/bg-execution-repeat.exp
2025-04-14 11:51 [PATCH] [gdb/testsuite] Fix another timeout in gdb.base/bg-execution-repeat.exp Tom de Vries
@ 2025-04-16 15:26 ` Alexandra Petlanova Hajkova
2025-04-16 15:40 ` Tom de Vries
0 siblings, 1 reply; 4+ messages in thread
From: Alexandra Petlanova Hajkova @ 2025-04-16 15:26 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2002 bytes --]
On Mon, Apr 14, 2025 at 1:51 PM Tom de Vries <tdevries@suse.de> wrote:
> With test-case gdb.base/bg-execution-repeat.exp, occasionally I run into a
> timeout:
> ...
> (gdb) c 1&
> Will stop next time breakpoint 1 is reached. Continuing.
> (gdb) PASS: $exp: c 1&: c 1&
>
> Breakpoint 2, foo () at bg-execution-repeat.c:23
> 23 return 0; /* set break here */
> PASS: $exp: c 1&: breakpoint hit 1
>
> Will stop next time breakpoint 2 is reached. Continuing.
> (gdb) PASS: $exp: c 1&: repeat bg command
> print 1
> $1 = 1
> (gdb) PASS: $exp: c 1&: input still accepted
> interrupt
> (gdb) PASS: $exp: c 1&: interrupt
>
> Program received signal SIGINT, Interrupt.
> foo () at bg-execution-repeat.c:24
> 24 }
> PASS: $exp: c 1&: interrupt received
> set var do_wait=0
> (gdb) PASS: $exp: c 1&: set var do_wait=0
> continue&
> Continuing.
> (gdb) PASS: $exp: c 1&: continue&
> FAIL: $exp: c 1&: breakpoint hit 2 (timeout)
> ...
>
> I can reproduce it reliably by adding a "sleep (1)" before the "do_wait =
> 1"
> in the .c file.
>
> The timeout happens as follows:
> - with the inferior stopped at main, gdb continues (command c 1&)
> - the inferior hits the breakpoint at foo
> - gdb continues (using the repeat command functionality)
> - the inferior is interrupted
> - inferior variable do_wait gets set to 0. The assumption here is that the
> inferior has progressed enough that do_wait is set to 1 at that point,
> but
> that happens not to be the case. Consequently, this has no effect.
> - gdb continues
> - the inferior sets do_wait to 1
> - the inferior enters the wait function, and wait for do_wait to become 0,
> which never happens.
>
> Fix this by moving the "do_wait = 1" to before the first call to foo.
>
> Tested on x86_64-linux.
> ---
>
Hi Tom,
I also tested this on aarch64 and it works as expected, I think it's a
reasonable change.
Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
[-- Attachment #2: Type: text/html, Size: 2633 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [gdb/testsuite] Fix another timeout in gdb.base/bg-execution-repeat.exp
2025-04-16 15:26 ` Alexandra Petlanova Hajkova
@ 2025-04-16 15:40 ` Tom de Vries
0 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2025-04-16 15:40 UTC (permalink / raw)
To: Alexandra Petlanova Hajkova; +Cc: gdb-patches
On 4/16/25 17:26, Alexandra Petlanova Hajkova wrote:
>
>
> On Mon, Apr 14, 2025 at 1:51 PM Tom de Vries <tdevries@suse.de
> <mailto:tdevries@suse.de>> wrote:
>
> With test-case gdb.base/bg-execution-repeat.exp, occasionally I run
> into a
> timeout:
> ...
> (gdb) c 1&
> Will stop next time breakpoint 1 is reached. Continuing.
> (gdb) PASS: $exp: c 1&: c 1&
>
> Breakpoint 2, foo () at bg-execution-repeat.c:23
> 23 return 0; /* set break here */
> PASS: $exp: c 1&: breakpoint hit 1
>
> Will stop next time breakpoint 2 is reached. Continuing.
> (gdb) PASS: $exp: c 1&: repeat bg command
> print 1
> $1 = 1
> (gdb) PASS: $exp: c 1&: input still accepted
> interrupt
> (gdb) PASS: $exp: c 1&: interrupt
>
> Program received signal SIGINT, Interrupt.
> foo () at bg-execution-repeat.c:24
> 24 }
> PASS: $exp: c 1&: interrupt received
> set var do_wait=0
> (gdb) PASS: $exp: c 1&: set var do_wait=0
> continue&
> Continuing.
> (gdb) PASS: $exp: c 1&: continue&
> FAIL: $exp: c 1&: breakpoint hit 2 (timeout)
> ...
>
> I can reproduce it reliably by adding a "sleep (1)" before the
> "do_wait = 1"
> in the .c file.
>
> The timeout happens as follows:
> - with the inferior stopped at main, gdb continues (command c 1&)
> - the inferior hits the breakpoint at foo
> - gdb continues (using the repeat command functionality)
> - the inferior is interrupted
> - inferior variable do_wait gets set to 0. The assumption here is
> that the
> inferior has progressed enough that do_wait is set to 1 at that
> point, but
> that happens not to be the case. Consequently, this has no effect.
> - gdb continues
> - the inferior sets do_wait to 1
> - the inferior enters the wait function, and wait for do_wait to
> become 0,
> which never happens.
>
> Fix this by moving the "do_wait = 1" to before the first call to foo.
>
> Tested on x86_64-linux.
> ---
>
> Hi Tom,
>
> I also tested this on aarch64 and it works as expected, I think it's a
> reasonable change.
>
Hi Alexandra,
thanks for the review, pushed.
- Tom
> Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com
> <mailto:ahajkova@redhat.com>>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] [gdb/testsuite] Fix another timeout in gdb.base/bg-execution-repeat.exp
@ 2025-04-10 3:09 Tom de Vries
0 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2025-04-10 3:09 UTC (permalink / raw)
To: gdb-patches
With a gdb 16.2 based package, I ran into:
...
(gdb) PASS: gdb.base/bg-execution-repeat.exp: c 1&: input still accepted
interrupt
(gdb) PASS: gdb.base/bg-execution-repeat.exp: c 1&: interrupt
set var do_wait=0
(gdb) PASS: gdb.base/bg-execution-repeat.exp: c 1&: set var do_wait=0
continue&
Cannot execute this command while the selected thread is running.
(gdb)
Program received signal SIGINT, Interrupt.
PASS: gdb.base/bg-execution-repeat.exp: c 1&: continue&
0x00007ffff7cf1503 in clock_nanosleep@GLIBC_2.2.5 () from /lib64/libc.so.6
FAIL: gdb.base/bg-execution-repeat.exp: c 1&: breakpoint hit 2 (timeout)
...
Fix this by waiting for "Program received signal SIGINT, Interrupt" after
issuing the interrupt command.
Tested on x86_64-linux.
---
gdb/testsuite/gdb.base/bg-execution-repeat.exp | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/gdb/testsuite/gdb.base/bg-execution-repeat.exp b/gdb/testsuite/gdb.base/bg-execution-repeat.exp
index b1496ee7d5a..d5580fb8e34 100644
--- a/gdb/testsuite/gdb.base/bg-execution-repeat.exp
+++ b/gdb/testsuite/gdb.base/bg-execution-repeat.exp
@@ -67,6 +67,17 @@ proc test {continue_cmd} {
# enable the "set var" command with an interrupt / continue& pair.
gdb_test -no-prompt-anchor "interrupt"
+ set test "interrupt received"
+ set re [string_to_regexp "Program received signal SIGINT, Interrupt."]
+ gdb_expect {
+ -re $re {
+ pass $test
+ }
+ timeout {
+ fail "$test (timeout)"
+ }
+ }
+
# Allow the breakpoint to trigger.
gdb_test -no-prompt-anchor "set var do_wait=0"
base-commit: 6fe4e5bd10b996428a557e036c07c5839a8e0a49
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-16 15:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-14 11:51 [PATCH] [gdb/testsuite] Fix another timeout in gdb.base/bg-execution-repeat.exp Tom de Vries
2025-04-16 15:26 ` Alexandra Petlanova Hajkova
2025-04-16 15:40 ` Tom de Vries
-- strict thread matches above, loose matches on Subject: below --
2025-04-10 3:09 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