From f01da1e93ff72600a821a3449fa0bacc347754d3 Mon Sep 17 00:00:00 2001
From: pompolic <pompolic@special-circumstanc.es>
Date: Tue, 31 Jan 2023 17:04:16 +0100
Subject: [PATCH] Add some debug statements

---
 gdb-port/top-level-parse.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gdb-port/top-level-parse.py b/gdb-port/top-level-parse.py
index 1976dfd..90ad642 100644
--- a/gdb-port/top-level-parse.py
+++ b/gdb-port/top-level-parse.py
@@ -18,6 +18,7 @@ class TopLevelParse:
 		self.h_do_parse_parser = None
 		self.vt_types = None
 		self.parser_decombinator = None
+		self.debug_stop # DEBUG
 
 		# If available, extracting the allocated bytes at h_do_parse entry/exit
 		# TODO: doing it at h_do_parse gets a list of cumulative allocation sizes
@@ -96,6 +97,7 @@ class TopLevelParse:
 			self.cumulative_byte_differences.insert(0, newbytes - self.bytes_at_enter[-(len(self.cumulative_byte_differences)+1)]) # TODO: consistency. this is the third way of answering the question, "how deep are we in the stack"
 			allocated_bytes = self.cumulative_byte_differences[-len(self.cumulative_byte_differences)] - self.cumulative_byte_differences[-(len(self.cumulative_byte_differences)-1)]  # NB: len(self.cumulative_byte_differences) changed since the last line
 			self.total_byte_differences.insert(-len(self.cumulative_byte_differences), allocated_bytes)
+			#print("adding mem use: parser:", str(parser_obj), "arena:", int(parser_stack.arena), "bytes:", allocated_bytes) # DEBUG
 			parser_obj.add_mem_use(int(parser_stack.arena), allocated_bytes)
 			# TODO: allocations can be attributed to individual h_do_parse(parser) calls, thus the same per-parser per-arena stats tracking can be done
 
@@ -142,6 +144,8 @@ class TopLevelParse:
 		# This is probably the slowest part of the code, or maybe the overhead adds up over many calls to h_arena_malloc_raw()
 		if parser_obj is not None:
 			# Caveat: parser_stack is assumed not to be None if we could get a parser_obj
+			if parser_obj.name == "ws":
+				print("breakpoint is adding", alloc_size, "bytes to ws") # DEBUG
 			parser_obj.add_mem_use(int(parser_stack.arena), alloc_size)
 		elif parser_stack is not None:
 			#print("Allocation of " + str(alloc_size) + " bytes without a parser on the stack. (Happens before first call perform_lowlevel_parse to or after return from that call)")
-- 
GitLab