diff --git a/gdb-port/commands.py b/gdb-port/commands.py index 7474e1c7d21f8eb1e08a9fff8fc76ef32a9dc1ce..bcfa0c7b3c38a37f7eda71c708f029160f4c718b 100644 --- a/gdb-port/commands.py +++ b/gdb-port/commands.py @@ -225,13 +225,16 @@ class HammerParseApply(FlowControlWithPrint): #profiler = cProfile.Profile() # DEBUG #profiler.enable() # DEBUG with cProfile.Profile() as profiler: # DEBUG - #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? + 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? + showmap_old = top_level_parse.show_input_map_after_apply + top_level_parse.show_input_map_after_apply = False # 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") - #top_level_parse.clear_ast_stack_index() + top_level_parse.show_input_map_after_apply = showmap_old + top_level_parse.clear_ast_stack_index() self.conditionally_print_backtrace() profiler.print_stats(sort='tottime') # DEBUG @@ -254,11 +257,14 @@ class HammerParseApplyAndShowAST(FlowControlWithPrint): #profiler.enable() # DEBUG with cProfile.Profile() as profiler: # DEBUG 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? + showmap_old = top_level_parse.show_input_map_after_apply + top_level_parse.show_input_map_after_apply = True # 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") + top_level_parse.show_input_map_after_apply = showmap_old top_level_parse.clear_ast_stack_index() self.conditionally_print_backtrace() diff --git a/gdb-port/hammer-breakpoints.py b/gdb-port/hammer-breakpoints.py index d2ea3068c6661cda4da34f936021692eeb172584..32b923e0ebdc8fa285bb59984f787870849450fc 100644 --- a/gdb-port/hammer-breakpoints.py +++ b/gdb-port/hammer-breakpoints.py @@ -101,7 +101,8 @@ class HDoParseRetBreakpoint(gdb.Breakpoint): ast_manager.print_ast() #print(top_level_parse.peek_parserstack().p_stack) #TODO:sometimes the hammer-parser-backtrace gets messed up top_level_parse.input_ptr = parse_state['input_stream']['input'] - top_level_parse.print_input_map(ast_manager.top_node.ast) + if top_level_parse.show_input_map_after_apply: + top_level_parse.print_input_map(ast_manager.top_node.ast) #print(top_level_parse.peek_parserstack().p_stack) # Do not stop at this breakpoint, but stop at the next HDoParseBreakpoint gdb.set_convenience_variable("hammer_step_counter", 1) diff --git a/gdb-port/top-level-parse.py b/gdb-port/top-level-parse.py index eaeff8200896f60b5f3cf00a8e04051a9d510315..ff2626557c2631ffa33d4c19273b417c4c4f5e4f 100644 --- a/gdb-port/top-level-parse.py +++ b/gdb-port/top-level-parse.py @@ -8,6 +8,7 @@ class TopLevelParse: self.current_parse_depth = 0 # Used by the AST handling code. self.starting_input_index = [] self.input_token_map = {} + self.show_input_map_after_apply = False self.input_ptr = None # Technically, 1 virtual parse function + 1 h_do_parse + 1 perform_lowlevel_parse (if packrat) # TODO: len(self.parser_stacks[-1]) and self.current_parse_depth serve the same purpose. avoid multiple sources of truth