{"record":{"id":"bc1b427a4300851a","repo":"NationalSecurityAgency/ghidra","slug":"invalid-register-name","errorCode":null,"errorMessage":"Invalid register name: {}","messagePattern":"Invalid register name: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/flatapi/FlatDebuggerAPI.java","lineNumber":1077,"sourceCode":"\t\t}\n\t\tif (!invalid.isEmpty()) {\n\t\t\tthrow new IllegalArgumentException(\"One or more invalid register names: \" + invalid);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Validate and retrieve the name register\n\t * \n\t * @param language the language defining the register\n\t * @param name the name\n\t * @return the register\n\t * @throws IllegalArgumentException if the name is invalid\n\t */\n\tdefault Register validateRegisterName(Language language, String name) {\n\t\tRegister register = language.getRegister(name);\n\t\tif (register == null) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid register name: \" + name);\n\t\t}\n\t\treturn register;\n\t}\n\n\t/**\n\t * Read several registers from the current context, refreshing from the target if needed\n\t * \n\t * @param names the source register names\n\t * @return the list of register values, or null on error\n\t * @throws IllegalArgumentException if any name is invalid\n\t * @see #readRegisters(TracePlatform, TraceThread, int, long, Collection)\n\t */\n\tdefault List<RegisterValue> readRegistersNamed(Collection<String> names) {\n\t\treturn readRegisters(validateRegisterNames(requireCurrentTrace().getBaseLanguage(), names));\n\t}\n\n\t/**\n\t * Read a register from the current context, refreshing from the target if needed","sourceCodeStart":1059,"sourceCodeEnd":1095,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/flatapi/FlatDebuggerAPI.java#L1059-L1095","documentation":"Thrown by FlatDebuggerAPI.validateRegisterName(language, name) when the single supplied register name does not exist in the given language. This is the single-name counterpart to the bulk validator.","triggerScenarios":"Calling validateRegisterName(lang, name) where language.getRegister(name) returns null.","commonSituations":"Architecture mismatch (register name from a different ISA); typo in the register name; the register is not exposed by this particular language definition.","solutions":["Check language.getRegister(name) != null before calling validateRegisterName().","Use language.getRegister(name) directly instead of the validator if you just need the register.","Confirm the register name is correct for the platform's architecture."],"exampleFix":"// before\nRegister r = validateRegisterName(lang, \"r15x\"); // typo, throws\n\n// after\nString name = \"r15\";\nif (lang.getRegister(name) == null) {\n    println(\"Unknown register: \" + name);\n    return;\n}\nRegister r = validateRegisterName(lang, name);","handlingStrategy":"validation","validationCode":"if (language.getRegister(name) == null) {\n    println(\"Unknown register: \" + name);\n    return;\n}","typeGuard":"static boolean isValidRegisterName(Language lang, String name) {\n    return lang.getRegister(name) != null;\n}","tryCatchPattern":"try {\n    Register r = validateRegisterName(lang, name);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Invalid register name\")) {\n        // list valid registers for the user, then retry\n    } else throw e;\n}","preventionTips":["Pre-check with language.getRegister(name) before calling the validator.","Confirm the register name belongs to the current architecture."],"tags":["flat-debugger-api","register","language","argument-validation","debugger"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}