public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Farre <simon.farre.cx@gmail.com>
To: gdb-patches@sourceware.org
Cc: Simon Farre <simon.farre.cx@gmail.com>
Subject: [PATCH v1] Fix DAP Stop & Continue event bugs
Date: Wed, 31 May 2023 15:59:52 +0200	[thread overview]
Message-ID: <20230531135952.207022-1-simon.farre.cx@gmail.com> (raw)

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(-)

diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py
index d9ae603dfa4..bd46c233e1c 100644
--- a/gdb/python/lib/gdb/dap/events.py
+++ b/gdb/python/lib/gdb/dap/events.py
@@ -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):
-- 
2.40.1


                 reply	other threads:[~2023-05-31 13:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230531135952.207022-1-simon.farre.cx@gmail.com \
    --to=simon.farre.cx@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).