From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/5] gdb.threads/next-bp-other-thread.c: Ensure child thread is started.
Date: Fri, 17 Feb 2023 12:38:17 -0800 [thread overview]
Message-ID: <20230217203818.11287-5-jhb@FreeBSD.org> (raw)
In-Reply-To: <20230217203818.11287-1-jhb@FreeBSD.org>
Use a pthread_barrier to ensure the child thread is started before
the main thread gets to the first breakpoint.
---
gdb/testsuite/gdb.threads/next-bp-other-thread.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/gdb/testsuite/gdb.threads/next-bp-other-thread.c b/gdb/testsuite/gdb.threads/next-bp-other-thread.c
index 60aa029464c..33c6ec11982 100644
--- a/gdb/testsuite/gdb.threads/next-bp-other-thread.c
+++ b/gdb/testsuite/gdb.threads/next-bp-other-thread.c
@@ -22,9 +22,13 @@
/* Always zero, used in breakpoint condition. */
volatile int global_zero;
+static pthread_barrier_t threads_started_barrier;
+
void *
child_function (void *arg)
{
+ pthread_barrier_wait (&threads_started_barrier);
+
while (1)
{
usleep (1); /* set breakpoint child here */
@@ -39,7 +43,12 @@ main (void)
pthread_t child_thread;
int res;
+ pthread_barrier_init (&threads_started_barrier, NULL, 2);
+
res = pthread_create (&child_thread, NULL, child_function, NULL);
+
+ pthread_barrier_wait (&threads_started_barrier);
+
sleep (2); /* set wait-thread breakpoint here */
exit (EXIT_SUCCESS);
}
--
2.38.1
next prev parent reply other threads:[~2023-02-17 20:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-17 20:38 [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
2023-02-17 20:38 ` [PATCH 1/5] gdb.threads/multi-create: Double the existing stack size John Baldwin
2023-02-17 20:38 ` [PATCH 2/5] gdb.base/catch-syscall.exp: Remove some Linux-only assumptions John Baldwin
2023-02-17 20:38 ` [PATCH 3/5] gdb.threads/execl.c: Ensure all threads are started before execl John Baldwin
2023-02-17 20:38 ` John Baldwin [this message]
2023-02-17 20:38 ` [PATCH 5/5] gdb tests: Allow for "LWP" in thread IDs from info threads John Baldwin
2023-03-03 17:59 ` [PING] [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
2023-03-03 19:16 ` Tom Tromey
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=20230217203818.11287-5-jhb@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).