* [PATCH] Change py-thread-exited.exp to work with gdbserver
@ 2023-07-31 17:32 Tom Tromey
2023-08-10 17:42 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2023-07-31 17:32 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
gdbserver does not notify gdb of new threads when they are created.
I'm not sure if this is documented anywhere, but it is mentioned on
this page:
https://sourceware.org/gdb/wiki/LocalRemoteFeatureParity
Search for "Finding new threads in the inferior".
This behavior is a bit unfortunate -- I would think that it would be
better to arrange for such notification if something on the gdb side
is interested.
Meanwhile, this patch fixes py-thread-exited.exp to work around this
problem.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30677
---
gdb/testsuite/gdb.python/py-thread-exited.c | 6 +++---
gdb/testsuite/gdb.python/py-thread-exited.exp | 12 ++++++++++--
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/gdb/testsuite/gdb.python/py-thread-exited.c b/gdb/testsuite/gdb.python/py-thread-exited.c
index fd0342bc765..d62133ba59e 100644
--- a/gdb/testsuite/gdb.python/py-thread-exited.c
+++ b/gdb/testsuite/gdb.python/py-thread-exited.c
@@ -24,14 +24,14 @@ pthread_t thread3_id;
void* do_thread (void* d)
{
- return NULL;
+ return NULL; /* In thread */
}
int main (void)
{
pthread_create (&thread2_id, NULL, do_thread, NULL);
- pthread_join (thread2_id, NULL);
pthread_create (&thread3_id, NULL, do_thread, NULL);
+ pthread_join (thread2_id, NULL);
pthread_join (thread3_id, NULL);
- return 12;
+ return 12; /* Done */
}
diff --git a/gdb/testsuite/gdb.python/py-thread-exited.exp b/gdb/testsuite/gdb.python/py-thread-exited.exp
index 957585958a2..937816106e2 100644
--- a/gdb/testsuite/gdb.python/py-thread-exited.exp
+++ b/gdb/testsuite/gdb.python/py-thread-exited.exp
@@ -36,9 +36,17 @@ if ![runto_main] {
return -1
}
-gdb_breakpoint 37 "last of main"
-gdb_continue_to_breakpoint "continue to breakpoint"
+gdb_breakpoint [gdb_get_line_number "In thread" ${testfile}.c]
+gdb_breakpoint [gdb_get_line_number "Done" ${testfile}.c]
+
+# gdbserver does not notify new threads on creation. In order for
+# this test to even see that the threads are created, we have to
+# arrange to stop when they are running.
+gdb_continue_to_breakpoint "continue to first in-thread breakpoint"
+gdb_continue_to_breakpoint "continue to second in-thread breakpoint"
+
+gdb_continue_to_breakpoint "continue to end breakpoint"
gdb_test "python print(threadOneExit)" \
".*event type: thread-exited. global num: 2.*"
--
2.40.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Change py-thread-exited.exp to work with gdbserver
2023-07-31 17:32 [PATCH] Change py-thread-exited.exp to work with gdbserver Tom Tromey
@ 2023-08-10 17:42 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2023-08-10 17:42 UTC (permalink / raw)
To: Tom Tromey via Gdb-patches; +Cc: Tom Tromey
>>>>> "Tom" == Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> gdbserver does not notify gdb of new threads when they are created.
Tom> I'm not sure if this is documented anywhere, but it is mentioned on
Tom> this page:
Tom> https://sourceware.org/gdb/wiki/LocalRemoteFeatureParity
Tom> Search for "Finding new threads in the inferior".
Tom> This behavior is a bit unfortunate -- I would think that it would be
Tom> better to arrange for such notification if something on the gdb side
Tom> is interested.
Tom> Meanwhile, this patch fixes py-thread-exited.exp to work around this
Tom> problem.
Tom> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30677
I'm checking this in.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-10 17:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-31 17:32 [PATCH] Change py-thread-exited.exp to work with gdbserver Tom Tromey
2023-08-10 17:42 ` Tom Tromey
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).