mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Merge remote-tracking branch 'origin/GP-1487_Dan_emuUnimpl--SQUASHED'
into Ghidra_10.1 Conflicts: Ghidra/Debug/Framework-TraceModeling/src/test/java/ghidra/pcode/exec/trace/TracePcodeEmulatorTest.java
This commit is contained in:
commit
6cc2eae322
3 changed files with 40 additions and 2 deletions
|
@ -983,4 +983,27 @@ public class TracePcodeEmulatorTest extends AbstractGhidraHeadlessIntegrationTes
|
||||||
emuThread.stepInstruction();
|
emuThread.stepInstruction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that unimplemented instructions (as opposed to instructions with no semantics) result in
|
||||||
|
* an interrupt.
|
||||||
|
*/
|
||||||
|
@Test(expected = PcodeExecutionException.class)
|
||||||
|
public void testUNIMPL() throws Throwable {
|
||||||
|
try (ToyDBTraceBuilder tb = new ToyDBTraceBuilder("Test", "Toy:BE:64:default")) {
|
||||||
|
assertEquals(Register.NO_CONTEXT, tb.language.getContextBaseRegister());
|
||||||
|
|
||||||
|
TraceThread thread = initTrace(tb,
|
||||||
|
List.of(
|
||||||
|
"pc = 0x00400000;",
|
||||||
|
"sp = 0x00110000;"),
|
||||||
|
List.of(
|
||||||
|
"unimpl"));
|
||||||
|
|
||||||
|
TracePcodeEmulator emu = new TracePcodeEmulator(tb.trace, 0);
|
||||||
|
PcodeThread<byte[]> emuThread = emu.newThread(thread.getPath());
|
||||||
|
emuThread.overrideContextWithDefault();
|
||||||
|
emuThread.stepInstruction();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,10 +122,22 @@ public class PcodeExecutor<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void badOp(PcodeOp op) {
|
||||||
|
switch (op.getOpcode()) {
|
||||||
|
case PcodeOp.UNIMPLEMENTED:
|
||||||
|
throw new LowlevelError(
|
||||||
|
"Encountered an unimplemented instruction at " + op.getSeqnum().getTarget());
|
||||||
|
default:
|
||||||
|
throw new LowlevelError(
|
||||||
|
"Unsupported p-code op at " + op.getSeqnum().getTarget() + ": " + op);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void stepOp(PcodeOp op, PcodeFrame frame, SleighUseropLibrary<T> library) {
|
public void stepOp(PcodeOp op, PcodeFrame frame, SleighUseropLibrary<T> library) {
|
||||||
OpBehavior b = OpBehaviorFactory.getOpBehavior(op.getOpcode());
|
OpBehavior b = OpBehaviorFactory.getOpBehavior(op.getOpcode());
|
||||||
if (b == null) {
|
if (b == null) {
|
||||||
throw new LowlevelError("Unsupported pcode op" + op);
|
badOp(op);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (b instanceof UnaryOpBehavior) {
|
if (b instanceof UnaryOpBehavior) {
|
||||||
executeUnaryOp(op, (UnaryOpBehavior) b);
|
executeUnaryOp(op, (UnaryOpBehavior) b);
|
||||||
|
@ -164,7 +176,8 @@ public class PcodeExecutor<T> {
|
||||||
executeReturn(op, frame);
|
executeReturn(op, frame);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
throw new LowlevelError("Unsupported op " + op);
|
badOp(op);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
# 1010 0100 ssss tttt # user_four rs rt user_four rs rt
|
# 1010 0100 ssss tttt # user_four rs rt user_four rs rt
|
||||||
# 1010 0101 nnnn nnnn # user_five n user_five n
|
# 1010 0101 nnnn nnnn # user_five n user_five n
|
||||||
# 1010 0110 ssss 0000 # user_six rs user_six rs
|
# 1010 0110 ssss 0000 # user_six rs user_six rs
|
||||||
|
# 1010 1000 0000 0000 # unimpl
|
||||||
#
|
#
|
||||||
#### RESERVED
|
#### RESERVED
|
||||||
# 1101 1001 xxxx xxxx # RESERVED BANK
|
# 1101 1001 xxxx xxxx # RESERVED BANK
|
||||||
|
@ -222,3 +223,4 @@ define pcodeop pcodeop_three;
|
||||||
:user_five Rel8 is $(INSTR_PHASE) op1215=0xa & op0811=0x05 & Rel8 { lr = inst_next; call Rel8; pcodeop_three();}
|
:user_five Rel8 is $(INSTR_PHASE) op1215=0xa & op0811=0x05 & Rel8 { lr = inst_next; call Rel8; pcodeop_three();}
|
||||||
:user_six rs is $(INSTR_PHASE) op1215=0xa & op0811=0x06 & rs & op0003=0x0 { r1 = pcodeop_one(rs); call [r1];}
|
:user_six rs is $(INSTR_PHASE) op1215=0xa & op0811=0x06 & rs & op0003=0x0 { r1 = pcodeop_one(rs); call [r1];}
|
||||||
|
|
||||||
|
:unimpl is $(INSTR_PHASE) op1215=0xa & op0811=0x08 & op0007=0 unimpl
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue