diff --git a/gdb-port/commands.py b/gdb-port/commands.py index a11b0ffa990495ef68140c7ab471f497378dd49a..8d906f25ffd7c9e2bac52f4459fc6b7a7d32ded0 100644 --- a/gdb-port/commands.py +++ b/gdb-port/commands.py @@ -191,13 +191,10 @@ class HammerParseStepToResult(FlowControlWithPrint): 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) - # Stop at next HDoParseRetBreakpoint + # HDoParseRetBreakpoint sets hammer_step_counter to 1 after capturing the AST subtree, so this will stop at the first h_do_parse invocation afterwards if gdb.selected_inferior().pid > 0: gdb.execute("continue") - if gdb.selected_inferior().pid > 0: - gdb.set_convenience_variable("hammer_step_counter", 1) - # Continue and stop at the next h_do_parse invocation - gdb.execute("continue") + self.conditionally_print_backtrace() HammerParseStepToResult() @@ -222,16 +219,11 @@ class HammerParseApply(FlowControlWithPrint): def invoke(self, arg, from_tty): top_level_parse.setup_ast_stack_index(0) #TODO: is it a problem if this command overwrites it? would it better to use a convenience variable, as with parse-step? - # TODO: can this result in a state where we stop due to hammer_step_counter being set, before the parser is applied? - # TODO: Would it be better to just never allow stopping at the RET breakpoint? - # Stop at next HDoParseRetBreakpoint + # HDoParseRetBreakpoint sets hammer_step_counter to 1 after capturing the AST subtree, so this will stop at the first h_do_parse invocation afterwards if gdb.selected_inferior().pid > 0: gdb.execute("continue") - if gdb.selected_inferior().pid > 0: - gdb.set_convenience_variable("hammer_step_counter", 1) - # Continue and stop at the next h_do_parse invocation - gdb.execute("continue") + self.conditionally_print_backtrace() HammerParseApply() diff --git a/gdb-port/hammer-breakpoints.py b/gdb-port/hammer-breakpoints.py index c78dd29ca139478e419212ae67aff7130f14e6b6..971b179d0ca19398c0268be158f1b39ed3e6f01a 100644 --- a/gdb-port/hammer-breakpoints.py +++ b/gdb-port/hammer-breakpoints.py @@ -63,7 +63,6 @@ class HDoParseBreakpoint(gdb.Breakpoint): class HDoParseRetBreakpoint(gdb.Breakpoint): def stop(self): - # TODO: Check for ast command frame = gdb.selected_frame() block = frame.block() # Updated GDB, now this works @@ -88,12 +87,14 @@ class HDoParseRetBreakpoint(gdb.Breakpoint): top_level_parse.return_from_h_do_parse(parse_state, parser, ret_val) # Checking want_result_of() here avoids instantiating a HParseResult every time h_do_parse returns - stop = top_level_parse.want_result_of(parser) - if stop: + want_ast = top_level_parse.want_result_of(parser) + if want_ast: parser_obj = top_level_parse.parser_by_address(parser) ast_manager.set_top_node(ret_val, parser_obj) ast_manager.print_ast() - return True + # Do not stop at this breakpoint, but stop at the next HDoParseBreakpoint + gdb.set_convenience_variable("hammer_step_counter", 1) + return False class PerformLowLevelParseBreakpoint(gdb.Breakpoint):