aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/lib
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-01-11 09:52:55 -0700
committerTom Tromey <tromey@adacore.com>2024-01-24 08:50:01 -0700
commit0c566ea7f1d6ae77730e30358aadec22ab302bf8 (patch)
treec573430d4e870b36543906fdf64108b345a1835a /gdb/python/lib
parent7737b1336402cd4682538620ab996bdb7ad0ea79 (diff)
downloadbinutils-0c566ea7f1d6ae77730e30358aadec22ab302bf8.zip
binutils-0c566ea7f1d6ae77730e30358aadec22ab302bf8.tar.gz
binutils-0c566ea7f1d6ae77730e30358aadec22ab302bf8.tar.bz2
Emit stopped event for DAP attach request
In an earlier patch, I wrote: ... It also adds some machinery so that attach stops can be suppressed, which I think is the right thing to do. However, after some discussions here at AdaCore, I now believe this to be incorrect -- while DAP says that expected "continue" events should be suppressed, there is no corresponding language for expected "stop" events, and indeed "stop" events explicitly mention cases like "step". This patch arranges for the stop event to be emitted again.
Diffstat (limited to 'gdb/python/lib')
-rw-r--r--gdb/python/lib/gdb/dap/events.py28
-rw-r--r--gdb/python/lib/gdb/dap/launch.py4
2 files changed, 15 insertions, 17 deletions
diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py
index bb2d1c9..4130222 100644
--- a/gdb/python/lib/gdb/dap/events.py
+++ b/gdb/python/lib/gdb/dap/events.py
@@ -147,14 +147,14 @@ def _cont(event):
)
-_suppress_stop = False
+_expected_stop_reason = None
@in_gdb_thread
-def suppress_stop():
- """Indicate that the next stop should not emit an event."""
- global _suppress_stop
- _suppress_stop = True
+def expect_stop(reason: str):
+ """Indicate that the next stop should be for REASON."""
+ global _expected_stop_reason
+ _expected_stop_reason = reason
_expected_pause = False
@@ -209,24 +209,22 @@ def _on_stop(event):
global inferior_running
inferior_running = False
- global _suppress_stop
- if _suppress_stop:
- _suppress_stop = False
- log("suppressing stop in _on_stop")
- return
-
log("entering _on_stop: " + repr(event))
- log(" details: " + repr(event.details))
+ if hasattr(event, "details"):
+ log(" details: " + repr(event.details))
obj = {
"threadId": gdb.selected_thread().global_num,
"allThreadsStopped": True,
}
if isinstance(event, gdb.BreakpointEvent):
obj["hitBreakpointIds"] = [x.number for x in event.breakpoints]
+
global _expected_pause
- # Some stop events still do not emit details. For example,
- # 'attach' causes a reason-less stop.
- if "reason" not in event.details:
+ global _expected_stop_reason
+ if _expected_stop_reason is not None:
+ obj["reason"] = _expected_stop_reason
+ _expected_stop_reason = None
+ elif "reason" not in event.details:
# This can only really happen via a "repl" evaluation of
# something like "attach". In this case just emit a generic
# stop.
diff --git a/gdb/python/lib/gdb/dap/launch.py b/gdb/python/lib/gdb/dap/launch.py
index bf9640a..184af16 100644
--- a/gdb/python/lib/gdb/dap/launch.py
+++ b/gdb/python/lib/gdb/dap/launch.py
@@ -18,7 +18,7 @@ import gdb
# These are deprecated in 3.9, but required in older versions.
from typing import Mapping, Optional, Sequence
-from .events import exec_and_expect_stop, expect_process, suppress_stop
+from .events import exec_and_expect_stop, expect_process, expect_stop
from .server import request, capability
from .startup import exec_and_log, DAPException
@@ -88,7 +88,7 @@ def attach(
else:
raise DAPException("attach requires either 'pid' or 'target'")
expect_process("attach")
- suppress_stop()
+ expect_stop("attach")
exec_and_log(cmd)