NationalSecurityAgency/ghidra · error · RuntimeError

Usage: ghidra trace delreg [GROUP]

Error message

Usage: ghidra trace delreg [GROUP]

What it means

Usage error raised by ghidra_trace_delreg when more than one token is supplied. delreg removes recorded registers from the trace; with no GROUP it deletes 'all'. Like delmem, deletion is by design constrained.

Source

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

                        internal_dict: Dict[str, Any]) -> None:
    """Delete the given register group for the current frame from the Ghidra
    trace.

    Usage: ghidra trace delreg [GROUP]

    If no group is specified, 'all' is assumed.

    Why would you do this? There are probably good reasons, but please consider
    that deleting information is typically not helping the user.
    """

    args = shlex.split(command)
    if len(args) == 0:
        group = 'all'
    elif len(args) == 1:
        group = args[0]
    else:
        raise RuntimeError("Usage: ghidra trace delreg [GROUP]")

    trace, tx = STATE.require_tx()
    proc = util.get_process()
    frame = util.selected_frame()
    regs = frame.GetRegisters()
    space = REGS_PATTERN.format(procnum=proc.GetProcessID(), tnum=util.selected_thread().GetThreadID(),
                                level=frame.GetFrameID())
    names: List[str] = []
    if group != 'all':
        bank = regs.GetFirstValueByName(group)
        collect_mapped_names(names, proc, bank)
    else:
        for i in range(regs.GetSize()):
            bank = regs.GetValueAtIndex(i)
            collect_mapped_names(names, proc, bank)
    trace.delete_registers(space, names)

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Pass zero tokens (delete all banks) or exactly one GROUP.
  2. Delete additional banks with separate delreg calls.
  3. Consider whether deletion is necessary; the docstring cautions against it.

Example fix

// before
ghidra trace delreg gp fp
// after
ghidra trace delreg gp
Defensive patterns

Strategy: validation

Validate before calling

import shlex

def validate_delreg(command: str) -> None:
    if len(shlex.split(command)) > 1:
        raise ValueError('delreg takes 0 or 1 GROUP token')

Try / catch

try:
    ghidra_trace_delreg(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: Passing multiple group tokens; passing flags; passing a second argument by accident.

Common situations: User mirrors a multi-bank putreg call into delreg; user appends a confirmation flag.

Related errors


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