From 01d77c6d2763ff83c5b871fbb5bad75a2c491dc9 Mon Sep 17 00:00:00 2001 From: pompolic <pompolic@special-circumstanc.es> Date: Mon, 11 Jul 2022 22:52:40 +0200 Subject: [PATCH] Fix exception when no argument is given to hammer-parse-step-to-result --- gdb-port/commands.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gdb-port/commands.py b/gdb-port/commands.py index 90502da..17f6cc7 100644 --- a/gdb-port/commands.py +++ b/gdb-port/commands.py @@ -181,14 +181,14 @@ class HammerParseStepToResult(FlowControlWithPrint): def invoke(self, arg, from_tty): args = gdb.string_to_argv(arg) - index = -1 + index = 0 if len(args) < 1: print("No argument given. Execution will be stopped after the current parser being applied returns its result.") - - try: - index = int(args[0]) - except ValueError: - print("Argument needs to be an integer. Execution will be stopped after the current parser being applied returns its result.") + else: + try: + index = int(args[0]) + except ValueError: + print("Argument needs to be an integer. Execution will be stopped after the current parser being applied returns its result.") top_level_parse.setup_ast_stack_index(index) # HDoParseRetBreakpoint sets hammer_step_counter to 1 after capturing the AST subtree, so this will stop at the first h_do_parse invocation afterwards -- GitLab