{"record":{"id":"07ba4e73f984b121","repo":"NationalSecurityAgency/ghidra","slug":"not-connected-07ba4e","errorCode":null,"errorMessage":"Not connected","messagePattern":"Not connected","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py","lineNumber":98,"sourceCode":"    def require_mm(self) -> arch.DefaultMemoryMapper:\n        if self.memory_mapper is None:\n            raise RuntimeError(\"No memory mapper\")\n        return self.memory_mapper\n\n    def require_rm(self) -> arch.DefaultRegisterMapper:\n        if self.register_mapper is None:\n            raise RuntimeError(\"No register mapper\")\n        return self.register_mapper\n\n\nclass State(object):\n\n    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 is not 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 is not None:\n            raise RuntimeError(\"Trace already started\")","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py#L80-L116","documentation":"Raised by State.require_client in the Ghidra LLDB agent when STATE.client is None — i.e. no connection to the Ghidra trace-rpc server has been established. Commands that need to send trace data to Ghidra (create_trace, putmem, etc.) call require_client; without a Client the operation cannot proceed. RuntimeError signals a lifecycle precondition: 'connect' must precede any client-using command.","triggerScenarios":"Running a trace/command that calls STATE.require_client() before the agent connected to Ghidra (e.g. 'ghidra_trace' commands issued before 'ghidra_trace_connect' <host:port>). Reached by ~the majority of commands.py that touch the server.","commonSituations":"User issued trace commands out of order (forgot 'connect'); connection dropped and client was reset (reset_client) but user continued issuing commands; script that begins tracing without first connecting.","solutions":["Run the connect command first (ghidra_trace_connect host:port) before any trace-emitting command.","In scripts, guard with a connection check (STATE.client is not None) before issuing commands.","Catch RuntimeError in command wrappers and print a 'not connected; run ghidra_trace_connect' hint.","Verify the host:port and that the Ghidra script (TraceConnectLaunchTraceServerScript) is running."],"exampleFix":"// before\nclient = STATE.require_client()\n// after\nif STATE.client is None:\n    print(\"Not connected. Run: ghidra_trace_connect <host:port>\")\n    return\nclient = STATE.require_client()","handlingStrategy":"validation","validationCode":"if STATE.client is None:\n    print(\"Not connected. Run: ghidra_trace_connect <host:port>\")\n    return\nclient = STATE.require_client()","typeGuard":"def is_connected() -> bool:\n    return STATE.client is not None","tryCatchPattern":"try:\n    client = STATE.require_client()\nexcept RuntimeError:\n    print(\"Not connected; run ghidra_trace_connect first\")\n    return","preventionTips":["always connect before issuing trace commands","guard scripts with a connection check","verify the Ghidra trace server script is running"],"tags":["ghidra","lldb","runtime-error","state-machine","connection"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}