NationalSecurityAgency/ghidra · error · IllegalArgumentException

Emulation requires a Sleigh language

Error message

Emulation requires a Sleigh language

What it means

Thrown by LocAndVal.buildExecutor when the TracePlatform's Language is not a SleighLanguage. The p-code executor required for emulation/emulation inspection is constructed from a SleighLanguage, so any platform using a legacy or non-Sleigh language cannot build an executor.

Source

Thrown at Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/emulation/LocAndVal.java:260

		PcodeTraceDataAccess data = new DefaultPcodeTraceAccess(coordinates.getPlatform(),
			coordinates.getViewSnap(), coordinates.getSnap())
					.getDataForThreadState(coordinates.getThread(), coordinates.getFrame());
		// Seems weird, but RO is in terms of the Target. RO writes the Trace.
		DebuggerPcodeUtils.WriterAndState ws =
			DebuggerPcodeUtils.executorStateForCoordinates(provider, coordinates, Mode.RO);
		return new WriterAndState(ws.writer(),
			new LocAndValPcodeExecutorState(new LocAndValPcodeExecutorStatePiece(ws.state(),
				new LocationPcodeExecutorStatePiece(data.getLanguage()))));
	}

	public record WriterAndExecutor(Writer writer, PcodeExecutor<LocAndVal> executor) {}

	public static WriterAndExecutor buildExecutor(ServiceProvider provider,
			DebuggerCoordinates coordinates) {
		TracePlatform platform = coordinates.getPlatform();
		Language language = platform.getLanguage();
		if (!(language instanceof SleighLanguage slang)) {
			throw new IllegalArgumentException("Emulation requires a Sleigh language");
		}
		WriterAndState ws = buildState(provider, coordinates);
		return new WriterAndExecutor(ws.writer,
			new PcodeExecutor<>(slang, ws.state.getArithmetic(), ws.state, Reason.INSPECT));
	}
}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Ensure the trace's platform is bound to a program imported with a Sleigh-based processor spec.
  2. Guard the call: check platform.getLanguage() instanceof SleighLanguage before buildExecutor.
  3. Re-import the target binary with a current processor module so the platform resolves a SleighLanguage.
  4. Disable emulation/inspection features for non-Sleigh platforms.

Example fix

// before
WriterAndExecutor we = LocAndVal.buildExecutor(provider, coordinates); // throws

// after
Language lang = coordinates.getPlatform().getLanguage();
if (!(lang instanceof SleighLanguage)) {
    throw new IllegalStateException("Platform language is not Sleigh: " + lang);
}
WriterAndExecutor we = LocAndVal.buildExecutor(provider, coordinates);
Defensive patterns

Strategy: type-guard

Validate before calling

Language lang = coordinates.getPlatform().getLanguage();
boolean ok = lang instanceof SleighLanguage;

Type guard

static boolean platformIsSleigh(TracePlatform p) {
    return p.getLanguage() instanceof SleighLanguage;
}

Try / catch

try {
    LocAndVal.buildExecutor(provider, coordinates);
} catch (IllegalArgumentException e) {
    Msg.showWarn(this, null, "Cannot emulate", e.getMessage());
}

Prevention

When it happens

Trigger: Calling LocAndVal.buildExecutor(provider, coordinates) where coordinates.getPlatform().getLanguage() is not an instance of SleighLanguage.

Common situations: Selecting a platform/trace whose underlying program uses an old processor module; traces recorded against non-Sleigh language specs; programmatic emulation on a platform configured without a Sleigh language.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/3d501f6ff744a66f. Report an issue: GitHub.