[v1] Fix DAP Stop & Continue event bugs
Commit Message
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 | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
@@ -82,7 +82,7 @@ _suppress_cont = False
@in_gdb_thread
-def _cont(event):
+def _cont(event: gdb.events.ContinueEvent):
global _suppress_cont
if _suppress_cont:
log("_suppress_cont case")
@@ -91,7 +91,7 @@ def _cont(event):
send_event(
"continued",
{
- "threadId": gdb.selected_thread().global_num,
+ "threadId": event.inferior_thread.global_num,
"allThreadsContinued": True,
},
)
@@ -135,11 +135,11 @@ class ExecutionInvoker(Invoker):
@in_gdb_thread
-def _on_stop(event):
+def _on_stop(event: gdb.events.StopEvent):
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):