public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] Fix DAP Stop & Continue event bugs
@ 2023-05-31 14:12 Simon Farre
  2023-05-31 14:39 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Farre @ 2023-05-31 14:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Farre

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


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

* Re: [PATCH v2] Fix DAP Stop & Continue event bugs
  2023-05-31 14:12 [PATCH v2] Fix DAP Stop & Continue event bugs Simon Farre
@ 2023-05-31 14:39 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2023-05-31 14:39 UTC (permalink / raw)
  To: Simon Farre via Gdb-patches; +Cc: Simon Farre

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

Simon> Removed type annotation as it broke gdbpy.
Simon> Fixes a bug in the stop and continue event handlers in the DAP code.

Simon> Event handlers used the `gdb.selected_thread` which may or may not be
Simon> null at the time the event handler is called. It may also return the
Simon> wrong thread. The event parameter holds the necessary data.

Thank you.  This is ok.

Tom

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

end of thread, other threads:[~2023-05-31 14:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31 14:12 [PATCH v2] Fix DAP Stop & Continue event bugs Simon Farre
2023-05-31 14:39 ` 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).