{"record":{"id":"dcd35bc4d2e0c2e0","repo":"NationalSecurityAgency/ghidra","slug":"cannot-emulate-using-a-fixed-program-view","errorCode":null,"errorMessage":"Cannot emulate using a Fixed Program View","messagePattern":"Cannot emulate using a Fixed Program View","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/control/ControlMode.java","lineNumber":315,"sourceCode":"\t\t\t\treturn false;\n\t\t\t}\n\t\t\t// TODO: Limitation from using Sleigh for patching\n\t\t\tRegister ctxReg = coordinates.getTrace().getBaseLanguage().getContextBaseRegister();\n\t\t\tif (ctxReg == Register.NO_CONTEXT) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tAddressRange ctxRange = TraceRegisterUtils.rangeForRegister(ctxReg);\n\t\t\tif (ctxRange.contains(address)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\t@Override\n\t\tpublic CompletableFuture<Void> setVariable(PluginTool tool,\n\t\t\t\tDebuggerCoordinates coordinates, Address address, byte[] data) {\n\t\t\tif (!(coordinates.getView() instanceof TraceVariableSnapProgramView)) {\n\t\t\t\tthrow new IllegalArgumentException(\"Cannot emulate using a Fixed Program View\");\n\t\t\t}\n\t\t\tTraceThread thread = coordinates.getThread();\n\t\t\tif (thread == null) {\n\t\t\t\t// TODO: Well, technically, only for register edits\n\t\t\t\t// It's a limitation in TraceSchedule. Every step requires a thread\n\t\t\t\tthrow new IllegalArgumentException(\"Emulator edits require a thread.\");\n\t\t\t}\n\t\t\tLanguage language = coordinates.getPlatform().getLanguage();\n\t\t\tTraceSchedule time = coordinates.getTime()\n\t\t\t\t\t.patched(thread, language,\n\t\t\t\t\t\tPatchStep.generateSleigh(language, address, data));\n\n\t\t\tDebuggerCoordinates withTime = coordinates.time(time);\n\t\t\tDebuggerTraceManagerService traceManager =\n\t\t\t\tObjects.requireNonNull(tool.getService(DebuggerTraceManagerService.class),\n\t\t\t\t\t\"No trace manager service\");\n\n\t\t\treturn traceManager.activateAndNotify(withTime, ActivationCause.EMU_STATE_EDIT);","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/control/ControlMode.java#L297-L333","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Navigate to the present/emulated snapshot so the view is a TraceVariableSnapProgramView before editing.","Use RW_TRACE mode if you need to edit a fixed (recorded) snapshot directly.","Confirm coordinates.getView() instanceof TraceVariableSnapProgramView before issuing an emulator edit."],"exampleFix":"// before\nRW_EMULATOR.setVariable(tool, coordinates, address, data);  // fixed view\n\n// after\n// navigate to the emulated present first, or:\nRW_TRACE.setVariable(tool, coordinates, address, data);","handlingStrategy":"type-guard","validationCode":"if (!(coordinates.getView() instanceof TraceVariableSnapProgramView)) {\n    throw new IllegalStateException(\"emulator edits need a variable view; use RW_TRACE or navigate to present\");\n}","typeGuard":"boolean isEmuEditableView(DebuggerCoordinates c) {\n    return c.getView() instanceof TraceVariableSnapProgramView;\n}","tryCatchPattern":"try {\n    RW_EMULATOR.setVariable(tool, coordinates, address, data);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Fixed Program View\")) {\n        RW_TRACE.setVariable(tool, coordinates, address, data);\n    } else throw e;\n}","preventionTips":["Navigate to the emulated present before using RW_EMULATOR edits.","Fall back to RW_TRACE for fixed/recorded snapshots.","Pre-check the view type before issuing an emulator edit."],"tags":["control-mode","emulator","program-view","trace","java"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}