diff --git a/Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/commands.py b/Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/commands.py index 2b61ad3d80..b83a6cfe11 100644 --- a/Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/commands.py +++ b/Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/commands.py @@ -267,10 +267,10 @@ def ghidra_trace_create(start_trace: bool = True) -> None: global prog prog = Program() kind = os.getenv('OPT_TARGET_KIND') + img = os.getenv('OPT_TARGET_IMG') if kind == "kernel": prog.set_kernel() elif kind == "coredump": - img = os.getenv('OPT_TARGET_IMG') if img is not None: prog.set_core_dump(img) if '/' in img: @@ -287,14 +287,15 @@ def ghidra_trace_create(start_trace: bool = True) -> None: except drgn.MissingDebugInfoError as e: print(e) - if kind == "kernel": - img = prog.main_module().name # type: ignore - util.selected_tid = next(prog.threads()).tid - elif kind == "coredump": - util.selected_tid = prog.crashed_thread().tid - else: - img = prog.main_module().name # type: ignore - util.selected_tid = prog.main_thread().tid + if hasattr(drgn, 'Module') or kind == "coredump": + if kind == "kernel": + img = prog.main_module().name # type: ignore + util.selected_tid = next(prog.threads()).tid + elif kind == "coredump": + util.selected_tid = prog.crashed_thread().tid + else: + img = prog.main_module().name # type: ignore + util.selected_tid = prog.main_thread().tid if start_trace and img is not None: ghidra_trace_start(img) diff --git a/Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/methods.py b/Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/methods.py index d228e8c673..68f50a4cc2 100644 --- a/Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/methods.py +++ b/Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/methods.py @@ -23,7 +23,12 @@ from typing import Annotated, Any, Dict, Optional, Tuple import drgn import drgn.cli -from drgn import Module, StackFrame # type: ignore +from drgn import StackFrame +try: + from drgn import Module # type: ignore +except Exception as e: + class Module: + pass # not supported on older versions from ghidratrace import sch from ghidratrace.client import ( diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py index ae54f03878..ca89c0b63b 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py +++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py @@ -628,8 +628,6 @@ def putreg(frame: gdb.Frame, reg_descs: Sequence[ cobj.insert() mapper = trace.extra.require_rm() - gdb.write(f"---Register Mapper: {mapper}---\n") - keys = [] values = [] # NB: This command will fail if the process is running