NationalSecurityAgency/ghidra · error · IllegalArgumentException

Cannot emulate using a Fixed Program View

Error message

Cannot emulate using a Fixed Program View

What it means

Thrown as IllegalArgumentException by RW_EMULATOR.setVariable (ControlMode.java:314-316) when coordinates.getView() is not a TraceVariableSnapProgramView. Emulator (Control Emulator) mode applies edits by appending patch steps to a schedule, which requires a variable (emulate-able) program view; a fixed snapshot view cannot be patched.

Source

Thrown at Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/control/ControlMode.java:315

				return false;
			}
			// TODO: Limitation from using Sleigh for patching
			Register ctxReg = coordinates.getTrace().getBaseLanguage().getContextBaseRegister();
			if (ctxReg == Register.NO_CONTEXT) {
				return true;
			}
			AddressRange ctxRange = TraceRegisterUtils.rangeForRegister(ctxReg);
			if (ctxRange.contains(address)) {
				return false;
			}
			return true;
		}

		@Override
		public CompletableFuture<Void> setVariable(PluginTool tool,
				DebuggerCoordinates coordinates, Address address, byte[] data) {
			if (!(coordinates.getView() instanceof TraceVariableSnapProgramView)) {
				throw new IllegalArgumentException("Cannot emulate using a Fixed Program View");
			}
			TraceThread thread = coordinates.getThread();
			if (thread == null) {
				// TODO: Well, technically, only for register edits
				// It's a limitation in TraceSchedule. Every step requires a thread
				throw new IllegalArgumentException("Emulator edits require a thread.");
			}
			Language language = coordinates.getPlatform().getLanguage();
			TraceSchedule time = coordinates.getTime()
					.patched(thread, language,
						PatchStep.generateSleigh(language, address, data));

			DebuggerCoordinates withTime = coordinates.time(time);
			DebuggerTraceManagerService traceManager =
				Objects.requireNonNull(tool.getService(DebuggerTraceManagerService.class),
					"No trace manager service");

			return traceManager.activateAndNotify(withTime, ActivationCause.EMU_STATE_EDIT);

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Navigate to the present/emulated snapshot so the view is a TraceVariableSnapProgramView before editing.
  2. Use RW_TRACE mode if you need to edit a fixed (recorded) snapshot directly.
  3. Confirm coordinates.getView() instanceof TraceVariableSnapProgramView before issuing an emulator edit.

Example fix

// before
RW_EMULATOR.setVariable(tool, coordinates, address, data);  // fixed view

// after
// navigate to the emulated present first, or:
RW_TRACE.setVariable(tool, coordinates, address, data);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(coordinates.getView() instanceof TraceVariableSnapProgramView)) {
    throw new IllegalStateException("emulator edits need a variable view; use RW_TRACE or navigate to present");
}

Type guard

boolean isEmuEditableView(DebuggerCoordinates c) {
    return c.getView() instanceof TraceVariableSnapProgramView;
}

Try / catch

try {
    RW_EMULATOR.setVariable(tool, coordinates, address, data);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("Fixed Program View")) {
        RW_TRACE.setVariable(tool, coordinates, address, data);
    } else throw e;
}

Prevention

When it happens

Trigger: Switching to RW_EMULATOR mode and editing a variable while the active view is a Trace fixed view (e.g. a recorded snapshot that is not the emulated present). The instanceof check fails.

Common situations: The user navigated to a historical/recorded snapshot (fixed view) then attempted an emulator edit; a trace opened without emulator support; coordinates referencing a non-variable view.

Related errors


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