{"record":{"id":"5c0684b03bb490b8","repo":"NationalSecurityAgency/ghidra","slug":"usage-ghidra-trace-put-environment","errorCode":null,"errorMessage":"Usage: ghidra trace put-environment","messagePattern":"Usage: ghidra trace put-environment","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py","lineNumber":1689,"sourceCode":"    envobj.set_value('Debugger', 'lldb')\n    envobj.set_value('Arch', arch.get_arch())\n    envobj.set_value('OS', arch.get_osabi())\n    envobj.set_value('Endian', arch.get_endian())\n    envobj.insert()\n\n\n@convert_errors\ndef ghidra_trace_put_environment(debugger: lldb.SBDebugger, command: str,\n                                 result: lldb.SBCommandReturnObject,\n                                 internal_dict: Dict[str, Any]) -> None:\n    \"\"\"Put some environment indicators into the Ghidra trace.\n\n    Usage: ghidra trace put-environment\n    \"\"\"\n\n    args = shlex.split(command)\n    if len(args) != 0:\n        raise RuntimeError(\"Usage: ghidra trace put-environment\")\n\n    trace, tx = STATE.require_tx()\n    with trace.client.batch() as b:\n        put_environment()\n\n\ndef should_query_regions() -> bool:\n    \"\"\"It's possible some targets don't support regions.\n\n    There is also a bug in LLDB that can cause its gdb-remote client to\n    drop support. We need to account for this second case while still\n    ensuring we populate the full range for targets that genuinely don't\n    support it.\n    \"\"\"\n    # somewhat crappy heuristic to distinguish remote from local\n    tgt = util.get_target()\n    if tgt.GetNumModules() == 0:\n        # Target genuinely doesn't support regions.","sourceCodeStart":1671,"sourceCodeEnd":1707,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py#L1671-L1707","documentation":"Raised by ghidra_trace_put_environment when any argument is passed. put-environment writes environment indicators (Debugger='lldb', Arch) for the current process into the trace and accepts no arguments (commands.py:1689).","triggerScenarios":"Adding an architecture or platform token like `ghidra trace put-environment x86_64`, or trailing text after the command.","commonSituations":"Users try to force an architecture via this command, but arch is derived from arch.get_arch(); passing it as an argument is rejected.","solutions":["Run with no arguments: `ghidra trace put-environment`.","To change arch, set the LLDB target's architecture (target triple) before launching so arch.get_arch() reports correctly."],"exampleFix":"// before\nghidra trace put-environment arm64\n// after\nghidra trace put-environment","handlingStrategy":"validation","validationCode":"assert len(command.split()) == 0, \"put-environment takes no arguments\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Arch is derived from the LLDB target triple, not an argument.","Set the target architecture before launch if arch is wrong."],"tags":["lldb","ghidra","cli-usage","debugger-agent","environment"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}