From 0fbe6cf47f9893af482626aa6fb30ea68f0c30d3 Mon Sep 17 00:00:00 2001 From: Aaron Adams Date: Wed, 16 Aug 2023 17:54:14 +0800 Subject: [PATCH] add try except around search memory --- pwndbg/search.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pwndbg/search.py b/pwndbg/search.py index 6e314ef90..ce0f26e59 100644 --- a/pwndbg/search.py +++ b/pwndbg/search.py @@ -58,7 +58,21 @@ def search(searchfor, mappings=None, start=None, end=None, executable=False, wri if length <= 0: break - start = i.search_memory(start, length, searchfor) + try: + start = i.search_memory(start, length, searchfor) + except gdb.error as e: + # While remote debugging on an embedded device and searching + # through a large memory region (~512mb), gdb may return an error similar + # to `error: Invalid hex digit 116`, even though the search + # itself is ok. It seems to have to do with a timeout. + print(f"WARN: gdb.search_memory failed with: {e}") + if e.args[0].startswith("Invalid hex digit"): + print( + "WARN: This is possibly related to a timeout. Connection is likely broken." + ) + break + start = None + pass if start is None: break