From e65f384843481e194da1a07dc81df9fce78b5215 Mon Sep 17 00:00:00 2001 From: jackmisbach Date: Mon, 24 Nov 2025 19:24:32 -0600 Subject: [PATCH] Fix debugger-aware parsing for int arguments in subcommands (#3432) --- pwndbg/commands/__init__.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/pwndbg/commands/__init__.py b/pwndbg/commands/__init__.py index a0f7d0234..0437f3df7 100644 --- a/pwndbg/commands/__init__.py +++ b/pwndbg/commands/__init__.py @@ -228,15 +228,22 @@ class CommandObj: # We want to run all integer and otherwise-unspecified arguments # through fix() so that GDB parses it. # FIXME: this is weird - for action in self.parser._actions: - if isinstance(action, argparse._SubParsersAction): - action.type = str - if action.dest == "help": - continue - if action.type is int: - action.type = fix_int_reraise_arg - elif action.type is None: - action.type = fix_reraise_arg + def process_actions(actions): + """Recursively process actions, including subparsers""" + for action in actions: + if isinstance(action, argparse._SubParsersAction): + action.type = str + # Recursively process each subparser's actions + for subparser in action.choices.values(): + process_actions(subparser._actions) + if action.dest == "help": + continue + if action.type is int: + action.type = fix_int_reraise_arg + elif action.type is None: + action.type = fix_reraise_arg + + process_actions(self.parser._actions) assert ( self.parser.formatter_class is argparse.HelpFormatter