{"record":{"id":"c05a516f693e7afa","repo":"NationalSecurityAgency/ghidra","slug":"given-register-is-not-mapped-to-the-host-or-it-s","errorCode":null,"errorMessage":"Given register is not mapped to the host, or it's not in the guest language","messagePattern":"Given register is not mapped to the host, or it's not in the guest language","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/InternalTracePlatform.java","lineNumber":156,"sourceCode":"\t\t\tcontainer.getCanonicalPath(), register);\n\t}\n\n\t@Override\n\tdefault PathFilter getConventionalRegisterPath(AddressSpace space, Register register) {\n\t\tKeyPath path = KeyPath.parse(space.getName());\n\t\tTraceObjectSchema rootSchema = getTrace().getObjectManager().getRootSchema();\n\t\tif (rootSchema == null) {\n\t\t\treturn null;\n\t\t}\n\t\tTraceObjectSchema schema = rootSchema.getSuccessorSchema(path);\n\t\treturn getConventionalRegisterPath(schema, path, register);\n\t}\n\n\t@Override\n\tdefault TraceLabelSymbol addRegisterMapOverride(Register register, String objectName) {\n\t\tAddress hostAddr = mapGuestToHost(register.getAddress());\n\t\tif (hostAddr == null) {\n\t\t\tthrow new IllegalStateException(\n\t\t\t\t\"Given register is not mapped to the host, or it's not in the guest language\");\n\t\t}\n\t\ttry (LockHold hold = getTrace().lockWrite()) {\n\t\t\tTraceSymbolManager symbolManager = getTrace().getSymbolManager();\n\t\t\tTraceNamespaceSymbol globals = symbolManager.getGlobalNamespace();\n\t\t\tTraceNamespaceSymbolView namespaces = symbolManager.namespaces();\n\t\t\tString regMap = regMap(register);\n\t\t\tTraceNamespaceSymbol nsRegMap = namespaces.getGlobalNamed(regMap);\n\t\t\tif (nsRegMap == null) {\n\t\t\t\tnsRegMap = namespaces.add(regMap, globals, SourceType.USER_DEFINED);\n\t\t\t}\n\t\t\tTraceLabelSymbol exists = symbolManager.labels()\n\t\t\t\t\t.getChildWithNameAt(objectName, getIntKey(), hostAddr, nsRegMap);\n\t\t\tif (exists != null) {\n\t\t\t\treturn exists;\n\t\t\t}\n\t\t\treturn symbolManager.labels()\n\t\t\t\t\t.create(0, hostAddr, objectName, nsRegMap, SourceType.USER_DEFINED);","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/InternalTracePlatform.java#L138-L174","documentation":"Thrown by addRegisterMapOverride when mapGuestToHost(register.getAddress()) returns null, meaning the register's address could not be translated from the guest platform to the host platform. This indicates either the register is not part of the guest language at all, or the guest-to-host register mapping table has no entry for this register's address. An override cannot be created because there is no host address to anchor the label symbol to.","triggerScenarios":"Calling platform.addRegisterMapOverride(register, objectName) where 'register' does not exist in the guest language's register context, or the guest platform has no register mapping configured for it. This occurs when you pass a host-only register to a guest platform's override API, or when the guest language has not been fully mapped to the host.","commonSituations":"Using a Register object obtained from the host language rather than the guest language; guest language definition missing register mappings; attempting to override a register that was removed in a newer .sla/.sleigh file; calling addRegisterMapOverride before the platform's register mappings are initialized.","solutions":["Obtain the Register from the guest platform's language: platform.getLanguage().getRegister(name), not the host language.","Verify the register exists in the guest language via platform.getLanguage().getRegisters() before calling addRegisterMapOverride.","If the register is genuinely host-only and you want to expose it, register it in the guest language's mapping table first."],"exampleFix":"// before\nRegister reg = hostLanguage.getRegister(\"XMM0\");\nplatform.addRegisterMapOverride(reg, \"xmm0\");\n\n// after — use the guest platform's own register\nRegister reg = platform.getLanguage().getRegister(\"XMM0\");\nif (reg != null) {\n    platform.addRegisterMapOverride(reg, \"xmm0\");\n}","handlingStrategy":"validation","validationCode":"// Verify the register maps to host before calling addRegisterMapOverride\nAddress hostAddr = platform.mapGuestToHost(register.getAddress());\nif (hostAddr == null) {\n    // Register is not mapped — do not call addRegisterMapOverride\n    throw new IllegalStateException(\"Register \" + register + \" has no host mapping\");\n}\nplatform.addRegisterMapOverride(register, objectName);","typeGuard":"static boolean registerIsMappedToHost(TracePlatform platform, Register register) {\n    return platform.mapGuestToHost(register.getAddress()) != null;\n}","tryCatchPattern":"try {\n    platform.addRegisterMapOverride(register, objectName);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"not mapped to the host\")) {\n        // Register is not in the guest language — skip or log\n        Msg.warn(MyClass.class, \"Cannot override unmapped register: \" + register);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Always source Register objects from platform.getLanguage(), never from the host language.","Call mapGuestToHost(register.getAddress()) to pre-check before addRegisterMapOverride.","Filter your register list to only those present in the guest language's register context."],"tags":["register-mapping","guest-platform","override","trace-modeling"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}