From a18b53a8f68bc4fde9bd64b553f4ea500b30c626 Mon Sep 17 00:00:00 2001 From: Simon Farre Date: Mon, 5 Jun 2023 14:56:54 +0200 Subject: [PATCH] Add thread exited event 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 Approved-By: Tom Tromey --- gdb/python/lib/gdb/dap/events.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py index c1631442746..ab36dc559b2 100644 --- a/gdb/python/lib/gdb/dap/events.py +++ b/gdb/python/lib/gdb/dap/events.py @@ -58,23 +58,33 @@ def _bp_created(event): @in_gdb_thread -def _bp_deleted(event): +def thread_event(event, reason): send_event( - "breakpoint", + "thread", { - "reason": "removed", - "breakpoint": breakpoint_descriptor(event), + "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") + + +@in_gdb_thread +def _bp_deleted(event): send_event( - "thread", + "breakpoint", { - "reason": "started", - "threadId": event.inferior_thread.global_num, + "reason": "removed", + "breakpoint": breakpoint_descriptor(event), }, ) @@ -173,5 +183,6 @@ 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) gdb.events.new_objfile.connect(_new_objfile) -- 2.30.2