[PATCH v2] Fix DAP Stop & Continue event bugs

Simon Farre simon.farre.cx@gmail.com
Wed May 31 14:12:58 GMT 2023


Removed type annotation as it broke gdbpy.

Fixes a bug in the stop and continue event handlers in the DAP code.

Event handlers used the `gdb.selected_thread` which may or may not be
null at the time the event handler is called. It may also return the
wrong thread. The event parameter holds the necessary data.
---
 gdb/python/lib/gdb/dap/events.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py
index d9ae603dfa4..9dc2b58ca5a 100644
--- a/gdb/python/lib/gdb/dap/events.py
+++ b/gdb/python/lib/gdb/dap/events.py
@@ -91,7 +91,7 @@ def _cont(event):
         send_event(
             "continued",
             {
-                "threadId": gdb.selected_thread().global_num,
+                "threadId": event.inferior_thread.global_num,
                 "allThreadsContinued": True,
             },
         )
@@ -139,7 +139,7 @@ def _on_stop(event):
     log("entering _on_stop: " + repr(event))
     global _expected_stop
     obj = {
-        "threadId": gdb.selected_thread().global_num,
+        "threadId": event.inferior_thread.global_num,
         "allThreadsStopped": True,
     }
     if isinstance(event, gdb.BreakpointEvent):
-- 
2.40.1



More information about the Gdb-patches mailing list