NationalSecurityAgency/ghidra · warning · JDOMException
No context register name provided.
Error message
No context register name provided.
What it means
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.
Source
Thrown at Ghidra/Extensions/SleighDevTools/src/main/java/ghidra/app/util/disassemble/GNUExternalDisassembler.java:229
if (globalElement != null) {
globalDisassemblerOptions = globalElement.getAttributeValue("optstring");
}
Element contextRegisterElement = rootElem.getChild("context_register");
if (contextRegisterElement == null) {
//no context_register element found in the xml file
//this is not necessarily an error - might only be a global optstring
//global optstring has already been parsed, so we're done
if (globalElement != null) {
Msg.info(this,
"no context register element in " + gdisOpts.getAbsolutePath());
return;
}
//no context register element or global element, error
throw new JDOMException(
"No context_register element or global element in gdis options file");
}
if (contextRegisterElement.getContentSize() == 0) {
throw new JDOMException("No context register name provided.");
}
String contextRegisterName = contextRegisterElement.getContent(0).getValue();
contextRegister = lang.getRegister(contextRegisterName);
if (contextRegister == null) {
//the context register named in the xml file does not exist in the sleigh language
//this is an error
throw new JDOMException("Unknown context register " + contextRegisterName +
" for language " + lang.getLanguageID().getIdAsString());
}
valueToOptionString = new HashMap<>();
valueToDisplayPrefix = new HashMap<>();
Element options = rootElem.getChild("options");
List<Element> optList = options.getChildren("option");
for (Element opt : optList) {
Long value = Long.decode(opt.getAttributeValue("value"));
String optString = opt.getAttributeValue("optstring");
valueToOptionString.put(value, optString);
String displayPrefix = opt.getAttributeValue("display_prefix");View on GitHub (pinned to d5f144c24d)
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).
Example fix
<!-- before --> <context_register/> <!-- after --> <context_register>cs</context_register>
Defensive patterns
Strategy: validation
Validate before calling
import org.jdom2.Element;
Element ctx = root.getChild("context_register");
if (ctx != null && ctx.getContentSize() == 0) {
// empty <context_register/>; require a name or remove the element
} Type guard
public boolean contextRegisterHasName(Element ctx) {
return ctx != null && ctx.getContentSize() > 0
&& ctx.getContent(0).getValue() != null && !ctx.getContent(0).getValue().trim().isEmpty();
} Try / catch
try {
config.parseGdisOptionsFile(fileName);
} catch (JDOMException e) {
if (e.getMessage().equals("No context register name provided.")) {
// fill the element text or drop it in favor of a <global> block
} else throw e;
} Prevention
- 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.
When it happens
Trigger: An options file with <context_register></context_register> or <context_register/> — the tag is present but the register name text node is missing.
Common situations: Authoring a new gdis options file and forgetting to fill in the register name; an editing tool that collapsed the element to self-closing.
Related errors
- No context_register element or global element in gdis option
- Not a Sleigh Language:
- Unknown context register
- Error: disassemble_fn is NULL. Nothing I can do.\n
- Invalid byte_order: {}
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/7995e1d92c59b7d8.
Report an issue: GitHub.