public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v1] [gdb/dap] Add thread exited event
@ 2023-06-05 12:59 Simon Farre
  2023-06-05 13:48 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Farre @ 2023-06-05 12:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Farre

Reports a thread exit according to the DAP spec:
https://microsoft.github.io/debug-adapter-protocol/specification#Events_Thread

This patch requires the ThreadExitedEvent to be checked in,
in order to work. That patch is found here https://sourceware.org/pipermail/gdb-patches/2023-June/200071.html
---
 gdb/python/lib/gdb/dap/events.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py
index d9ae603dfa4..1618f9cd6ac 100644
--- a/gdb/python/lib/gdb/dap/events.py
+++ b/gdb/python/lib/gdb/dap/events.py
@@ -66,17 +66,23 @@ def _bp_deleted(event):
         },
     )
 
-
 @in_gdb_thread
-def _new_thread(event):
+def thread_event(event, reason):
     send_event(
         "thread",
         {
-            "reason": "started",
+            "reason": reason,
             "threadId": event.inferior_thread.global_num,
         },
     )
 
+@in_gdb_thread
+def _new_thread(event):
+    thread_event(event, "started")
+
+@in_gdb_thread
+def _thread_exited(event):
+    thread_event(event, "exited")
 
 _suppress_cont = False
 
@@ -160,4 +166,5 @@ gdb.events.breakpoint_created.connect(_bp_created)
 gdb.events.breakpoint_modified.connect(_bp_modified)
 gdb.events.breakpoint_deleted.connect(_bp_deleted)
 gdb.events.new_thread.connect(_new_thread)
+gdb.events.thread_exited.connect(_thread_exited)
 gdb.events.cont.connect(_cont)
-- 
2.40.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] [gdb/dap] Add thread exited event
  2023-06-05 12:59 [PATCH v1] [gdb/dap] Add thread exited event Simon Farre
@ 2023-06-05 13:48 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2023-06-05 13:48 UTC (permalink / raw)
  To: Simon Farre via Gdb-patches; +Cc: Simon Farre

>>>>> "Simon" == Simon Farre via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> Reports a thread exit according to the DAP spec:
Simon> https://microsoft.github.io/debug-adapter-protocol/specification#Events_Thread

We discussed on irc but FTR this commit message should have a trailer
like:

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30474

(and then close the bug & mark it target-milestone:14.1 when the patch
lands)

Simon> +@in_gdb_thread
Simon> +def _new_thread(event):
Simon> +    thread_event(event, "started")
Simon> +
Simon> +@in_gdb_thread
Simon> +def _thread_exited(event):
Simon> +    thread_event(event, "exited")
 
Not sure but you probably need to run 'black' on the file.

The patch looks good to me, once the prerequisite lands.  It would be
nice to have a test case, though I see I neglected to write one for the
thread-creation event.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-05 13:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-05 12:59 [PATCH v1] [gdb/dap] Add thread exited event Simon Farre
2023-06-05 13:48 ` 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).