summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOto Šťáva <oto.stava@nic.cz>2024-03-18 12:21:28 +0100
committerAleš Mrázek <ales.mrazek@nic.cz>2024-12-03 11:50:01 +0100
commit243b30c9dbdc1500706db029f88c6c1d3bed3e08 (patch)
treea975219f9a187e46206081033a4484ac099ccc41
parentkresctl debug: adjust defaults, documentation (diff)
downloadknot-resolver-243b30c9dbdc1500706db029f88c6c1d3bed3e08.tar.xz
knot-resolver-243b30c9dbdc1500706db029f88c6c1d3bed3e08.zip
kresctl debug: add --print-only and be silent by default
-rw-r--r--doc/user/manager-client.rst5
-rw-r--r--python/knot_resolver/client/commands/debug.py16
2 files changed, 18 insertions, 3 deletions
diff --git a/doc/user/manager-client.rst b/doc/user/manager-client.rst
index 03a2d9eb..7d43a07f 100644
--- a/doc/user/manager-client.rst
+++ b/doc/user/manager-client.rst
@@ -382,6 +382,11 @@ single ``kresctl`` command.
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:
diff --git a/python/knot_resolver/client/commands/debug.py b/python/knot_resolver/client/commands/debug.py
index cd12db50..5d9a81df 100644
--- a/python/knot_resolver/client/commands/debug.py
+++ b/python/knot_resolver/client/commands/debug.py
@@ -18,6 +18,7 @@ class DebugCommand(Command):
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)
@@ -41,6 +42,7 @@ class DebugCommand(Command):
dest="sudo",
help="Run GDB with sudo",
action="store_true",
+ default=False,
)
debug.add_argument(
"--gdb",
@@ -48,6 +50,12 @@ class DebugCommand(Command):
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
@@ -105,7 +113,7 @@ class DebugCommand(Command):
# 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"]}'])
@@ -130,5 +138,7 @@ class DebugCommand(Command):
)
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)