From dd72290f8d17c1ef24b85bd6b0ca7a99279d5f32 Mon Sep 17 00:00:00 2001 From: d-millar <33498836+d-millar@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:12:16 +0000 Subject: [PATCH 1/2] GP-4701: fix for MemoryError --- .../src/main/py/src/ghidragdb/hooks.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/hooks.py b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/hooks.py index 39377afdb9..a5447845e3 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/hooks.py +++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/hooks.py @@ -93,8 +93,14 @@ class InferiorState(object): if first or hashable_frame not in self.visited: commands.putreg( frame, util.get_register_descs(frame.architecture(), 'general')) - commands.putmem("$pc", "1", from_tty=False) - commands.putmem("$sp", "1", from_tty=False) + try: + commands.putmem("$pc", "1", from_tty=False) + except MemoryError as e: + print(f"Couldn't record page with PC: {e}") + try: + commands.putmem("$sp", "1", from_tty=False) + except MemoryError as e: + print(f"Couldn't record page with SP: {e}") self.visited.add(hashable_frame) if first or self.regions or self.threads or self.modules: # Sections, memory syscalls, or stack allocations From fcf4376222ea12ad551b21d4904566ba24657528 Mon Sep 17 00:00:00 2001 From: d-millar <33498836+d-millar@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:22:44 +0000 Subject: [PATCH 2/2] GP-4701: fix for MemoryError --- .../Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/hooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/hooks.py b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/hooks.py index a5447845e3..7f04b7784b 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/hooks.py +++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/hooks.py @@ -96,7 +96,7 @@ class InferiorState(object): try: commands.putmem("$pc", "1", from_tty=False) except MemoryError as e: - print(f"Couldn't record page with PC: {e}") + print(f"Couldn't record page with PC: {e}") try: commands.putmem("$sp", "1", from_tty=False) except MemoryError as e: