NationalSecurityAgency/ghidra · error · LoadException
Cannot add Trace to a program
Error message
Cannot add Trace to a program
What it means
TenetPlusPlusLoader.loadInto(Program, ImporterSettings) is overridden to always throw LoadException('Cannot add Trace to a program'). A Tenet++ trace becomes its own Trace domain object and cannot be merged into an existing Program; this entry point is intentionally disabled.
Source
Thrown at Ghidra/Debug/Debugger-importers/src/main/java/ghidra/app/util/opinion/TenetPlusPlusLoader.java:346
final long flushDone = System.currentTimeMillis();
settings.log()
.appendMsg("%d ms to load trace | %d ms to flush cache | %d ms total time"
.formatted(loadDone - start, flushDone - loadDone, flushDone - start));
return new LoadResults<>(new Loaded<>(trace, settings));
}
finally {
if (program != null) {
program.release(this);
}
}
}
@Override
public void loadInto(final Program program, final ImporterSettings settings)
throws IOException, LoadException, CancelledException {
throw new LoadException("Cannot add Trace to a program");
}
private Trace loadTrace(final ByteProvider provider, final String name, final Program program,
final Object consumer, final MessageLog log, final TaskMonitor monitor)
throws LanguageNotFoundException, IOException, CancelledException {
this.program = program;
final Language lang = program.getLanguage();
defaultSpace = lang.getAddressFactory().getDefaultAddressSpace();
final Trace trace = new DBTrace(name, program.getCompilerSpec(), consumer);
final TraceObjectManager om = trace.getObjectManager();
try (Transaction tx = trace.openTransaction("Import Tenet++ Trace: %s".formatted(name));
BypassWriteCache bypass = om.withoutWriteCache()) {
om.createRootObject(TENET_PLUS_PLUS_SESSION_SCHEMA);
View on GitHub (pinned to d5f144c24d)
Solutions
- Use load() which creates a new Trace domain object rather than loadInto().
- In a generic dispatcher, skip trace loaders for the loadInto path or detect and handle the LoadException contract.
- Document that Tenet++ traces are imported as standalone Trace objects.
Defensive patterns
Strategy: validation
Validate before calling
if (loader instanceof TenetPlusPlusLoader) {
// use load() to create a new Trace; never loadInto()
} Try / catch
try {
loader.loadInto(program, settings);
} catch (LoadException e) {
if (e.getMessage().contains("Cannot add Trace to a program")) {
// fall back to load() to create a standalone Trace
}
} Prevention
- Never call loadInto on Tenet++ trace loaders.
- Use load() to produce a standalone Trace domain object.
- Handle trace loaders specially in generic dispatchers.
When it happens
Trigger: A generic importer or script calls loadInto on TenetPlusPlusLoader instead of load(). The override makes the unsupported operation fail fast.
Common situations: Loader-dispatch harness that assumes loadInto works for every loader; misusing the trace loader in a merge-into-program workflow.
Related errors
- Cannot add Trace to a program
- No progam to associate with trace was given
- Encountered too many errors with this trace
- 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/b3c633d2406d1922.
Report an issue: GitHub.