{"record":{"id":"7995e1d92c59b7d8","repo":"NationalSecurityAgency/ghidra","slug":"no-context-register-name-provided","errorCode":null,"errorMessage":"No context register name provided.","messagePattern":"No context register name provided\\.","errorType":"exception","errorClass":"JDOMException","httpStatus":null,"severity":"warning","filePath":"Ghidra/Extensions/SleighDevTools/src/main/java/ghidra/app/util/disassemble/GNUExternalDisassembler.java","lineNumber":229,"sourceCode":"\t\t\t\tif (globalElement != null) {\n\t\t\t\t\tglobalDisassemblerOptions = globalElement.getAttributeValue(\"optstring\");\n\t\t\t\t}\n\t\t\t\tElement contextRegisterElement = rootElem.getChild(\"context_register\");\n\t\t\t\tif (contextRegisterElement == null) {\n\t\t\t\t\t//no context_register element found in the xml file \n\t\t\t\t\t//this is not necessarily an error - might only be a global optstring\n\t\t\t\t\t//global optstring has already been parsed, so we're done\n\t\t\t\t\tif (globalElement != null) {\n\t\t\t\t\t\tMsg.info(this,\n\t\t\t\t\t\t\t\"no context register element in \" + gdisOpts.getAbsolutePath());\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t//no context register element or global element, error\n\t\t\t\t\tthrow new JDOMException(\n\t\t\t\t\t\t\"No context_register element or global element in gdis options file\");\n\t\t\t\t}\n\t\t\t\tif (contextRegisterElement.getContentSize() == 0) {\n\t\t\t\t\tthrow new JDOMException(\"No context register name provided.\");\n\t\t\t\t}\n\t\t\t\tString contextRegisterName = contextRegisterElement.getContent(0).getValue();\n\t\t\t\tcontextRegister = lang.getRegister(contextRegisterName);\n\t\t\t\tif (contextRegister == null) {\n\t\t\t\t\t//the context register named in the xml file does not exist in the sleigh language\n\t\t\t\t\t//this is an error\n\t\t\t\t\tthrow new JDOMException(\"Unknown context register \" + contextRegisterName +\n\t\t\t\t\t\t\" for language \" + lang.getLanguageID().getIdAsString());\n\t\t\t\t}\n\t\t\t\tvalueToOptionString = new HashMap<>();\n\t\t\t\tvalueToDisplayPrefix = new HashMap<>();\n\t\t\t\tElement options = rootElem.getChild(\"options\");\n\t\t\t\tList<Element> optList = options.getChildren(\"option\");\n\t\t\t\tfor (Element opt : optList) {\n\t\t\t\t\tLong value = Long.decode(opt.getAttributeValue(\"value\"));\n\t\t\t\t\tString optString = opt.getAttributeValue(\"optstring\");\n\t\t\t\t\tvalueToOptionString.put(value, optString);\n\t\t\t\t\tString displayPrefix = opt.getAttributeValue(\"display_prefix\");","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Extensions/SleighDevTools/src/main/java/ghidra/app/util/disassemble/GNUExternalDisassembler.java#L211-L247","documentation":"Thrown by parseGdisOptionsFile() as a JDOMException when a <context_register> element exists but has empty content (getContentSize() == 0). The element must contain the register name as its text content; an empty element yields no register name to look up. Like 638 it is caught internally, logged, and resets the config fields.","triggerScenarios":"An options file with <context_register></context_register> or <context_register/> — the tag is present but the register name text node is missing.","commonSituations":"Authoring a new gdis options file and forgetting to fill in the register name; an editing tool that collapsed the element to self-closing.","solutions":["Put the context register name as the element's text content, e.g. <context_register>cs</context_register>.","Ensure the named register exists for the Sleigh language (else a separate 'Unknown context register' error follows).","Remove the <context_register> element entirely if the file should be global-optstring-only (but then add a <global> element, see 638)."],"exampleFix":"<!-- before -->\n<context_register/>\n\n<!-- after -->\n<context_register>cs</context_register>","handlingStrategy":"validation","validationCode":"import org.jdom2.Element;\nElement ctx = root.getChild(\"context_register\");\nif (ctx != null && ctx.getContentSize() == 0) {\n    // empty <context_register/>; require a name or remove the element\n}","typeGuard":"public boolean contextRegisterHasName(Element ctx) {\n    return ctx != null && ctx.getContentSize() > 0\n        && ctx.getContent(0).getValue() != null && !ctx.getContent(0).getValue().trim().isEmpty();\n}","tryCatchPattern":"try {\n    config.parseGdisOptionsFile(fileName);\n} catch (JDOMException e) {\n    if (e.getMessage().equals(\"No context register name provided.\")) {\n        // fill the element text or drop it in favor of a <global> block\n    } else throw e;\n}","preventionTips":["Always put the register name as text inside <context_register>...</context_register>.","Verify the named register exists for the Sleigh language to avoid the follow-on error.","Validate the options file content (non-empty element) before deploying it."],"tags":["sleigh-devtools","external-disassembler","configuration","xml"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}