From 03c5d1b8239b20de1fc2a01e9134a3390f652dd7 Mon Sep 17 00:00:00 2001
From: pompolic <pompolic@special-circumstanc.es>
Date: Fri, 14 Apr 2023 22:24:31 +0200
Subject: [PATCH] Attempt to fix double counting allocations

---
 gdb-port/parser.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gdb-port/parser.py b/gdb-port/parser.py
index 1976a40..d0f2103 100644
--- a/gdb-port/parser.py
+++ b/gdb-port/parser.py
@@ -335,7 +335,7 @@ class ParserStack:
 
 	def commit_at_pop(self):
 		current_event = self.stack_events[-1]
-		ev_start = self.committed if self.committed > 0 else 0
+		ev_start = self.committed + 1
 		ev_list = self.stack_events[ev_start:]
 		# NOTE: Assumes that ParserStack.pop() pops p_stack after this function runs
 		current_parser = self.p_stack[-1]
@@ -355,9 +355,9 @@ class ParserStack:
 			assert ev_list[-1] == current_event # DEBUG
 			# Compare bytes allocated in arena to last known value, which will be the additional bytes allocated since reentering the stack frame
 			#alloc_size = self.stack_events[ev_start][1] - current_event[1]
-			current_event[0][2].add_mem_use(int(self.arena), current_frame_alloc)
+			current_event[2].add_mem_use(int(self.arena), current_frame_alloc)
 			self.committed = len(self.stack_events)-1
-			return { current_event[0][2].address: current_frame_alloc }
+			return { current_event[2].address: current_frame_alloc }
 		print("commit_at_pop: current_frame_alloc", current_frame_alloc) # DEBUG
 
 		# TODO: if len(ev_list) > 1
-- 
GitLab