{"record":{"id":"57798d6d61df55ac","repo":"NationalSecurityAgency/ghidra","slug":"register-is-not-in-language","errorCode":null,"errorMessage":"Register {} is not in language {}","messagePattern":"Register (.+?) is not in language (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/flatapi/FlatDebuggerAPI.java","lineNumber":1108,"sourceCode":"\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\n\t * \n\t * @param platform the platform whose language defines the register\n\t * @param register the register\n\t * @return the value, or null on error\n\t */\n\tdefault RegisterValue readRegister(TracePlatform platform, Register register) {\n\t\tDebuggerCoordinates current = getCurrentDebuggerCoordinates();\n\t\tif (platform.getTrace() != current.getTrace()) {\n\t\t\tthrow new IllegalArgumentException(\"Given platform is not from the current trace\");\n\t\t}\n\t\tLanguage language = platform.getLanguage();\n\t\tif (!register.equals(language.getRegister(register.getName()))) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\"Register \" + register + \" is not in language \" + language);\n\t\t}\n\t\treturn readRegister(platform, requireThread(current.getThread()), current.getFrame(),\n\t\t\tcurrent.getSnap(), register);\n\t}\n\n\t/**\n\t * Read a register from the current context, refreshing from the target if needed\n\t * \n\t * @param register the register\n\t * @return the value, or null on error\n\t */\n\tdefault RegisterValue readRegister(Register register) {\n\t\treturn readRegister(requireCurrentPlatform(), register);\n\t}\n\n\t/**\n\t * Read a register from the current context, refreshing from the target if needed","sourceCodeStart":1090,"sourceCodeEnd":1126,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/flatapi/FlatDebuggerAPI.java#L1090-L1126","documentation":"Thrown by FlatDebuggerAPI.readRegister(platform, register) when the supplied Register object does not belong to the platform's language. It checks that the language's register of the same name equals the supplied register.","triggerScenarios":"Calling readRegister(platform, register) where register was obtained from a different language than platform.getLanguage().","commonSituations":"Register obtained from an old platform's language and reused after a platform/language change; mixing registers across architectures; register from a different compiler/sleigh language variant.","solutions":["Obtain the register from platform.getLanguage().getRegister(name) immediately before the call.","Assert the register's language matches the platform's language.","Re-resolve the register object whenever the platform changes."],"exampleFix":"// before\nRegister reg = oldLang.getRegister(\"RAX\");\nreadRegister(platform, reg); // throws if platform.lang != oldLang\n\n// after\nRegister reg = platform.getLanguage().getRegister(\"RAX\");\nreadRegister(platform, reg);","handlingStrategy":"validation","validationCode":"Register resolved = platform.getLanguage().getRegister(register.getName());\nif (!register.equals(resolved)) {\n    throw new IllegalStateException(\n        \"Register not in platform language\");\n}","typeGuard":"static boolean registerInLanguage(TracePlatform platform,\n        Register register) {\n    return register.equals(\n        platform.getLanguage().getRegister(register.getName()));\n}","tryCatchPattern":"try {\n    RegisterValue v = readRegister(platform, reg);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Register \")) {\n        reg = platform.getLanguage().getRegister(reg.getName());\n    } else throw e;\n}","preventionTips":["Resolve Register objects from the platform's own language at call time.","Re-resolve registers whenever the platform/language changes."],"tags":["flat-debugger-api","register","language","platform","debugger"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}