From 2e7f3393896a476fc17aaf7f22072f30ac7ffe00 Mon Sep 17 00:00:00 2001 From: Stephen Tozer Date: Tue, 28 Feb 2023 17:14:13 +0000 Subject: [Dexter] Add target_run_args option Adds an option to Dexter that passes command line arguments to the debugged process, following (and in addition to) any arguments given by the DexCommandLine command. Differential Revision: https://reviews.llvm.org/D144979 --- .../debuginfo-tests/dexter/dex/debugger/Debuggers.py | 8 ++++++++ .../debuginfo-tests/dexter/dex/debugger/dbgeng/dbgeng.py | 2 +- .../debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py | 3 +++ .../dexter/dex/debugger/visualstudio/VisualStudio.py | 2 ++ .../dexter/feature_tests/subtools/test/target_run_args.c | 15 +++++++++++++++ .../subtools/test/target_run_args_with_command.c | 16 ++++++++++++++++ 6 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/target_run_args.c create mode 100644 cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/target_run_args_with_command.c (limited to 'cross-project-tests') diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py index fbfa629faf8b..be48e7c95e5a 100644 --- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py +++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py @@ -114,6 +114,14 @@ def add_debugger_tool_arguments(parser, context, defaults): action='store_true', default=False, help='pass the debugger paths relative to --source-root-dir') + parser.add_argument( + '--target-run-args', + type=str, + metavar='', + default='', + help='command line arguments for the test program, in addition to any ' + 'provided by DexCommandLine') + def handle_debugger_tool_base_options(context, defaults): # noqa options = context.options diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/dbgeng/dbgeng.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/dbgeng/dbgeng.py index c89920d5cd86..8e015669b732 100644 --- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/dbgeng/dbgeng.py +++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/dbgeng/dbgeng.py @@ -96,7 +96,7 @@ class DbgEng(DebuggerBase): raise NotImplementedError('delete_conditional_breakpoint is not yet implemented by dbgeng') def launch(self, cmdline): - assert len(cmdline) == 0, "Command lines unimplemented for dbgeng right now" + assert len(cmdline) == 0 and not self.context.options.target_run_args, "Command lines unimplemented for dbgeng right now" # We are, by this point, already launched. self.step_info = probe_process.probe_state(self.client) diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py index 703f9c4744c2..4ab693c6d181 100644 --- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py +++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py @@ -9,6 +9,7 @@ import imp import os +import shlex from subprocess import CalledProcessError, check_output, STDOUT import sys @@ -171,6 +172,8 @@ class LLDB(DebuggerBase): self._target.BreakpointDelete(id) def launch(self, cmdline): + if self.context.options.target_run_args: + cmdline += shlex.split(self.context.options.target_run_args) self._process = self._target.LaunchSimple(cmdline, None, os.getcwd()) if not self._process or self._process.GetNumThreads() == 0: raise DebuggerException('could not launch process') diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py index 281d5f58ec15..4ce0142513b6 100644 --- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py +++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py @@ -250,6 +250,8 @@ class VisualStudio(DebuggerBase, metaclass=abc.ABCMeta): # pylint: disable=abst def launch(self, cmdline): cmdline_str = ' '.join(cmdline) + if self.context.options.target_run_args: + cmdline_str += f" {self.context.options.target_run_args}" # In a slightly baroque manner, lookup the VS project that runs when # you click "run", and set its command line options to the desired diff --git a/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/target_run_args.c b/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/target_run_args.c new file mode 100644 index 000000000000..11004adce912 --- /dev/null +++ b/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/target_run_args.c @@ -0,0 +1,15 @@ +// The dbgeng driver doesn't support --target-run-args yet. +// UNSUPPORTED: system-windows +// +// RUN: %dexter_regression_test --target-run-args "a b 'c d'" -- %s | FileCheck %s +// CHECK: target_run_args.c: + +int main(int argc, const char **argv) { + if (argc == 4) + return 0; // DexLabel('retline') + + return 1; // DexUnreachable() +} + +// DexExpectWatchValue('argc', '4', on_line=ref('retline')) +// DexExpectWatchValue('argv[1][0]', "'a'", on_line=ref('retline')) diff --git a/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/target_run_args_with_command.c b/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/target_run_args_with_command.c new file mode 100644 index 000000000000..f329cb9d71c5 --- /dev/null +++ b/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/target_run_args_with_command.c @@ -0,0 +1,16 @@ +// The dbgeng driver doesn't support --target-run-args yet. +// UNSUPPORTED: system-windows +// +// RUN: %dexter_regression_test --target-run-args "a b 'c d'" -- %s | FileCheck %s +// CHECK: target_run_args_with_command.c: + +int main(int argc, const char **argv) { + if (argc == 6) + return 0; // DexLabel('retline') + + return 1; // DexUnreachable() +} + +// DexCommandLine(['e', 'f']) +// DexExpectWatchValue('argc', '6', on_line=ref('retline')) +// DexExpectWatchValue('argv[1][0]', "'e'", on_line=ref('retline')) -- cgit v1.2.1