diff --git a/gdb-port/parser.py b/gdb-port/parser.py index 515018b211b0950490c1c4584598377208ffab06..db745d89b25d4bafedbd7ae2ee32111a0bff7b0f 100644 --- a/gdb-port/parser.py +++ b/gdb-port/parser.py @@ -255,3 +255,15 @@ class ParserStack: #return (stack_slice[-1][1] - stack_slice[0][1]) - self.compute_outer_frame(new_slice) # alternatively: return (stack_slice[-1][1] - stack_slice[-2][1]) + (stack_slice[1][1] - stack_slice[0][1]) + + def compute_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) + if last_pop is None: + # No "pop" events in the list, stack_events is all pushes + # Subtract the bytes allocated before the first push happened, from the bytes allocated by the most recent h_do_parse() + return self.stack_events[0][1] - self.stack_events[-1][1] + + #for index, ev in enumerate(self.stack_events[::-1]): + # if ev[0] == StackEvent.POP: + # last_pop = index