{"record":{"id":"da3f8e2b0da6a06a","repo":"NationalSecurityAgency/ghidra","slug":"sleigh-language-required","errorCode":null,"errorMessage":"Sleigh language required","messagePattern":"Sleigh language required","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/emulation/DebuggerEmulateFunctionDialog.java","lineNumber":202,"sourceCode":"\t\t@Override\n\t\tpublic ActionContext getActionContext(MouseEvent e) {\n\t\t\treturn new OutputActionContext(outputsFilterPanel.getSelectedItems());\n\t\t}\n\t};\n\n\tprotected final DomainObjectListener listenerForFunction = new DomainObjectListenerBuilder(this)\n\t\t\t.any(DomainObjectEvent.RESTORED)\n\t\t\t.terminate(inputActions::contextChanged)\n\t\t\t.with(FunctionChangeRecord.class)\n\t\t\t.each(ProgramEvent.FUNCTION_CHANGED)\n\t\t\t.call(this::functionChanged)\n\t\t\t.build();\n\n\tpublic DebuggerEmulateFunctionDialog(PluginTool tool, Function function) {\n\t\tsuper(\"Emulate %s of %s\".formatted(function.getName(), function.getProgram().getName()),\n\t\t\tfalse, true, true, true);\n\t\tif (!(function.getProgram().getLanguage() instanceof SleighLanguage language)) {\n\t\t\tthrow new IllegalArgumentException(\"Sleigh language required\");\n\t\t}\n\t\tthis.tool = tool;\n\t\tthis.function = function;\n\t\tthis.language = language;\n\n\t\tinputsTableModel = new InputsTableModel(tool, this);\n\t\toutputsTableModel = new OutputsTableModel(tool, this);\n\n\t\tinputsTableModel.addTableModelListener(evt -> {\n\t\t\tinputActions.contextChanged();\n\t\t});\n\t\toutputsTableModel.addTableModelListener(evt -> {\n\t\t\toutputActions.contextChanged();\n\t\t});\n\n\t\tsentinel = language.getDefaultSpace().getAddress(0xdeadbeef);\n\t\tsnapshotPeriod = 1;\n\t\tnextAlloc = language.getDefaultDataSpace().getAddress(0x7beef000);","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/emulation/DebuggerEmulateFunctionDialog.java#L184-L220","documentation":"Thrown by the DebuggerEmulateFunctionDialog constructor when the selected Function's program is not backed by a SleighLanguage. SleighLanguage is Ghidra's p-code processor specification; the emulator and the dialog's VarStorage/executor machinery all depend on it. Non-Sleigh Language implementations (legacy or custom) cannot drive p-code emulation, so the dialog refuses to open.","triggerScenarios":"Invoking the 'Emulate Function' action/dialog on a Function whose Program was imported or synthesized with a Language that is not an instance of ghidra.app.plugin.processors.sleigh.SleighLanguage.","commonSituations":"Loading a program built on an obsolete/legacy processor module that predates Sleigh; using a hand-rolled or stub Language implementation in tests; opening emulation on a synthetic DomainObject whose language was set programmatically to a non-Sleigh subclass.","solutions":["Re-import the program with a current Sleigh-based processor specification (.pspec/.sleigh) so its Language is a SleighLanguage.","Verify via function.getProgram().getLanguage() instanceof SleighLanguage before launching the emulation dialog, and warn the user instead of constructing it.","If working with a custom processor, ensure its Language implementation extends SleighLanguage.","Skip the Emulate Function action for programs known to use non-Sleigh languages."],"exampleFix":"// before\nnew DebuggerEmulateFunctionDialog(tool, function); // throws if non-Sleigh\n\n// after\nif (function.getProgram().getLanguage() instanceof SleighLanguage) {\n    new DebuggerEmulateFunctionDialog(tool, function);\n} else {\n    Msg.showWarn(this, null, \"Cannot Emulate\",\n        \"Emulation requires a program using a Sleigh language.\");\n}","handlingStrategy":"type-guard","validationCode":"boolean canEmulate = function.getProgram().getLanguage() instanceof SleighLanguage;","typeGuard":"static boolean isSleigh(Function f) {\n    return f.getProgram().getLanguage() instanceof SleighLanguage;\n}","tryCatchPattern":"try {\n    new DebuggerEmulateFunctionDialog(tool, function);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Sleigh language\")) {\n        Msg.showWarn(this, null, \"Cannot Emulate\", e.getMessage());\n    } else throw e;\n}","preventionTips":["Filter the Emulate Function action so it only appears for Sleigh-backed programs.","Cache the language check when the program is loaded."],"tags":["emulation","sleigh","language","precondition"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}