aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-12-07 09:51:52 -0700
committerTom Tromey <tromey@adacore.com>2023-12-22 09:05:17 -0700
commiteb6476e2db406ba323efba438b0d1851e86d02e5 (patch)
tree8887453aacc110380b5b0a7423160a229999bd04 /gdb/python
parent401b5b00ecef262ce36a8810775087c7d9928900 (diff)
downloadbinutils-eb6476e2db406ba323efba438b0d1851e86d02e5.zip
binutils-eb6476e2db406ba323efba438b0d1851e86d02e5.tar.gz
binutils-eb6476e2db406ba323efba438b0d1851e86d02e5.tar.bz2
Add 'program' to DAP 'attach' request
In many cases, it's not possible for gdb to discover the executable when a DAP 'attach' request is used. This patch lets the IDE supply this information. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/lib/gdb/dap/launch.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/gdb/python/lib/gdb/dap/launch.py b/gdb/python/lib/gdb/dap/launch.py
index 7014047..675542c 100644
--- a/gdb/python/lib/gdb/dap/launch.py
+++ b/gdb/python/lib/gdb/dap/launch.py
@@ -28,6 +28,11 @@ from .startup import exec_and_log
_program = None
+# True if the program was attached, False otherwise. This should only
+# be accessed from the gdb thread.
+_attach = False
+
+
# Any parameters here are necessarily extensions -- DAP requires this
# from implementations. Any additions or changes here should be
# documented in the gdb manual.
@@ -43,6 +48,8 @@ def launch(
):
global _program
_program = program
+ global _attach
+ _attach = False
if cwd is not None:
exec_and_log("cd " + cwd)
if program is not None:
@@ -60,10 +67,20 @@ def launch(
@request("attach")
-def attach(*, pid: Optional[int] = None, target: Optional[str] = None, **args):
+def attach(
+ *,
+ program: Optional[str] = None,
+ pid: Optional[int] = None,
+ target: Optional[str] = None,
+ **args,
+):
# Ensure configurationDone does not try to run.
+ global _attach
+ _attach = True
global _program
- _program = None
+ _program = program
+ if program is not None:
+ exec_and_log("file " + program)
if pid is not None:
cmd = "attach " + str(pid)
elif target is not None:
@@ -77,7 +94,7 @@ def attach(*, pid: Optional[int] = None, target: Optional[str] = None, **args):
@capability("supportsConfigurationDoneRequest")
@request("configurationDone", response=False)
def config_done(**args):
- global _program
- if _program is not None:
+ global _attach
+ if not _attach:
expect_process("process")
exec_and_expect_stop("run")