Merge remote-tracking branch 'origin/GP-1474_Dan_pcodeStepperShowDecoded--SQUASHED' into patch

This commit is contained in:
ghidra1
2022-01-06 11:44:19 -05:00
4 changed files with 35 additions and 1 deletions
@@ -52,6 +52,7 @@ import ghidra.pcode.exec.PcodeExecutorState;
import ghidra.pcode.exec.PcodeFrame;
import ghidra.program.model.data.DataType;
import ghidra.program.model.lang.Language;
import ghidra.program.model.listing.Instruction;
import ghidra.program.model.pcode.PcodeOp;
import ghidra.program.model.pcode.Varnode;
import ghidra.trace.model.Trace;
@@ -347,10 +348,11 @@ public class DebuggerPcodeStepperProvider extends ComponentProviderAdapter {
GhidraTable uniqueTable;
UniqueTableModel uniqueTableModel = new UniqueTableModel();
private GhidraTableFilterPanel<UniqueRow> uniqueFilterPanel;
GhidraTableFilterPanel<UniqueRow> uniqueFilterPanel;
GhidraTable pcodeTable;
PcodeTableModel pcodeTableModel = new PcodeTableModel();
JLabel instructionLabel;
// No filter panel on p-code
DockingAction actionStepBackward;
@@ -457,6 +459,8 @@ public class DebuggerPcodeStepperProvider extends ComponentProviderAdapter {
JPanel pcodePanel = new JPanel(new BorderLayout());
pcodeTable = new GhidraTable(pcodeTableModel);
pcodePanel.add(new JScrollPane(pcodeTable));
instructionLabel = new JLabel();
pcodePanel.add(instructionLabel, BorderLayout.NORTH);
mainPanel.setLeftComponent(pcodePanel);
JPanel uniquePanel = new JPanel(new BorderLayout());
@@ -620,6 +624,9 @@ public class DebuggerPcodeStepperProvider extends ComponentProviderAdapter {
}
protected void doLoadPcodeFrame() {
if (instructionLabel != null) {
instructionLabel.setText("(no instruction)");
}
if (emulationService == null) {
return;
}
@@ -660,6 +667,13 @@ public class DebuggerPcodeStepperProvider extends ComponentProviderAdapter {
populateSingleton(EnumPcodeRow.DECODE);
return;
}
Instruction instruction = thread.getInstruction();
if (instruction == null) {
instructionLabel.setText("(no instruction)");
}
else {
instructionLabel.setText(instruction.toString());
}
PcodeFrame frame = thread.getFrame();
if (frame == null) {
/**
@@ -28,6 +28,7 @@ import ghidra.pcode.emu.*;
import ghidra.pcode.exec.*;
import ghidra.program.model.address.Address;
import ghidra.program.model.lang.*;
import ghidra.program.model.listing.Instruction;
import ghidra.test.AbstractGhidraHeadlessIntegrationTest;
import ghidra.test.ToyProgramBuilder;
import ghidra.trace.database.ToyDBTraceBuilder;
@@ -333,6 +334,11 @@ public class TraceScheduleTest extends AbstractGhidraHeadlessIntegrationTest {
public PcodeFrame getFrame() {
return null;
}
@Override
public Instruction getInstruction() {
return null;
}
@Override
public void executeInstruction() {
@@ -284,6 +284,7 @@ public class DefaultPcodeThread<T> implements PcodeThread<T> {
}
postExecuteInstruction();
frame = null;
instruction = null;
}
@Override
@@ -291,6 +292,11 @@ public class DefaultPcodeThread<T> implements PcodeThread<T> {
return frame;
}
@Override
public Instruction getInstruction() {
return instruction;
}
protected void assertCompletedInstruction() {
if (frame != null) {
throw new IllegalStateException("The current instruction or inject has not finished.");
@@ -22,6 +22,7 @@ import ghidra.pcode.emu.DefaultPcodeThread.SleighEmulationLibrary;
import ghidra.pcode.exec.*;
import ghidra.program.model.address.Address;
import ghidra.program.model.lang.RegisterValue;
import ghidra.program.model.listing.Instruction;
/**
* An emulated thread of execution
@@ -157,6 +158,13 @@ public interface PcodeThread<T> {
*/
PcodeFrame getFrame();
/**
* Get the current decoded instruction, if applicable
*
* @return the instruction
*/
Instruction getInstruction();
/**
* Execute the next instruction, ignoring injects
*