From 28c5370f7fd88c2f5a1ac8779dbfffcae3572d05 Mon Sep 17 00:00:00 2001
From: pompolic <pompolic@special-circumstanc.es>
Date: Tue, 8 Feb 2022 20:07:53 +0100
Subject: [PATCH] Attempted fix for not finding function RETs

Increased the range of instructions a RET is searched for.
TODO: more robust error handling, see if there's a way to search up to a function's end via the GDB API
---
 gdb-port/parser-name-instrumentation-gdb.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gdb-port/parser-name-instrumentation-gdb.py b/gdb-port/parser-name-instrumentation-gdb.py
index 54bb57e..fcfe690 100644
--- a/gdb-port/parser-name-instrumentation-gdb.py
+++ b/gdb-port/parser-name-instrumentation-gdb.py
@@ -653,8 +653,8 @@ def locate_perform_lowlevel_parse_retq():
 	arch = gdb.selected_frame().architecture()
 	p_l_p_sym = gdb.lookup_symbol("perform_lowlevel_parse")[0]
 	p_l_p_address = int(p_l_p_sym.value().address)
-	# The choice of disassembling only 400 instructions from the start is arbitrary. (This function is 310 bytes long on this particular machine.) There is probably a way to find out where a function ends.
-	instructions = arch.disassemble(p_l_p_address, p_l_p_address+400)
+	# The choice of disassembling only 800 instructions from the start is arbitrary. (This function is 310 bytes long on this particular machine.) There is probably a way to find out where a function ends.
+	instructions = arch.disassemble(p_l_p_address, p_l_p_address+800)
 	results = [ ins["addr"] for ins in instructions if ins["asm"].startswith("ret") ]
 	return results[0]
 
@@ -662,8 +662,8 @@ def locate_h_packrat_parse_retq():
 	arch = gdb.selected_frame().architecture()
 	h_p_p_sym = gdb.lookup_symbol("h_packrat_parse")[0]
 	h_p_p_address = int(h_p_p_sym.value().address)
-	# Same as with perform_lowlevel_parse, +450 is arbitrary
-	instructions = arch.disassemble(h_p_p_address, h_p_p_address+450)
+	# Same as with perform_lowlevel_parse, +900 is arbitrary
+	instructions = arch.disassemble(h_p_p_address, h_p_p_address+900)
 	results = [ ins["addr"] for ins in instructions if ins["asm"].startswith("ret") ]
 	return results[0]
 
-- 
GitLab