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>
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user