NationalSecurityAgency/ghidra · warning · JDOMException
No context_register element or global element in gdis option
Error message
No context_register element or global element in gdis options file
What it means
Thrown by parseGdisOptionsFile() as a JDOMException when the gdis options XML file has neither a <context_register> element nor a <global> element under the root. A <global> alone is acceptable (optstring-only); a <context_register> alone is acceptable; but the complete absence of both means the file carries no usable configuration. (This is caught internally and logged; config fields are reset.)
Source
Thrown at Ghidra/Extensions/SleighDevTools/src/main/java/ghidra/app/util/disassemble/GNUExternalDisassembler.java:225
try (InputStream fis = gdisOpts.getInputStream()) {
Document doc = sax.build(fis);
Element rootElem = doc.getRootElement();
Element globalElement = rootElem.getChild("global");
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) {View on GitHub (pinned to d5f144c24d)
Solutions
- Add at least a <global optstring="..."/> or a properly populated <context_register> element to the options XML.
- Validate the options file against a known-good one from a working language (e.g. an x86 gdis options file).
- If external disassembly isn't needed for this language, remove the options file so the integration is not attempted.
Example fix
<!-- before --> <gdis> </gdis> <!-- after --> <gdis> <global optstring="-M"/> </gdis>
Defensive patterns
Strategy: validation
Validate before calling
import org.jdom2.Element;
Element root = doc.getRootElement();
boolean hasGlobal = root.getChild("global") != null;
boolean hasCtx = root.getChild("context_register") != null;
if (!hasGlobal && !hasCtx) {
// options file is empty of usable config; add one before relying on it
} Type guard
public boolean gdisOptionsHasUsableConfig(Element root) {
return root.getChild("global") != null || root.getChild("context_register") != null;
} Try / catch
try {
config.parseGdisOptionsFile(fileName);
} catch (JDOMException e) {
if (e.getMessage().contains("context_register element or global element")) {
// external disassembler disabled for this language; degrade gracefully
} else throw e;
} Prevention
- Author gdis options files with at least a <global> or <context_register> block.
- Validate the XML structure against a working language's options file.
- Remove the options file if external disassembly is not required for the language.
When it happens
Trigger: A language's gdis options file (.gdis or named options file next to the .slaspec) that is empty, has only an unrelated root, or is a stub missing both required elements.
Common situations: Hand-editing a gdis options file and deleting both elements; a newly added language whose options file was created as a placeholder; corruption during an upgrade that stripped elements.
Related errors
- No context register name provided.
- 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/2e2db58f7f1aa670.
Report an issue: GitHub.