{"record":{"id":"86c0e3fed49aa854","repo":"NationalSecurityAgency/ghidra","slug":"usage-ghidra-trace-remove-obj-path","errorCode":null,"errorMessage":"Usage: ghidra trace remove-obj PATH","messagePattern":"Usage: ghidra trace remove-obj PATH","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py","lineNumber":1040,"sourceCode":"    span = trace.proxy_object_path(path).insert()\n    result.PutCString(f\"Inserted object: lifespan={span}\")\n\n\n@convert_errors\ndef ghidra_trace_remove_obj(debugger: lldb.SBDebugger, command: str,\n                            result: lldb.SBCommandReturnObject,\n                            internal_dict: Dict[str, Any]) -> None:\n    \"\"\"Remove an object from the Ghidra trace.\n\n    Usage: ghidra trace remove-obj PATH\n\n    This does not delete the object. It just removes it from the tree for the\n    current snap and onwards.\n    \"\"\"\n\n    args = shlex.split(command)\n    if len(args) != 1:\n        raise RuntimeError(\"Usage: ghidra trace remove-obj PATH\")\n    path = args[0]\n\n    # NOTE: id parameter is probably not necessary, since this command is for\n    # humans.\n    trace, tx = STATE.require_tx()\n    trace.proxy_object_path(path).remove()\n\n\ndef to_bytes(value: lldb.SBValue) -> bytes:\n    n = value.GetNumChildren()\n    return bytes(int(value.GetChildAtIndex(i).GetValueAsUnsigned())\n                 for i in range(0, n))\n\n\ndef to_string(value: lldb.SBValue, encoding: str) -> str:\n    n = value.GetNumChildren()\n    b = bytes(int(value.GetChildAtIndex(i).GetValueAsUnsigned())\n              for i in range(0, n))","sourceCodeStart":1022,"sourceCodeEnd":1058,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py#L1022-L1058","documentation":"Usage error raised by ghidra_trace_remove_obj when the token count is not exactly 1. remove_obj unlinks an object from the tree for the current snap onwards (it does not delete the object). A single PATH token is required.","triggerScenarios":"Zero tokens; multi-token unquoted path; passing flags; passing a snap/lifespan argument.","commonSituations":"User quotes PATH incorrectly; user expects remove to accept a range or snap parameter that the command does not support.","solutions":["Pass exactly one PATH token.","Quote the command so PATH stays a single token.","Remember remove only affects current snap onwards; it is not a hard delete."],"exampleFix":"// before\nghidra trace remove-obj Processes[0] Threads[1]\n// after\nghidra trace remove-obj Processes[0].Threads[1]","handlingStrategy":"validation","validationCode":"import shlex\n\ndef validate_remove_obj(command: str) -> None:\n    if len(shlex.split(command)) != 1:\n        raise ValueError('remove-obj needs exactly one PATH token')","typeGuard":"def is_single_path_token(command: str) -> bool:\n    return len(shlex.split(command)) == 1","tryCatchPattern":"try:\n    ghidra_trace_remove_obj(debugger, command, result, internal_dict)\nexcept RuntimeError as e:\n    if str(e).startswith('Usage:'):\n        result.SetError(str(e))\n    else:\n        raise","preventionTips":["Pass a single quoted PATH token.","Remember remove only affects the current snap onward.","remove-obj does not delete the object."],"tags":["ghidra-trace","argument-validation","object-tree","cli-usage"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}