Use a custom GDB executable. This may be a command on ``PATH``, or an
absolute path to an executable.
+ .. option:: --print-only
+
+ Prints the GDB command line into ``stderr`` as a Python array, does not
+ execute GDB.
+
.. _manager-client-subprocess-types:
self.proc_type: Optional[str] = namespace.proc_type
self.sudo: bool = namespace.sudo
self.gdb: str = namespace.gdb
+ self.print_only: bool = namespace.print_only
self.gdb_args: List[str] = namespace.extra
super().__init__(namespace)
dest="sudo",
help="Run GDB with sudo",
action="store_true",
+ default=False,
)
debug.add_argument(
"--gdb",
type=str,
default=None,
)
+ debug.add_argument(
+ "--print-only",
+ help="Prints the GDB command line into stderr as a Python array, does not execute GDB",
+ action="store_true",
+ default=False,
+ )
return debug, DebugCommand
@staticmethod
# Attach GDB to processes - the processes are attached using the `add-inferior` and `attach` GDB
# commands. This way, we can debug multiple processes.
- exec_args.extend([gdb_cmd])
+ exec_args.extend([gdb_cmd, "--"])
exec_args.extend(["-init-eval-command", "set detach-on-fork off"])
exec_args.extend(["-init-eval-command", "set schedule-multiple on"])
exec_args.extend(["-init-eval-command", f'attach {procs[0]["pid"]}'])
)
exec_args.extend(self.gdb_args)
- print(f"exec_args = {exec_args}")
- os.execl(*exec_args)
+ if self.print_only:
+ print(f"{exec_args}")
+ else:
+ os.execl(*exec_args)