NationalSecurityAgency/ghidra · error · RuntimeError

Usage: ghidra trace remove-obj PATH

Error message

Usage: ghidra trace remove-obj PATH

What it means

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.

Source

Thrown at Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py:1040

    span = trace.proxy_object_path(path).insert()
    result.PutCString(f"Inserted object: lifespan={span}")


@convert_errors
def ghidra_trace_remove_obj(debugger: lldb.SBDebugger, command: str,
                            result: lldb.SBCommandReturnObject,
                            internal_dict: Dict[str, Any]) -> None:
    """Remove an object from the Ghidra trace.

    Usage: ghidra trace remove-obj PATH

    This does not delete the object. It just removes it from the tree for the
    current snap and onwards.
    """

    args = shlex.split(command)
    if len(args) != 1:
        raise RuntimeError("Usage: ghidra trace remove-obj PATH")
    path = args[0]

    # NOTE: id parameter is probably not necessary, since this command is for
    # humans.
    trace, tx = STATE.require_tx()
    trace.proxy_object_path(path).remove()


def to_bytes(value: lldb.SBValue) -> bytes:
    n = value.GetNumChildren()
    return bytes(int(value.GetChildAtIndex(i).GetValueAsUnsigned())
                 for i in range(0, n))


def to_string(value: lldb.SBValue, encoding: str) -> str:
    n = value.GetNumChildren()
    b = bytes(int(value.GetChildAtIndex(i).GetValueAsUnsigned())
              for i in range(0, n))

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Pass exactly one PATH token.
  2. Quote the command so PATH stays a single token.
  3. Remember remove only affects current snap onwards; it is not a hard delete.

Example fix

// before
ghidra trace remove-obj Processes[0] Threads[1]
// after
ghidra trace remove-obj Processes[0].Threads[1]
Defensive patterns

Strategy: validation

Validate before calling

import shlex

def validate_remove_obj(command: str) -> None:
    if len(shlex.split(command)) != 1:
        raise ValueError('remove-obj needs exactly one PATH token')

Type guard

def is_single_path_token(command: str) -> bool:
    return len(shlex.split(command)) == 1

Try / catch

try:
    ghidra_trace_remove_obj(debugger, command, result, internal_dict)
except RuntimeError as e:
    if str(e).startswith('Usage:'):
        result.SetError(str(e))
    else:
        raise

Prevention

When it happens

Trigger: Zero tokens; multi-token unquoted path; passing flags; passing a snap/lifespan argument.

Common situations: User quotes PATH incorrectly; user expects remove to accept a range or snap parameter that the command does not support.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/86c0e3fed49aa854. Report an issue: GitHub.