diff --git a/gdb-port/commands.py b/gdb-port/commands.py index 84ab837dd9506dd375bc009bce544177c4245865..d65a2e34b7be1d48b99f58d3a95e3c0d51756d9f 100644 --- a/gdb-port/commands.py +++ b/gdb-port/commands.py @@ -1,3 +1,5 @@ +import cProfile, pstats, io # DEBUG + print(": Registering basic commands") class ExtendedParseStepInfo(gdb.Parameter): @@ -220,14 +222,24 @@ class HammerParseApply(FlowControlWithPrint): print(":: hammer-parse-apply") 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? - - # 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() - - self.conditionally_print_backtrace() + #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? + + # 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() + + self.conditionally_print_backtrace() + profiler.print_stats() # 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() diff --git a/gdb-port/top-level-parse.py b/gdb-port/top-level-parse.py index 96db1d349ee97b913c6cda44ec89d035a419ffb0..1134504bfd9c910bbd3f5b846c96c615a4721e25 100644 --- a/gdb-port/top-level-parse.py +++ b/gdb-port/top-level-parse.py @@ -1,3 +1,5 @@ +#import cProfile #DEBUG + class TopLevelParse: def __init__(self): self.parser_stacks = []