NationalSecurityAgency/ghidra · error · LoadException
Cannot add GZT to program
Error message
Cannot add GZT to program
What it means
Thrown by GztLoader.loadInto() unconditionally — GZT traces cannot be appended or merged into an existing Program. The LoadException is always thrown because a GZT file represents a complete trace database, not an additive overlay. The loader only supports creating a new trace via load(), not loading into an existing program.
Source
Thrown at Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/utils/GztLoader.java:132
}
else {
packedDatabase.dispose();
}
}
}
return trace;
}
finally {
if (tmpFile != null) {
tmpFile.delete();
}
}
}
@Override
public void loadInto(Program program, ImporterSettings settings)
throws IOException, LoadException, CancelledException {
throw new LoadException("Cannot add GZT to program");
}
@Override
public Collection<LoadSpec> findSupportedLoadSpecs(ByteProvider provider) throws IOException {
List<LoadSpec> loadSpecs = new ArrayList<>();
if (isGztFile(provider)) {
loadSpecs.add(new LoadSpec(this, 0, false));
}
return loadSpecs;
}
@Override
public String getPreferredFileName(ByteProvider provider) {
return FilenameUtils.removeExtension(provider.getName());
}
private static File createTmpFile(ByteProvider provider, TaskMonitor monitor)
throws IOException {View on GitHub (pinned to d5f144c24d)
Solutions
- Use 'Import' (creating a new trace) instead of 'Add to Program' for GZT files.
- If scripting, call GztLoader.load() to create a new trace rather than loadInto().
- Disable or hide the 'Add to Program' option in the UI when the GZT loader is selected.
- If merging trace data is needed, open the trace separately and use the Debugger's mapping features.
Example fix
// Before: // loader.loadInto(program, settings); // always throws for GZT // // After: // // GZT can only create new traces: // DBTrace trace = (DBTrace) loader.load(loadSpecs, optionList, monitor, consumer);
Defensive patterns
Strategy: validation
Validate before calling
// Before calling loadInto, check if the loader supports it: // GztLoader always throws from loadInto — never call it. // Use load() instead to create a new trace.
Type guard
// GztLoader does not support loadInto at all.
// Always route GZT imports through load(), not loadInto().
boolean supportsLoadInto(Loader loader) {
return !(loader instanceof GztLoader);
} Try / catch
try {
loader.loadInto(program, settings);
} catch (LoadException e) {
if (e.getMessage().equals("Cannot add GZT to program")) {
// use loader.load() to create a new trace instead
} else { throw e; }
} Prevention
- Never call loadInto() on GztLoader — it is unconditionally unsupported.
- In import workflows, use the 'New Project / Import' path for GZT files, not 'Add to Program'.
- In scripts, branch on loader type before calling loadInto vs load.
When it happens
Trigger: Any call to GztLoader.loadInto(Program, ImporterSettings) throws immediately. This happens when the Ghidra import framework or a script attempts to use the GZT loader in 'add to program' mode — for example, importing additional files into an already-open program, or the import dialog offering 'Add to Program' for a GZT file.
Common situations: The user selects 'Add to Program' in the import dialog for a .gzt file. A script calls loader.loadInto() on a GztLoader instance. The import framework routes a multi-file import through loadInto instead of load.
Related errors
- File imported is not a Trace: {traceName}
- only DBTrace objects are supported
- only DBTrace files are supported
- No progam to associate with trace was given
- Selected file is not a program
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/fb4dc8d986b0ec85.
Report an issue: GitHub.