From dab0208dbf09601129df4e83879f570f448872f8 Mon Sep 17 00:00:00 2001
From: pompolic <pompolic@special-circumstanc.es>
Date: Tue, 6 Dec 2022 09:52:06 +0100
Subject: [PATCH] Initialize cumulative_byte_differences anew when entering
 h_do_parse

Also typo fix in comment
---
 gdb-port/top-level-parse.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gdb-port/top-level-parse.py b/gdb-port/top-level-parse.py
index 4f2a141..a5ccd24 100644
--- a/gdb-port/top-level-parse.py
+++ b/gdb-port/top-level-parse.py
@@ -44,7 +44,8 @@ class TopLevelParse:
 		# TODO: invalidate previous memory stacks
 		# Originally meant to allow changing between different forms of gathering memory statistics.
 		# The only valid translation is BREAKPOINT -> DETAILED_ARENA_STATS
-		# If the HMallocRaw breakpoint is turned off, DETAILED_ARENA_STATS -> BREAKPOINT is no longer possible, since some allocations will have been missed
+		# If the HMallocRawBreakpoint is turned off, DETAILED_ARENA_STATS -> BREAKPOINT is no longer possible, since some allocations will have been missed
+		# TODO: if allocated tokens can be attributed to parsers retroactively from Hammer's stats, then future support for DETAILED_ARENA_STATS -> BREAKPOINT is possible
 		if not extended_arena_stats_available():
 			print("Can't use HArena statistics for memory: Hammer wasn't compiled with DETAILED_ARENA_STATS")
 		else:
@@ -66,6 +67,7 @@ class TopLevelParse:
 		#if self.memory_stat_method == HammerMemoryStatisticsMethod.DETAILED_ARENA_STATS
 		if self.extended_arena_stats_available(): # DEBUG
 			self.bytes_at_enter.append(arena['arena_malloc_bytes'])
+			self.cumulative_byte_differences = []
 
 		try:
 			parser_obj = self.parser_objs[parser]
-- 
GitLab