From 8453b16a888b33820633b67a2c4108b387cac318 Mon Sep 17 00:00:00 2001 From: pompolic <pompolic@special-circumstanc.es> Date: Sat, 13 May 2023 22:12:01 +0200 Subject: [PATCH] (WIP) commit pending allocations when stopping at breakpoint --- gdb-port/top-level-parse.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gdb-port/top-level-parse.py b/gdb-port/top-level-parse.py index da6a1e0..ee40a1c 100644 --- a/gdb-port/top-level-parse.py +++ b/gdb-port/top-level-parse.py @@ -66,6 +66,11 @@ class TopLevelParse: self.parser_objs[parser] = parser_obj parser_stack = self.peek_parserstack() parser_stack.push(parser_obj, arena, stopping_at_bp) + if stopping_at_bp: + profiler.enable() + self.gather_all_allocations_in_parserstacks() + self.commit_pending_allocations(self.pending_allocations) + profiler.disable() parser_obj.increment_apply_count(int(arena)) if parser_stack.parse_state is None and parser_stack.parse_state != parse_state_int: self.first_h_do_parse_after_packrat_parse(parse_state_int, arena_int) @@ -277,8 +282,14 @@ class TopLevelParse: self.pending_allocs[ps.arena_int] = pending_allocs - # TODO: allocations are grouped by arena, then parser address. we get the arena address from the parser stack, which may be shared between parser stacks - # Therefore, it can't just be blindly assigned to a key with the arena's address. the two dicts need to be merged, with the values of duplicate entries added together - # However, the problem is that doing this naively would require two nested for loops minimum + # TODO: allocations are grouped by arena, then parser address. we get the arena address from the parser stack, which may be shared between parser stacks + # Therefore, it can't just be blindly assigned to a key with the arena's address. the two dicts need to be merged, with the values of duplicate entries added together + # However, the problem is that doing this naively would require two nested for loops minimum + # TODO: check if grouping { parser : { arena : alloc } } would work better + def commit_pending_allocations(self): + for arena, allocs in self.pending_allocs.items(): + for addr, alloc in allocs.items(): + parser_objs[addr].add_mem_use(arena, alloc) + self.pending_allocs = {} top_level_parse = TopLevelParse() -- GitLab