Skip to content
Snippets Groups Projects
Commit c7fda1ae authored by pompolic's avatar pompolic
Browse files

Printing cleanup

parent 77405206
No related branches found
No related tags found
No related merge requests found
...@@ -222,9 +222,10 @@ class HammerParseApply(FlowControlWithPrint): ...@@ -222,9 +222,10 @@ class HammerParseApply(FlowControlWithPrint):
print(":: hammer-parse-apply") print(":: hammer-parse-apply")
def invoke(self, arg, from_tty): def invoke(self, arg, from_tty):
#profiler = cProfile.Profile() # DEBUG ##profiler = cProfile.Profile() # DEBUG
#profiler.enable() # DEBUG ##profiler.enable() # DEBUG
with cProfile.Profile() as profiler: # 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? 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 showmap_old = top_level_parse.show_input_map_after_apply
top_level_parse.show_input_map_after_apply = False top_level_parse.show_input_map_after_apply = False
...@@ -237,13 +238,13 @@ class HammerParseApply(FlowControlWithPrint): ...@@ -237,13 +238,13 @@ class HammerParseApply(FlowControlWithPrint):
top_level_parse.clear_ast_stack_index() top_level_parse.clear_ast_stack_index()
self.conditionally_print_backtrace() self.conditionally_print_backtrace()
profiler.print_stats(sort='tottime') # DEBUG #profiler.print_stats(sort='tottime') # DEBUG
#profiler.disable() # DEBUG ##profiler.disable() # DEBUG
#s = io.StringIO() # DEBUG ##s = io.StringIO() # DEBUG
#sortby = SortKey.CUMULATIVE # DEBUG ##sortby = SortKey.CUMULATIVE # DEBUG
#ps = pstats.Stats(pr, stream=s).sort_stats(sortby) # DEBUG ##ps = pstats.Stats(pr, stream=s).sort_stats(sortby) # DEBUG
#ps.print_stats() # DEBUG ##ps.print_stats() # DEBUG
#print(s.getvalue()) # DEBUG ##print(s.getvalue()) # DEBUG
HammerParseApply() HammerParseApply()
...@@ -253,9 +254,10 @@ class HammerParseApplyAndShowAST(FlowControlWithPrint): ...@@ -253,9 +254,10 @@ class HammerParseApplyAndShowAST(FlowControlWithPrint):
print(":: hammer-parse-apply-and-show-ast") print(":: hammer-parse-apply-and-show-ast")
def invoke(self, arg, from_tty): def invoke(self, arg, from_tty):
#profiler = cProfile.Profile() # DEBUG ##profiler = cProfile.Profile() # DEBUG
#profiler.enable() # DEBUG ##profiler.enable() # DEBUG
with cProfile.Profile() as profiler: # 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? 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 showmap_old = top_level_parse.show_input_map_after_apply
top_level_parse.show_input_map_after_apply = True top_level_parse.show_input_map_after_apply = True
...@@ -268,12 +270,12 @@ class HammerParseApplyAndShowAST(FlowControlWithPrint): ...@@ -268,12 +270,12 @@ class HammerParseApplyAndShowAST(FlowControlWithPrint):
top_level_parse.clear_ast_stack_index() top_level_parse.clear_ast_stack_index()
self.conditionally_print_backtrace() self.conditionally_print_backtrace()
profiler.print_stats(sort='tottime') # DEBUG #profiler.print_stats(sort='tottime') # DEBUG
#profiler.disable() # DEBUG ##profiler.disable() # DEBUG
#s = io.StringIO() # DEBUG ##s = io.StringIO() # DEBUG
#sortby = SortKey.CUMULATIVE # DEBUG ##sortby = SortKey.CUMULATIVE # DEBUG
#ps = pstats.Stats(pr, stream=s).sort_stats(sortby) # DEBUG ##ps = pstats.Stats(pr, stream=s).sort_stats(sortby) # DEBUG
#ps.print_stats() # DEBUG ##ps.print_stats() # DEBUG
#print(s.getvalue()) # DEBUG ##print(s.getvalue()) # DEBUG
HammerParseApplyAndShowAST() HammerParseApplyAndShowAST()
...@@ -96,7 +96,7 @@ class HDoParseRetBreakpoint(gdb.Breakpoint): ...@@ -96,7 +96,7 @@ class HDoParseRetBreakpoint(gdb.Breakpoint):
ast_manager.print_ast() ast_manager.print_ast()
#print(top_level_parse.peek_parserstack().p_stack) #TODO:sometimes the hammer-parser-backtrace gets messed up #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.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) top_level_parse.print_input_map(ast_manager.top_node.ast)
#print(top_level_parse.peek_parserstack().p_stack) #print(top_level_parse.peek_parserstack().p_stack)
# Do not stop at this breakpoint, but stop at the next HDoParseBreakpoint # Do not stop at this breakpoint, but stop at the next HDoParseBreakpoint
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment