* [PATCH] testsuite, mi: avoid a clang bug in 'user-selected-context-sync.exp'
@ 2021-03-29 14:03 Tankut Baris Aktemur
2021-03-29 14:36 ` Simon Marchi
0 siblings, 1 reply; 2+ messages in thread
From: Tankut Baris Aktemur @ 2021-03-29 14:03 UTC (permalink / raw)
To: gdb-patches
This test causes several timeouts for Clang, taking too long time to
finish. The reason is, for an infinite loop of the form
while(1); /* suppose this is line 30. */
Clang generates code that looks like
0x00000000004004d4 <+4>: jmp 0x4004d9 <loop+9>
0x00000000004004d9 <+9>: jmp 0x4004d9 <loop+9>
So, the real loop is the instruction at address 0x4004d9. But a
breakpoint that's defined at the loop line (assume line 30 in this
case) is inserted at address 0x4004d4.
(gdb) break 30
Breakpoint 1 at 0x4004d4: file test.c, line 30.
Therefore, continuing a thread that was spinning on the loop does not hit
the breakpoint. The bug is reported at
https://bugs.llvm.org/show_bug.cgi?id=49614
Tweak the infinite loop to spin on a variable to avoid this bug. The
test is unrelated to the bug.
gdb/testsuite/ChangeLog:
2021-03-29 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.mi/user-selected-context-sync.exp: Spin on a variable in
the infinite loop to avoid a Clang bug.
---
gdb/testsuite/gdb.mi/user-selected-context-sync.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.c b/gdb/testsuite/gdb.mi/user-selected-context-sync.c
index 500a118a2dc..0f8a966f69d 100644
--- a/gdb/testsuite/gdb.mi/user-selected-context-sync.c
+++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.c
@@ -27,7 +27,8 @@ static pthread_barrier_t barrier;
static void
child_sub_function (void)
{
- while (1); /* thread loop line */
+ int spin = 1;
+ while (spin); /* thread loop line */
}
static void *
@@ -57,7 +58,8 @@ main (void)
pthread_barrier_wait (&barrier);
- while (1); /* main break line */
+ int spin = 1;
+ while (spin); /* main break line */
return 0;
}
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] testsuite, mi: avoid a clang bug in 'user-selected-context-sync.exp'
2021-03-29 14:03 [PATCH] testsuite, mi: avoid a clang bug in 'user-selected-context-sync.exp' Tankut Baris Aktemur
@ 2021-03-29 14:36 ` Simon Marchi
0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2021-03-29 14:36 UTC (permalink / raw)
To: Tankut Baris Aktemur, gdb-patches
On 2021-03-29 10:03 a.m., Tankut Baris Aktemur via Gdb-patches wrote:> This test causes several timeouts for Clang, taking too long time to
> finish. The reason is, for an infinite loop of the form
>
> while(1); /* suppose this is line 30. */
>
> Clang generates code that looks like
>
> 0x00000000004004d4 <+4>: jmp 0x4004d9 <loop+9>
> 0x00000000004004d9 <+9>: jmp 0x4004d9 <loop+9>
>
> So, the real loop is the instruction at address 0x4004d9. But a
> breakpoint that's defined at the loop line (assume line 30 in this
> case) is inserted at address 0x4004d4.
>
> (gdb) break 30
> Breakpoint 1 at 0x4004d4: file test.c, line 30.
>
> Therefore, continuing a thread that was spinning on the loop does not hit
> the breakpoint. The bug is reported at
>
> https://bugs.llvm.org/show_bug.cgi?id=49614
>
> Tweak the infinite loop to spin on a variable to avoid this bug. The
> test is unrelated to the bug.
>
> gdb/testsuite/ChangeLog:
> 2021-03-29 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
>
> * gdb.mi/user-selected-context-sync.exp: Spin on a variable in
> the infinite loop to avoid a Clang bug.
> ---
> gdb/testsuite/gdb.mi/user-selected-context-sync.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.c b/gdb/testsuite/gdb.mi/user-selected-context-sync.c
> index 500a118a2dc..0f8a966f69d 100644
> --- a/gdb/testsuite/gdb.mi/user-selected-context-sync.c
> +++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.c
> @@ -27,7 +27,8 @@ static pthread_barrier_t barrier;
> static void
> child_sub_function (void)
> {
> - while (1); /* thread loop line */
> + int spin = 1;
> + while (spin); /* thread loop line */
> }
>
> static void *
> @@ -57,7 +58,8 @@ main (void)
>
> pthread_barrier_wait (&barrier);
>
> - while (1); /* main break line */
> + int spin = 1;
> + while (spin); /* main break line */
>
> return 0;
> }
>
Thanks, this is OK. Maybe just add a comment in the code, otherwise
someone might be tempted to "optimize" it. If they see the comment,
they'll be able to "git blame" and get the full story.
Simon
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-29 14:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-29 14:03 [PATCH] testsuite, mi: avoid a clang bug in 'user-selected-context-sync.exp' Tankut Baris Aktemur
2021-03-29 14:36 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).