From eb6476e2db406ba323efba438b0d1851e86d02e5 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 7 Dec 2023 09:51:52 -0700 Subject: 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 --- gdb/python/lib/gdb/dap/launch.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'gdb/python') 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") -- cgit v1.1