{"record":{"id":"9b1b630d19d197df","repo":"NationalSecurityAgency/ghidra","slug":"no-trace-active","errorCode":null,"errorMessage":"No trace active","messagePattern":"No trace active","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/commands.py","lineNumber":134,"sourceCode":"    def __init__(self) -> None:\n        self.reset_client()\n\n    def require_client(self) -> Client:\n        if self.client is None:\n            raise RuntimeError(\"Not connected\")\n        return self.client\n\n    def require_no_client(self) -> None:\n        if self.client != None:\n            raise RuntimeError(\"Already connected\")\n\n    def reset_client(self) -> None:\n        self.client: Optional[Client] = None\n        self.reset_trace()\n\n    def require_trace(self) -> Trace[Extra]:\n        if self.trace is None:\n            raise RuntimeError(\"No trace active\")\n        return self.trace\n\n    def require_no_trace(self) -> None:\n        if self.trace != None:\n            raise RuntimeError(\"Trace already started\")\n\n    def reset_trace(self) -> None:\n        self.trace: Optional[Trace[Extra]] = None\n        util.set_convenience_variable('_ghidra_tracing', \"false\")\n        self.reset_tx()\n\n    def require_tx(self) -> Tuple[Trace, Transaction]:\n        trace = self.require_trace()\n        if self.tx is None:\n            raise RuntimeError(\"No transaction\")\n        return trace, self.tx\n\n    def require_no_tx(self) -> None:","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/commands.py#L116-L152","documentation":"Thrown by State.require_trace() when no trace object is active — ghidra_trace_start has not been called or the trace was reset. Commands that operate on a trace (e.g., creating snapshots, recording memory/registers) require an active Trace[Extra] object. This RuntimeError indicates the trace lifecycle hasn't been initiated.","triggerScenarios":"STATE.require_trace() is called by trace-recording commands, but STATE.trace is None (from reset_trace or initial state). Happens when commands like ghidra_trace_putmem, ghidra_trace_tx_start are issued before ghidra_trace_start was called to create the trace.","commonSituations":"The user forgot to call ghidra_trace_start('path') before recording. The trace was reset via reset_trace() (which sets trace to None) and not re-established. Script execution skips the start step.","solutions":["Call ghidra_trace_start('trace_name') to create and activate a trace before recording commands.","Ensure the trace connector is connected first (ghidra_trace_connect) — starting a trace requires a client.","Check if reset_trace was called unexpectedly and re-start the trace.","In scripts, follow the lifecycle: connect > start trace > begin tx > record > end tx > stop trace > disconnect."],"exampleFix":"# Before: recording without an active trace\n# ghidra_trace_putmem(...)\n#\n# After: start trace first\n# ghidra_trace_connect('127.0.0.1:12345')\n# ghidra_trace_start('mytrace')\n# ghidra_trace_putmem(...)","handlingStrategy":"validation","validationCode":"# Before trace-recording commands, verify a trace is active:\nif STATE.trace is None:\n    ghidra_trace_connect('127.0.0.1:12345')\n    ghidra_trace_start('mytrace')\n# now safe to issue recording commands","typeGuard":"def has_active_trace(state) -> bool:\n    return state.trace is not None","tryCatchPattern":"try:\n    trace = STATE.require_trace()\nexcept RuntimeError as e:\n    if str(e) == 'No trace active':\n        ghidra_trace_start('mytrace')\n        trace = STATE.require_trace()\n    else:\n        raise","preventionTips":["Follow the trace lifecycle: connect > start trace > begin tx > record > end tx > stop > disconnect.","Always call ghidra_trace_start before recording commands.","Re-establish trace after reset_trace() calls.","In scripts, guard recording commands with trace existence checks."],"tags":["debugger-agent","trace","lifecycle","state-management","python"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}