aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-07-24 09:14:20 -0600
committerTom Tromey <tromey@adacore.com>2023-08-01 12:52:26 -0600
commitf131a5790812c3ca69a4fcd9cd2b9ac15b29d181 (patch)
tree9897069805cad9ce21c12180e9b7777097ebf18f /gdb/python
parent7abfd03742d2cea591dca940aa748e865f906018 (diff)
downloadgdb-f131a5790812c3ca69a4fcd9cd2b9ac15b29d181.zip
gdb-f131a5790812c3ca69a4fcd9cd2b9ac15b29d181.tar.gz
gdb-f131a5790812c3ca69a4fcd9cd2b9ac15b29d181.tar.bz2
Add "cwd" parameter to DAP launch request
This adds the "cwd" parameter to the DAP launch request. This came up here: https://github.com/eclipse-cdt-cloud/cdt-gdb-adapter/issues/90 ... and seemed like a good idea. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/lib/gdb/dap/launch.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/gdb/python/lib/gdb/dap/launch.py b/gdb/python/lib/gdb/dap/launch.py
index c3c09bc..d13037f 100644
--- a/gdb/python/lib/gdb/dap/launch.py
+++ b/gdb/python/lib/gdb/dap/launch.py
@@ -23,12 +23,22 @@ from .server import request, capability
from .startup import send_gdb, send_gdb_with_response, in_gdb_thread, exec_and_log
+# The program being launched, or None. This should only be access
+# from the DAP thread.
_program = None
@in_gdb_thread
-def _set_args_env(args, env):
+def _launch_setup(program, cwd, args, env, stopAtBeginningOfMainSubprogram):
+ if cwd is not None:
+ exec_and_log("cd " + cwd)
+ if program is not None:
+ exec_and_log("file " + program)
inf = gdb.selected_inferior()
+ if stopAtBeginningOfMainSubprogram:
+ main = inf.main_name
+ if main is not None:
+ exec_and_log("tbreak " + main)
inf.arguments = args
if env is not None:
inf.clear_env()
@@ -36,14 +46,6 @@ def _set_args_env(args, env):
inf.set_env(name, value)
-@in_gdb_thread
-def _break_at_main():
- inf = gdb.selected_inferior()
- main = inf.main_name
- if main is not None:
- exec_and_log("tbreak " + main)
-
-
# Any parameters here are necessarily extensions -- DAP requires this
# from implementations. Any additions or changes here should be
# documented in the gdb manual.
@@ -51,19 +53,17 @@ def _break_at_main():
def launch(
*,
program: Optional[str] = None,
+ cwd: Optional[str] = None,
args: Sequence[str] = (),
env: Optional[Mapping[str, str]] = None,
stopAtBeginningOfMainSubprogram: bool = False,
**extra,
):
- if program is not None:
- global _program
- _program = program
- send_gdb("file " + _program)
- if stopAtBeginningOfMainSubprogram:
- send_gdb(_break_at_main)
- if len(args) > 0 or env is not None:
- send_gdb(lambda: _set_args_env(args, env))
+ global _program
+ _program = program
+ send_gdb(
+ lambda: _launch_setup(program, cwd, args, env, stopAtBeginningOfMainSubprogram)
+ )
@request("attach")