[PATCH] D144979: [Dexter] Add target_run_args option

Stephen Tozer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 28 09:40:01 PST 2023


StephenTozer created this revision.
StephenTozer added reviewers: jmorse, Orlando, CarlosAlbertoEnciso.
StephenTozer added a project: debug-info.
Herald added a project: All.
StephenTozer requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144979

Files:
  cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py
  cross-project-tests/debuginfo-tests/dexter/dex/debugger/dbgeng/dbgeng.py
  cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py
  cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py
  cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/target_run_args.c


Index: cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/target_run_args.c
===================================================================
--- /dev/null
+++ cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/target_run_args.c
@@ -0,0 +1,14 @@
+// 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'))
Index: cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py
===================================================================
--- cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py
+++ cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py
@@ -250,6 +250,8 @@
 
     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
Index: cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py
===================================================================
--- cross-project-tests/debuginfo-tests/dexter/dex/debugger/lldb/LLDB.py
+++ 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 @@
             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')
Index: cross-project-tests/debuginfo-tests/dexter/dex/debugger/dbgeng/dbgeng.py
===================================================================
--- cross-project-tests/debuginfo-tests/dexter/dex/debugger/dbgeng/dbgeng.py
+++ cross-project-tests/debuginfo-tests/dexter/dex/debugger/dbgeng/dbgeng.py
@@ -96,7 +96,7 @@
         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)
 
Index: cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py
===================================================================
--- cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py
+++ cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py
@@ -114,6 +114,14 @@
         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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144979.501189.patch
Type: text/x-patch
Size: 3845 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230228/c4395770/attachment.bin>


More information about the llvm-commits mailing list