[v2,gdb/dap] Add thread exited event

Message ID 20230801153659.109243-1-simon.farre.cx@gmail.com
State New
Headers
Series [v2,gdb/dap] Add thread exited event |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 warning Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm warning Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_check--master-arm warning Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 warning Patch failed to apply

Commit Message

Simon Farre Aug. 1, 2023, 3:36 p.m. UTC
  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

Formatted correctly using black

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30474
---
 gdb/python/lib/gdb/dap/events.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
  

Comments

Tom Tromey Aug. 1, 2023, 3:39 p.m. UTC | #1
>>>>> "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

Simon> This patch requires the ThreadExitedEvent to be checked in,
Simon> in order to work. That patch is found here https://sourceware.org/pipermail/gdb-patches/2023-June/200071.html

Simon> Formatted correctly using black

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

Thank you.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  

Patch

diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py
index d9ae603dfa4..19838756c74 100644
--- a/gdb/python/lib/gdb/dap/events.py
+++ b/gdb/python/lib/gdb/dap/events.py
@@ -68,16 +68,26 @@  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 +170,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)