diff --git a/gdb-port/parser.py b/gdb-port/parser.py index 3fca7d73c1697441006c6bf5a58ffe25ef85ac76..7eaff974e6f926f8d7ff70dbd01bbf69cc56d3c3 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)