NationalSecurityAgency/ghidra · error · RuntimeError

No trace active

Error message

No trace active

What it means

Raised by State.require_trace in the Ghidra LLDB agent when STATE.trace is None — i.e. no trace has been started on the current connection. Commands that emit objects/snapshots/transactions (the bulk of commands.py) call require_trace; without a Trace they cannot proceed. RuntimeError signals a lifecycle precondition: 'start_trace' (create_trace + assignment at commands.py:373) must precede trace-emitting commands.

Source

Thrown at Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py:111

    def __init__(self) -> None:
        self.reset_client()

    def require_client(self) -> Client:
        if self.client is None:
            raise RuntimeError("Not connected")
        return self.client

    def require_no_client(self) -> None:
        if self.client is not None:
            raise RuntimeError("Already connected")

    def reset_client(self) -> None:
        self.client: Optional[Client] = None
        self.reset_trace()

    def require_trace(self) -> Trace[Extra]:
        if self.trace is None:
            raise RuntimeError("No trace active")
        return self.trace

    def require_no_trace(self) -> None:
        if self.trace is not None:
            raise RuntimeError("Trace already started")

    def reset_trace(self) -> None:
        self.trace: Optional[Trace[Extra]] = None
        util.set_convenience_variable('_ghidra_tracing', "false")
        self.reset_tx()

    def require_tx(self) -> Tuple[Trace[Extra], Transaction]:
        trace = self.require_trace()
        if self.tx is None:
            raise RuntimeError("No transaction")
        return trace, self.tx

    def require_no_tx(self) -> None:

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Run the start-trace command (ghidra_trace_start) after connecting and before any record/put command.
  2. In scripts, assert STATE.trace is not None before emitting.
  3. Catch RuntimeError and hint 'no trace active; run ghidra_trace_start'.
  4. Ensure the start command completed (create_trace succeeded) before issuing record commands.

Example fix

// before
trace = STATE.require_trace()
// after
if STATE.trace is None:
    print("No trace active. Run: ghidra_trace_start <description>")
    return
trace = STATE.require_trace()
Defensive patterns

Strategy: validation

Validate before calling

if STATE.trace is None:
    print("No trace active. Run: ghidra_trace_start <description>")
    return
trace = STATE.require_trace()

Type guard

def trace_active() -> bool:
    return STATE.trace is not None

Try / catch

try:
    trace = STATE.require_trace()
except RuntimeError:
    print("No trace active; run ghidra_trace_start first")
    return

Prevention

When it happens

Trigger: Running a trace-emitting command (put, mem, regs, snapshot, tx, etc.) before 'ghidra_trace_start' created a trace. Reached by ~all commands that build the trace tree.

Common situations: User issued put/record commands before 'ghidra_trace_start'; trace was closed (STATE.trace set to None) and user continued; script that records without starting.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/6bc308850d62117a. Report an issue: GitHub.