NationalSecurityAgency/ghidra · error · IllegalArgumentException
Trace must use a sleigh-based language
Error message
Trace must use a sleigh-based language
What it means
evaluateBytes(String expr, ...) compiles a Sleigh source expression on the trace's base language, then evaluates it. Compilation requires a SleighLanguage; if trace.getBaseLanguage() is any other Language subclass, it cannot compile and is rejected.
Source
Thrown at Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/pcode/exec/trace/TraceSleighUtils.java:225
Utils.bytesToBigInteger(bytes, bytes.length, expr.getLanguage().isBigEndian(), false),
bytesPair.getRight());
}
/**
* Evaluate a Sleigh expression on the given trace
*
* @param expr the expression
* @param trace the trace
* @param snap the snap
* @param thread the thread, required if register space is used
* @param frame the frame, for when register space is used
* @return the value of the expression as a byte array
*/
public static byte[] evaluateBytes(String expr, Trace trace, long snap, TraceThread thread,
int frame) {
Language language = trace.getBaseLanguage();
if (!(language instanceof SleighLanguage)) {
throw new IllegalArgumentException("Trace must use a sleigh-based language");
}
return evaluateBytes(
SleighProgramCompiler.compileExpression((SleighLanguage) language, expr),
trace, snap, thread, frame);
}
/**
* Evaluate a Sleigh expression on the given trace
*
* @param expr the expression
* @param trace the trace
* @param snap the snap
* @param thread the thread, required if register space is used
* @param frame the frame, for when register space is used
* @return the value of the expression as a big integer
*/
public static BigInteger evaluate(String expr, Trace trace, long snap, TraceThread thread,
int frame) {View on GitHub (pinned to d5f144c24d)
Solutions
- Ensure the trace's base language resolves to a SleighLanguage (correct LanguageID / .ldefs).
- Prefer the PcodeExpression overload and compile yourself only when you have confirmed a Sleigh language.
- Guard: `if (trace.getBaseLanguage() instanceof SleighLanguage)` before calling.
Example fix
// before
byte[] v = TraceSleighUtils.evaluateBytes("inst_start", trace, snap, thread, frame);
// after
if (!(trace.getBaseLanguage() instanceof SleighLanguage)) {
throw new IllegalStateException("trace language is not Sleigh: " + trace.getBaseLanguage());
}
byte[] v = TraceSleighUtils.evaluateBytes("inst_start", trace, snap, thread, frame); Defensive patterns
Strategy: validation
Validate before calling
if (!(trace.getBaseLanguage() instanceof SleighLanguage)) {
throw new IllegalStateException("trace not Sleigh: " + trace.getBaseLanguage());
}
byte[] v = TraceSleighUtils.evaluateBytes(exprText, trace, snap, thread, frame); Type guard
static boolean traceIsSleigh(Trace trace) {
return trace.getBaseLanguage() instanceof SleighLanguage;
} Try / catch
try {
return TraceSleighUtils.evaluateBytes(exprText, trace, snap, thread, frame);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("sleigh-based language")) {
// language is non-Sleigh; compute the value via direct register/memory reads instead
} else throw e;
} Prevention
- Confirm trace base language type before any Sleigh expression API.
- Prefer opening traces through the standard Sleigh-providing language service.
- Wrap TraceSleighUtils calls behind a facade that validates language type once.
When it happens
Trigger: Calling the String-expr evaluateBytes overload on a trace whose base language is not a SleighLanguage.
Common situations: Trace opened with a custom/non-Sleigh language provider. A trace recorded against an architecture Ghidra models without a Sleigh front-end. Programmatic traces built with a stub Language.
Related errors
- This expression can only be evaulated on traces with languag
- Sleigh language required
- Emulation requires a Sleigh language
- TracePlatform must use a Sleigh language
- Current trace does not use Sleigh
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/acb0d8f05d978011.
Report an issue: GitHub.