{"record":{"id":"a24230302cd9d744","repo":"NationalSecurityAgency/ghidra","slug":"usage-ghidra-trace-delmem-address-length","errorCode":null,"errorMessage":"Usage: ghidra trace delmem ADDRESS LENGTH","messagePattern":"Usage: ghidra trace delmem ADDRESS LENGTH","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py","lineNumber":850,"sourceCode":"@convert_errors\ndef ghidra_trace_delmem(debugger: lldb.SBDebugger, command: str,\n                        result: lldb.SBCommandReturnObject,\n                        internal_dict: Dict[str, Any]) -> None:\n    \"\"\"Delete the given range of memory from the Ghidra trace.\n\n    Usage: ghidra trace delmem ADDRESS LENGTH\n\n    Why would you do this? There are probably good reasons, but please consider\n    that deleting information is typically not helping the user.\n\n    Note there is no PAGES argument. This is to prevent accidental deletion of\n    more bytes than intended. Expand the range manually, if you must.\n    \"\"\"\n\n    trace = STATE.require_trace()\n    args = shlex.split(command)\n    if len(args) != 2:\n        raise RuntimeError(\"Usage: ghidra trace delmem ADDRESS LENGTH\")\n    address = args[0]\n    length = args[1]\n\n    STATE.require_tx()\n    start, end = eval_range(address, length)\n    if start is None or end is None:\n        return\n    proc = util.get_process()\n    base, addr = trace.extra.require_mm().map(proc, start)\n    # Do not create the space. We're deleting stuff.\n    trace.delete_bytes(addr.extend(end - start))\n\n\n# Yes, lldb puts each full bank in a \"value\", with chilren for each reg\ndef putreg(frame: lldb.SBFrame, bank: lldb.SBValue) -> None:\n    proc = util.get_process()\n    space = REGS_PATTERN.format(procnum=proc.GetProcessID(),\n                                tnum=util.selected_thread().GetThreadID(),","sourceCodeStart":832,"sourceCodeEnd":868,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py#L832-L868","documentation":"Usage error raised by ghidra_trace_delmem when the token count is not exactly 2. delmem intentionally has no PAGES argument (the docstring warns deletion should be deliberate), so only ADDRESS and LENGTH are accepted.","triggerScenarios":"Passing 0, 1, 3+ tokens; attempting to add a PAGES flag (rejected by design); including STATE or other trailing arguments.","commonSituations":"User assumes delmem mirrors putmem's signature and tries to add PAGES; user pastes a 3-token putmem-style command into delmem.","solutions":["Pass exactly two tokens: ADDRESS LENGTH.","To delete a wider range, expand ADDRESS/LENGTH manually rather than passing PAGES.","Double-check that deletion is intended; the docstring warns this is rarely helpful."],"exampleFix":"// before\nghidra trace delmem 0x10000 0x100 1\n// after\nghidra trace delmem 0x10000 0x100","handlingStrategy":"validation","validationCode":"import shlex\n\ndef validate_delmem(command: str) -> None:\n    if len(shlex.split(command)) != 2:\n        raise ValueError('delmem needs exactly ADDRESS LENGTH (no PAGES)')","typeGuard":null,"tryCatchPattern":"try:\n    ghidra_trace_delmem(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":["delmem has no PAGES argument by design.","Expand the range manually if more bytes must be deleted.","Treat deletion as deliberate; verify ranges before running."],"tags":["ghidra-trace","argument-validation","cli-usage"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}