{"record":{"id":"cc86c2b4e517d49c","repo":"NationalSecurityAgency/ghidra","slug":"unknown-register-or-label-nm","errorCode":null,"errorMessage":"Unknown register or label: '{nm}'","messagePattern":"Unknown register or label: '(.+?)'","errorType":"exception","errorClass":"SleighException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger/src/main/java/ghidra/pcode/exec/DebuggerPcodeUtils.java","lineNumber":193,"sourceCode":"\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (mode.preferId) {\n\t\t\t\tSleighSymbol symbol = tryIntegerLiteral(loc, nm, false);\n\t\t\t\tif (symbol != null) {\n\t\t\t\t\treturn symbol;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * NOTE: This may break things that check for the absence of a symbol\n\t\t\t * \n\t\t\t * I don't think it'll affect expressions, but it could later affect user Sleigh\n\t\t\t * libraries that an expression might like to use. The better approach might be to pass\n\t\t\t * a parameter indicating whether absence is good or bad.\n\t\t\t */\n\t\t\tsc.reportError(loc, \"Unknown register or label '%s'\".formatted(nm));\n\t\t\tthrow new SleighException(\"Unknown register or label: '\" + nm + \"'\");\n\t\t}\n\n\t\tprotected SleighSymbol tryMap(String nm, Trace trace, long snap, Program program,\n\t\t\t\tSymbol symbol, Address addr, List<SleighSymbol> externals) {\n\t\t\tTraceLocation tloc =\n\t\t\t\tmappings.getOpenMappedLocation(trace, new ProgramLocation(program, addr), snap);\n\t\t\tif (tloc == null) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tSleighSymbol mapped = createSleighConstant(program.getName(), nm, tloc.getAddress());\n\t\t\tif (!symbol.isExternal()) {\n\t\t\t\treturn mapped;\n\t\t\t}\n\t\t\t// Most externals will not map, but if one does, use it as a fallback\n\t\t\texternals.add(mapped);\n\t\t\treturn null;\n\t\t}\n","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger/src/main/java/ghidra/pcode/exec/DebuggerPcodeUtils.java#L175-L211","documentation":"Thrown during Sleigh expression parsing when the symbol resolver encounters a name that is neither a known register nor a defined label in the current scope. DebuggerPcodeUtils' custom SleighSymbolResolver reports the error via sc.reportError() and then throws SleighException. This occurs when evaluating p-code expressions (e.g., for register access or breakpoints) that reference undefined symbols.","triggerScenarios":"The symbol resolver's resolve() method is called for a name 'nm' that isn't found among registers, labels, or mapped symbols. sc.reportError() is called first, then SleighException is thrown. Happens when a p-code expression references a register name that doesn't exist in the processor's register context, or a label that hasn't been defined.","commonSituations":"The user types a register name in a debugger expression that doesn't exist for the current processor (e.g., 'rax' on an ARM target). A Sleigh expression references an external symbol that has no mapping. The processor specification changed, renaming or removing a register. A typo in the expression.","solutions":["Verify the register or label name is valid for the current processor model.","Check for typos in the expression — register names are case-sensitive and architecture-specific.","Ensure the symbol is defined in the program's symbol table or the processor's register list.","If referencing a mapped symbol, verify the trace-to-program mapping covers it.","Consult the processor's .sleigh file for the correct register and label names."],"exampleFix":"// Before: expression references unknown symbol\n// eval \"R15 + unknown_label\"\n//\n// After: use valid register/label names for the target architecture\n// eval \"R15 + R0\"","handlingStrategy":"try-catch","validationCode":"// No generic pre-check; symbol resolution is context-dependent.\n// Validate expression tokens against known registers/labels before parsing if possible.\n// Check program.getLanguage().getRegisters() for valid register names.","typeGuard":"// Check if a name is a known register before evaluating:\nboolean isKnownRegister(String name, Program program) {\n    return program.getLanguage().getRegister(name) != null;\n}","tryCatchPattern":"try {\n    // evaluate Sleigh expression\n} catch (SleighException e) {\n    if (e.getMessage().startsWith(\"Unknown register or label\")) {\n        // inform user of valid register/label names for the architecture\n    } else { throw e; }\n}","preventionTips":["Verify register names against the processor's .sleigh specification before using them.","Use autocomplete or register enumeration to avoid typos in expressions.","Ensure label symbols are defined in the program's symbol table before referencing them.","When switching architectures, update all hardcoded register names in scripts."],"tags":["sleigh","pcode","symbol-resolution","register","expression"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}