diff --git a/gdb-port/commands.py b/gdb-port/commands.py index bcfa0c7b3c38a37f7eda71c708f029160f4c718b..1c030ca60d79faeb05646ca713062fb947bb1aa0 100644 --- a/gdb-port/commands.py +++ b/gdb-port/commands.py @@ -222,9 +222,10 @@ class HammerParseApply(FlowControlWithPrint): print(":: hammer-parse-apply") def invoke(self, arg, from_tty): - #profiler = cProfile.Profile() # DEBUG - #profiler.enable() # DEBUG - with cProfile.Profile() as profiler: # DEBUG + ##profiler = cProfile.Profile() # DEBUG + ##profiler.enable() # DEBUG + #with cProfile.Profile() as profiler: # DEBUG + if True: 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 @@ -237,13 +238,13 @@ class HammerParseApply(FlowControlWithPrint): top_level_parse.clear_ast_stack_index() self.conditionally_print_backtrace() - profiler.print_stats(sort='tottime') # DEBUG - #profiler.disable() # DEBUG - #s = io.StringIO() # DEBUG - #sortby = SortKey.CUMULATIVE # DEBUG - #ps = pstats.Stats(pr, stream=s).sort_stats(sortby) # DEBUG - #ps.print_stats() # DEBUG - #print(s.getvalue()) # DEBUG + #profiler.print_stats(sort='tottime') # DEBUG + ##profiler.disable() # DEBUG + ##s = io.StringIO() # DEBUG + ##sortby = SortKey.CUMULATIVE # DEBUG + ##ps = pstats.Stats(pr, stream=s).sort_stats(sortby) # DEBUG + ##ps.print_stats() # DEBUG + ##print(s.getvalue()) # DEBUG HammerParseApply() @@ -253,9 +254,10 @@ class HammerParseApplyAndShowAST(FlowControlWithPrint): print(":: hammer-parse-apply-and-show-ast") def invoke(self, arg, from_tty): - #profiler = cProfile.Profile() # DEBUG - #profiler.enable() # DEBUG - with cProfile.Profile() as profiler: # DEBUG + ##profiler = cProfile.Profile() # DEBUG + ##profiler.enable() # DEBUG + #with cProfile.Profile() as profiler: # DEBUG + if True: 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 @@ -268,12 +270,12 @@ class HammerParseApplyAndShowAST(FlowControlWithPrint): top_level_parse.clear_ast_stack_index() self.conditionally_print_backtrace() - profiler.print_stats(sort='tottime') # DEBUG - #profiler.disable() # DEBUG - #s = io.StringIO() # DEBUG - #sortby = SortKey.CUMULATIVE # DEBUG - #ps = pstats.Stats(pr, stream=s).sort_stats(sortby) # DEBUG - #ps.print_stats() # DEBUG - #print(s.getvalue()) # DEBUG + #profiler.print_stats(sort='tottime') # DEBUG + ##profiler.disable() # DEBUG + ##s = io.StringIO() # DEBUG + ##sortby = SortKey.CUMULATIVE # DEBUG + ##ps = pstats.Stats(pr, stream=s).sort_stats(sortby) # DEBUG + ##ps.print_stats() # DEBUG + ##print(s.getvalue()) # DEBUG HammerParseApplyAndShowAST() diff --git a/gdb-port/hammer-breakpoints.py b/gdb-port/hammer-breakpoints.py index 2e26ae6a43125d69fb53282b584cb80b83a996eb..ba5d5d690509c3e9672a938bdfc38bc9af915ba8 100644 --- a/gdb-port/hammer-breakpoints.py +++ b/gdb-port/hammer-breakpoints.py @@ -96,7 +96,7 @@ 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'] - if top_level_parse.show_input_map_after_apply: + if top_level_parse.show_input_map_after_apply and ast_manager.top_node: 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