{"record":{"id":"3d501f6ff744a66f","repo":"NationalSecurityAgency/ghidra","slug":"emulation-requires-a-sleigh-language","errorCode":null,"errorMessage":"Emulation requires a Sleigh language","messagePattern":"Emulation requires a Sleigh language","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/emulation/LocAndVal.java","lineNumber":260,"sourceCode":"\t\tPcodeTraceDataAccess data = new DefaultPcodeTraceAccess(coordinates.getPlatform(),\n\t\t\tcoordinates.getViewSnap(), coordinates.getSnap())\n\t\t\t\t\t.getDataForThreadState(coordinates.getThread(), coordinates.getFrame());\n\t\t// Seems weird, but RO is in terms of the Target. RO writes the Trace.\n\t\tDebuggerPcodeUtils.WriterAndState ws =\n\t\t\tDebuggerPcodeUtils.executorStateForCoordinates(provider, coordinates, Mode.RO);\n\t\treturn new WriterAndState(ws.writer(),\n\t\t\tnew LocAndValPcodeExecutorState(new LocAndValPcodeExecutorStatePiece(ws.state(),\n\t\t\t\tnew LocationPcodeExecutorStatePiece(data.getLanguage()))));\n\t}\n\n\tpublic record WriterAndExecutor(Writer writer, PcodeExecutor<LocAndVal> executor) {}\n\n\tpublic static WriterAndExecutor buildExecutor(ServiceProvider provider,\n\t\t\tDebuggerCoordinates coordinates) {\n\t\tTracePlatform platform = coordinates.getPlatform();\n\t\tLanguage language = platform.getLanguage();\n\t\tif (!(language instanceof SleighLanguage slang)) {\n\t\t\tthrow new IllegalArgumentException(\"Emulation requires a Sleigh language\");\n\t\t}\n\t\tWriterAndState ws = buildState(provider, coordinates);\n\t\treturn new WriterAndExecutor(ws.writer,\n\t\t\tnew PcodeExecutor<>(slang, ws.state.getArithmetic(), ws.state, Reason.INSPECT));\n\t}\n}\n","sourceCodeStart":242,"sourceCodeEnd":267,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/emulation/LocAndVal.java#L242-L267","documentation":"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.","triggerScenarios":"Calling LocAndVal.buildExecutor(provider, coordinates) where coordinates.getPlatform().getLanguage() is not an instance of SleighLanguage.","commonSituations":"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.","solutions":["Ensure the trace's platform is bound to a program imported with a Sleigh-based processor spec.","Guard the call: check platform.getLanguage() instanceof SleighLanguage before buildExecutor.","Re-import the target binary with a current processor module so the platform resolves a SleighLanguage.","Disable emulation/inspection features for non-Sleigh platforms."],"exampleFix":"// before\nWriterAndExecutor we = LocAndVal.buildExecutor(provider, coordinates); // throws\n\n// after\nLanguage lang = coordinates.getPlatform().getLanguage();\nif (!(lang instanceof SleighLanguage)) {\n    throw new IllegalStateException(\"Platform language is not Sleigh: \" + lang);\n}\nWriterAndExecutor we = LocAndVal.buildExecutor(provider, coordinates);","handlingStrategy":"type-guard","validationCode":"Language lang = coordinates.getPlatform().getLanguage();\nboolean ok = lang instanceof SleighLanguage;","typeGuard":"static boolean platformIsSleigh(TracePlatform p) {\n    return p.getLanguage() instanceof SleighLanguage;\n}","tryCatchPattern":"try {\n    LocAndVal.buildExecutor(provider, coordinates);\n} catch (IllegalArgumentException e) {\n    Msg.showWarn(this, null, \"Cannot emulate\", e.getMessage());\n}","preventionTips":["Gate emulation features on a Sleigh language check at platform selection.","Avoid non-Sleigh platforms for emulation workflows."],"tags":["emulation","sleigh","language","platform","precondition"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}