Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-5657: Some conditionals to avoid missing types in older gdb versions.

Dane4f12cc69168
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 1f97bd0cb9..890f3ca8ea 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
@@ -386,9 +386,10 @@ def on_new_objfile(event: gdb.NewObjFileEvent) -> None:
modules_changed()
-@log_errors
-def on_free_objfile(event: gdb.FreeObjFileEvent) -> None:
- modules_changed()
+if hasattr(gdb, 'FreeObjFileEvent'):
+ @log_errors
+ def on_free_objfile(event: gdb.FreeObjFileEvent) -> None:
+ modules_changed()
@log_errors
diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/util.py b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/util.py
index 84241ad310..0967fe0cd3 100644
--- a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/util.py
+++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/util.py
@@ -308,6 +308,11 @@ class BreakpointLocation:
thread_groups: List[int]
+# Quite a hack, but only needed for type annotations
+if not hasattr(gdb, 'BreakpointLocation'):
+ gdb.BreakpointLocation = BreakpointLocation
+
+
class BreakpointLocationInfoReader(object):
@abstractmethod
def get_locations(self, breakpoint: gdb.Breakpoint) -> List[Union[