{"record":{"id":"38f465ccebffd6fa","repo":"NationalSecurityAgency/ghidra","slug":"encountered-an-unimplemented-instruction-at","errorCode":null,"errorMessage":"Encountered an unimplemented instruction at {}","messagePattern":"Encountered an unimplemented instruction at (.+?)","errorType":"exception","errorClass":"LowlevelError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/ProposedUtils/src/main/java/ghidra/pcode/eval/AbstractVarnodeEvaluator.java","lineNumber":424,"sourceCode":"\t\t\tcase PcodeOp.PTRADD:\n\t\t\t\treturn evaluatePtrAdd(program, op, already);\n\t\t\tcase PcodeOp.PTRSUB:\n\t\t\t\treturn evaluatePtrSub(program, op, already);\n\t\t\tdefault:\n\t\t\t\treturn badOp(op);\n\t\t}\n\t}\n\n\t/**\n\t * The method invoked when an unrecognized or unsupported operator is encountered\n\t * \n\t * @param op the op\n\t * @return the value, but this usually throws an exception\n\t */\n\tprotected T badOp(PcodeOp op) {\n\t\tswitch (op.getOpcode()) {\n\t\t\tcase PcodeOp.UNIMPLEMENTED:\n\t\t\t\tthrow new LowlevelError(\n\t\t\t\t\t\"Encountered an unimplemented instruction at \" +\n\t\t\t\t\t\top.getSeqnum().getTarget());\n\t\t\tdefault:\n\t\t\t\tthrow new LowlevelError(\n\t\t\t\t\t\"Unsupported p-code op at \" + op.getSeqnum().getTarget() + \": \" + op);\n\t\t}\n\t}\n}\n","sourceCodeStart":406,"sourceCodeEnd":433,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/pcode/eval/AbstractVarnodeEvaluator.java#L406-L433","documentation":"Thrown (unchecked LowlevelError) by badOp() when the p-code op's opcode is PcodeOp.UNIMPLEMENTED, meaning the underlying machine instruction is not implemented in the processor's SLEIGH language spec. The message includes the instruction's target address for diagnosis. This is a tooling/data limitation, not a logic bug in your code.","triggerScenarios":"Evaluating p-code where an instruction translates to an UNIMPLEMENTED op because the SLEIGH specification for the target processor does not provide semantics for that instruction. Encountered when emulating or symbolically executing binaries for architectures with incomplete instruction coverage.","commonSituations":"Emulating code for an architecture whose p-code spec is partial; stepping into vendor-specific or privileged instructions the spec marks UNIMPLEMENTED; analyzing a binary that uses an instruction variant the language module doesn't model.","solutions":["Confirm the target processor language module supports the instruction; switch to a more complete SLEIGH spec if available.","Catch LowlevelError around emulation of a region and skip/handle the unimplemented instruction (e.g. treat as no-op or unsupported block).","If you maintain the language spec, add the missing p-code semantics for that instruction.","Restrict analysis to instruction sequences known to be fully implemented."],"exampleFix":"// before\nT out = evaluator.evaluateOp(program, op, cache); // LowlevelError on UNIMPLEMENTED\n\n// after: skip unimplemented instructions explicitly\nif (op.getOpcode() == PcodeOp.UNIMPLEMENTED) {\n    return unsupportedMarker(op);\n}\nT out = evaluator.evaluateOp(program, op, cache);","handlingStrategy":"try-catch","validationCode":"// Skip UNIMPLEMENTED ops instead of evaluating them\nif (op.getOpcode() == PcodeOp.UNIMPLEMENTED) {\n    // instruction not modelled in the SLEIGH spec; skip or mark unsupported\n}","typeGuard":null,"tryCatchPattern":"try {\n    T out = evaluator.evaluateOp(program, op, cache);\n} catch (LowlevelError e) {\n    if (e.getMessage().startsWith(\"Encountered an unimplemented instruction\")) { /* skip region */ }\n    else throw e;\n}","preventionTips":["Use a processor language spec that covers the target instruction set.","Catch LowlevelError around emulation regions to skip unimplemented instructions.","Restrict analysis to fully-implemented instruction sequences."],"tags":["pcode","emulation","unimplemented-instruction","sleigh","lowlevel-error","unchecked-exception"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}