diff options
author | Tom Tromey <tromey@adacore.com> | 2023-05-01 13:59:20 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-05-24 06:16:10 -0600 |
commit | ea33730dfa4b2e639f99bb4c1f4f8f073ef5b937 (patch) | |
tree | a96066576965da75c02e23c09fb043b3207cd7ed /gdb/python | |
parent | 3153113252f3b949a159439a17e88af8ff0dce30 (diff) | |
download | binutils-ea33730dfa4b2e639f99bb4c1f4f8f073ef5b937.zip binutils-ea33730dfa4b2e639f99bb4c1f4f8f073ef5b937.tar.gz binutils-ea33730dfa4b2e639f99bb4c1f4f8f073ef5b937.tar.bz2 |
Add "args" and "env" parameters to DAP launch request
This patch augments the DAP launch request with some optional new
parameters that let the client control the command-line arguments and
the environment of the inferior.
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/lib/gdb/dap/launch.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/gdb/python/lib/gdb/dap/launch.py b/gdb/python/lib/gdb/dap/launch.py index b4102cc..21499a3 100644 --- a/gdb/python/lib/gdb/dap/launch.py +++ b/gdb/python/lib/gdb/dap/launch.py @@ -13,20 +13,36 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import gdb from .events import ExecutionInvoker from .server import request, capability -from .startup import send_gdb +from .startup import send_gdb, in_gdb_thread _program = None +@in_gdb_thread +def _set_args_env(args, env): + inf = gdb.selected_inferior() + inf.arguments = args + if env is not None: + inf.clear_env() + for name, value in env.items(): + inf.set_env(name, value) + + +# Any parameters here are necessarily extensions -- DAP requires this +# from implementations. Any additions or changes here should be +# documented in the gdb manual. @request("launch") -def launch(*, program=None, **args): +def launch(*, program=None, args=[], env=None, **extra): if program is not None: global _program _program = program send_gdb(f"file {_program}") + if len(args) > 0 or env is not None: + send_gdb(lambda: _set_args_env(args, env)) @capability("supportsConfigurationDoneRequest") |