{"record":{"id":"7597ec1caf3c25af","repo":"NationalSecurityAgency/ghidra","slug":"usage-ghidra-trace-disconnect","errorCode":null,"errorMessage":"Usage: ghidra trace disconnect","messagePattern":"Usage: ghidra trace disconnect","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py","lineNumber":356,"sourceCode":"        print(f\"Connection from {chost}:{cport}\")\n        STATE.client = Client(\n            c, util.LLDB_VERSION.display, methods.REGISTRY)\n    except ValueError:\n        raise RuntimeError(\"PORT must be numeric\")\n\n\n@convert_errors\ndef ghidra_trace_disconnect(debugger: lldb.SBDebugger, command: str,\n                            result: lldb.SBCommandReturnObject,\n                            internal_dict: Dict[str, Any]) -> None:\n    \"\"\"Disconnect LLDB from Ghidra for tracing.\n\n    Usage: ghidra trace disconnect\n    \"\"\"\n\n    args = shlex.split(command)\n    if len(args) != 0:\n        raise RuntimeError(\"Usage: ghidra trace disconnect\")\n\n    STATE.require_client().close()\n    STATE.reset_client()\n\n\ndef compute_name() -> str:\n    target = lldb.debugger.GetTargetAtIndex(0)\n    progname = target.executable.basename\n    if progname is None:\n        return 'lldb/noname'\n    else:\n        return 'lldb/' + progname.split('/')[-1]\n\n\ndef start_trace(name: str) -> None:\n    language, compiler = arch.compute_ghidra_lcsp()\n    STATE.trace = STATE.require_client().create_trace(\n        name, language, compiler, extra=Extra())","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py#L338-L374","documentation":"`ghidra trace disconnect` takes no arguments; it closes the client stored in STATE. Any extra token aborts before the close runs (so the client is left connected).","triggerScenarios":"`ghidra trace disconnect now`; `ghidra trace disconnect 127.0.0.1:12345`.","commonSituations":"Assuming disconnect needs the address (it does not — it uses STATE.client); adding a confirmation word.","solutions":["Call it with no arguments: `ghidra trace disconnect`"],"exampleFix":"// before\nghidra trace disconnect 127.0.0.1:12345\n// after\nghidra trace disconnect","handlingStrategy":"validation","validationCode":"import shlex\ndef no_args(command: str) -> bool:\n    return len(shlex.split(command)) == 0","typeGuard":null,"tryCatchPattern":"try:\n    ghidra_trace_disconnect(debugger, command, result, internal_dict)\nexcept RuntimeError as e:\n    if str(e).startswith('Usage: ghidra trace disconnect'):\n        # drop all arguments and retry\n        ...\n    raise","preventionTips":["Disconnect takes no arguments — it uses the stored client","Run `ghidra trace info` to confirm a connection exists before disconnecting"],"tags":["ghidra","lldb","cli","validation","connection"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}