From a37dc8a8462b2f7ae30a0226581ec29b2cf5b633 Mon Sep 17 00:00:00 2001 From: pompolic <pompolic@special-circumstanc.es> Date: Fri, 7 Apr 2023 20:53:24 +0200 Subject: [PATCH] More comments --- gdb-port/parser.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gdb-port/parser.py b/gdb-port/parser.py index 3fca7d7..7eaff97 100644 --- a/gdb-port/parser.py +++ b/gdb-port/parser.py @@ -275,13 +275,19 @@ class ParserStack: print("push_allocations:", push_allocations) # DEBUG print("push_allocations_with_names:", {parser.name: pushes[index+1][1]-pushes[index][1] for index, parser in enumerate(parsers)}) # DEBUG # TODO: looks like it needs to account for the case where top of stack is a string of pushes, but there are runs of pushes without corresponding pops (yet?) deeper in the stack - # TODO: seems this is possible, but check if it really is: - #print("all stack events:", self.stack_events) # DEBUG + print("top 30 stack events:", [ev[0] for ev in self.stack_events[-30:]]) # DEBUG #for index, ev in enumerate(self.stack_events[::-1]): # if ev[0] == StackEvent.POP: # last_pop = index + # The list of stack events is split up into two kinds of "runs", runs of "push" events which don't have a corresponding "pop" yet + # And runs of push/pop events which are assumed to be balanced + # These latter can be straightforwardly accounted for by recursively removing the "outer" frame corresponding to a push/pop pair + # "push" events are trickier, because to get the allocations, they need to be compared to the *next* time hammer memory stats were sampled, be it push or pop + + # TODO: perhaps a "pop" should act as a checkpoint, and commit every allocation up to that point + def calculate_and_clear_pushes_at_end(self): # Throws StopIteration if no more items in the iterator match the condition last_pop = next((index for index,ev in enumerate(self.stack_events[::-1]) if ev[0] == StackEvent.POP), None) -- GitLab