summaryrefslogtreecommitdiff
path: root/cross-project-tests
diff options
context:
space:
mode:
authorStephen Tozer <Stephen.Tozer@Sony.com>2023-02-28 17:14:13 +0000
committerStephen Tozer <Stephen.Tozer@Sony.com>2023-03-15 17:11:30 +0000
commit2e7f3393896a476fc17aaf7f22072f30ac7ffe00 (patch)
treefd0d863a8c012e4e9e0529ddd31453fb922e3e3f /cross-project-tests
parentade336d6e14140134728b9991be8e4e68d6205ea (diff)
downloadllvm-2e7f3393896a476fc17aaf7f22072f30ac7ffe00.tar.gz
[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
Diffstat (limited to 'cross-project-tests')
-rw-r--r--cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py8
-rw-r--r--cross-project-tests/debuginfo-tests/dexter/dex/debugger/dbgeng/dbgeng.py2
-rw-r--r--cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py3
-rw-r--r--cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py2
-rw-r--r--cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/target_run_args.c15
-rw-r--r--cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/target_run_args_with_command.c16
6 files changed, 45 insertions, 1 deletions
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='<flags>',
+ 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'))