diff --git a/gdb-port/parser.py b/gdb-port/parser.py
index 855646b80c1ba2f8322994538fc066652bd9e7c0..8311a3f9e52cb7c1fcf402203b34bffab7a679a5 100644
--- a/gdb-port/parser.py
+++ b/gdb-port/parser.py
@@ -220,3 +220,19 @@ class ParserStack:
 
 	def depth(self):
 		return len(self.p_stack)
+
+	def compute_parserstack_frame_allocs(self):
+		stack_depth = 0
+		stack_events = None
+		for index, ev in enumerate(self.stack_events[::-1]):
+			# Since this is meant to be called from ParserStack.pop(), the assumption here is that the first element will be a StackEvent.POP
+			# So we can stop gathering memory allocations at the point stack_depth becomes 0 again: that'll be the point in the list,
+			# where the parser we just popped from the stack had been pushed on it. Allocations prior to that are not relevant and are not considered
+			if ev[0] == StackEvent.POP:
+				stack_depth += 1
+			elif ev[0] == StackEvent.PUSH:
+				stack_depth -= 1
+				if stack_depth == 0:
+					stack_events = self.stack_events[-index:]
+					print(stack_events)
+					break