From fe576ada0f0d127b18f457a479a2992e509e60dc Mon Sep 17 00:00:00 2001 From: pompolic <pompolic@special-circumstanc.es> Date: Thu, 13 Apr 2023 16:17:39 +0200 Subject: [PATCH] (WIP) Stack event will now also hold a reference to the appropriate parser --- gdb-port/parser.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gdb-port/parser.py b/gdb-port/parser.py index a01669e..7db9afb 100644 --- a/gdb-port/parser.py +++ b/gdb-port/parser.py @@ -141,7 +141,7 @@ class ParserStack: #TODO: check that self.arena is same as gdb.selected_frame()'s arena self.bytes_at_enter.append(int(self.arena_gdbval['arena_malloc_bytes'])) self.cumulative_byte_differences = [] - self.stack_events.append((StackEvent.PUSH, int(self.arena_gdbval['arena_malloc_bytes']))) + self.stack_events.append((StackEvent.PUSH, int(self.arena_gdbval['arena_malloc_bytes']), parser)) prev = 0 if len(self.bytes_at_enter) > 1: prev = self.bytes_at_enter[-2] @@ -165,7 +165,7 @@ class ParserStack: #if self.extended_arena_stats_available(): # DEBUG #import code; code.interact(local=locals()) # DEBUG newbytes = int(self.parse_state_gdbval['arena']['arena_malloc_bytes']) - self.stack_events.append((StackEvent.POP, int(self.parse_state_gdbval['arena']['arena_malloc_bytes']))) + self.stack_events.append((StackEvent.POP, int(self.parse_state_gdbval['arena']['arena_malloc_bytes']), parser_obj)) # TODO: index expression with len() seems unnecessary self.cumulative_byte_differences.insert(0, newbytes - self.bytes_at_enter[-(len(self.cumulative_byte_differences)+1)]) # TODO: consistency. this is the third way of answering the question, "how deep are we in the stack" allocated_bytes = self.cumulative_byte_differences[-len(self.cumulative_byte_differences)] - self.cumulative_byte_differences[-(len(self.cumulative_byte_differences)-1)] # NB: len(self.cumulative_byte_differences) changed since the last line @@ -332,8 +332,14 @@ class ParserStack: # - the previous item on the list is a "pop" event. In this case self.stack_events[self.committed] == current_event (?) # - in this case we just need to add the difference in allocated bytes since that last "pop", to the parser we're about to pop off p_stack - def commit_pop(self, ev_list): - pass + def commit_pop(self): + current_event = self.stack_events[-1] + ev_list = self.stack_events[self.committed:] + # NOTE: Assumes that ParserStack.pop() pops p_stack after this function runs + current_parser = self.p_stack[-1] + print("commit_pop: ev_list:", ev_list) # DEBUG + print("commit_pop: parser:", parser) # DEBUG + def commit_pushes_at_end(self): pass -- GitLab