From f7c102c727bb21273ec4ac3b8c4d6c07ad71248f Mon Sep 17 00:00:00 2001
From: pompolic <pompolic@special-circumstanc.es>
Date: Tue, 25 Oct 2022 14:40:41 +0200
Subject: [PATCH] When a token spans chunk boundaries, print in both

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

diff --git a/gdb-port/top-level-parse.py b/gdb-port/top-level-parse.py
index b6f1f6f..ea60795 100644
--- a/gdb-port/top-level-parse.py
+++ b/gdb-port/top-level-parse.py
@@ -429,7 +429,15 @@ class TopLevelParse:
 				info_strings.append(" ".join([hpr.str_no_deref(), str(tokenmap_entry)]))
 			except:
 				info_strings.append(" ".join(["invalid", str(tokenmap_entry)]))
-			printing_index += 1
+			if tokenmap_entry['end'] > end:
+				print("carrying token to next chunk, current_token:", tokenmap_entry)
+				if printing_index+1 < len(token_list):
+					next_token = token_list[printing_index+1]
+					next_tokenmap_entry = self.input_token_map[int(next_token.address)]
+					print("next_token:", next_tokenmap_entry)
+				break
+			else:
+				printing_index += 1
 
 		self.printing_index = printing_index
 		info_dict = dict(enumerate(info_strings))
-- 
GitLab