mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-01-31 13:31:08 +00:00
Added P-Code Test framework to facilitate semantic verification through
emulation
This commit is contained in:
parent
7c5523362c
commit
dd15435371
@ -33,6 +33,7 @@ data/parserprofiles/linux_32.prf||GHIDRA||||END|
|
||||
data/parserprofiles/linux_64.prf||GHIDRA||||END|
|
||||
data/parserprofiles/objc_mac_carbon.prf||GHIDRA||reviewed||END|
|
||||
data/parserprofiles/vs12Local.prf||GHIDRA||||END|
|
||||
data/pcodetest/EmuTesting.gdt||GHIDRA||||END|
|
||||
data/stringngrams/StringModel.sng||GHIDRA||reviewed||END|
|
||||
data/symbols/win32/kernel32.hints||GHIDRA||||END|
|
||||
data/symbols/win32/mfc100.exports||GHIDRA||||END|
|
||||
@ -1179,6 +1180,10 @@ src/main/resources/images/xor.png||GHIDRA||||END|
|
||||
src/main/resources/images/zoom.png||FAMFAMFAM Icons - CC 2.5|||silk|END|
|
||||
src/main/resources/images/zoom_in.png||FAMFAMFAM Icons - CC 2.5|||silk|END|
|
||||
src/main/resources/images/zoom_out.png||FAMFAMFAM Icons - CC 2.5|||silk|END|
|
||||
src/main/resources/pcodetest/chunk1.hinc||GHIDRA||||END|
|
||||
src/main/resources/pcodetest/chunk2.hinc||GHIDRA||||END|
|
||||
src/main/resources/pcodetest/chunk3.hinc||GHIDRA||||END|
|
||||
src/main/resources/pcodetest/chunk4.hinc||GHIDRA||||END|
|
||||
src/test.slow/resources/dirlist.txt||GHIDRA||reviewed||END|
|
||||
src/test.slow/resources/filterTestDirList.txt||GHIDRA||||END|
|
||||
src/test.slow/resources/ghidra/app/plugin/core/datamgr/TestDataType.txt||GHIDRA||||END|
|
||||
|
BIN
Ghidra/Features/Base/data/pcodetest/EmuTesting.gdt
Normal file
BIN
Ghidra/Features/Base/data/pcodetest/EmuTesting.gdt
Normal file
Binary file not shown.
@ -34,7 +34,7 @@ import ghidra.program.model.mem.Memory;
|
||||
public class SearchBaseExtended extends GhidraScript {
|
||||
|
||||
//holds the mask and value for all the mnemonics, or commands like cmp, jmp, jnz etc
|
||||
ArrayList<Case> mnemonics = new ArrayList<Case>();
|
||||
ArrayList<Case> mnemonics = new ArrayList<>();
|
||||
|
||||
/*
|
||||
* Holds the masks and values for all the operands. The arraylist portion will correspond to the operand number. An example is
|
||||
@ -44,13 +44,13 @@ public class SearchBaseExtended extends GhidraScript {
|
||||
* operand. I set it up this was to conserve memory and allow for a dynamically growing collection.
|
||||
*/
|
||||
ArrayList<LinkedHashMap<Case, OperandCase>> ops =
|
||||
new ArrayList<LinkedHashMap<Case, OperandCase>>();//holds masks and values for all operands.
|
||||
new ArrayList<>();//holds masks and values for all operands.
|
||||
|
||||
ArrayList<Case> db = new ArrayList<Case>();//holds the search results.
|
||||
ArrayList<Case> db = new ArrayList<>();//holds the search results.
|
||||
|
||||
//These control the detail at which a scan is performed.
|
||||
//They determine how specific the instructions must match the currently selected ones
|
||||
ArrayList<SLMaskControl> controlList = new ArrayList<SLMaskControl>();
|
||||
ArrayList<SLMaskControl> controlList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
@ -59,7 +59,7 @@ public class SearchBaseExtended extends GhidraScript {
|
||||
}
|
||||
|
||||
public void run(boolean mneonics, boolean op1, boolean op2, boolean constants) {
|
||||
controlList = new ArrayList<SLMaskControl>();
|
||||
controlList = new ArrayList<>();
|
||||
controlList.add(new SLMaskControl(mneonics, op1, op2, constants));
|
||||
loadSelectedInstructions();
|
||||
executeSearch();
|
||||
@ -72,11 +72,11 @@ public class SearchBaseExtended extends GhidraScript {
|
||||
}
|
||||
|
||||
public void clearResults() {
|
||||
db = new ArrayList<Case>();
|
||||
db = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setState(SLMaskControl newState) {
|
||||
controlList = new ArrayList<SLMaskControl>();
|
||||
controlList = new ArrayList<>();
|
||||
controlList.add(newState);
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ public class SearchBaseExtended extends GhidraScript {
|
||||
mnemonics.add(tCase); //adds the mnemonic mask and value to the arraylist
|
||||
|
||||
//Gets a code unit which can be used to determine if the operands are constants.
|
||||
CodeUnit cUnit = list.getCodeUnitAt(tempAddr);
|
||||
CodeUnit cu = list.getCodeUnitAt(tempAddr);
|
||||
|
||||
//Iterates through all the operands for the currently selected instruction and stores them accordingly
|
||||
for (int x = 1; x <= logger.getNumOperands(); x++) {
|
||||
@ -156,7 +156,7 @@ public class SearchBaseExtended extends GhidraScript {
|
||||
otCase.textRep = tempIns.getDefaultOperandRepresentation(x - 1);
|
||||
|
||||
//Determines if the given operand is a constant value. If it is a constant then proper flag is set.
|
||||
if (cUnit.getScalar(x - 1) != null) {
|
||||
if (cu.getScalar(x - 1) != null) {
|
||||
otCase.constant = true;
|
||||
}
|
||||
|
||||
@ -321,8 +321,8 @@ public class SearchBaseExtended extends GhidraScript {
|
||||
ArrayList<LinkedHashMap<Case, OperandCase>> localOperands,
|
||||
ArrayList<SLMaskControl> control) {
|
||||
|
||||
ArrayList<byte[]> masks = new ArrayList<byte[]>();
|
||||
ArrayList<byte[]> values = new ArrayList<byte[]>();
|
||||
ArrayList<byte[]> masks = new ArrayList<>();
|
||||
ArrayList<byte[]> values = new ArrayList<>();
|
||||
|
||||
//used for storing the byte stream currently being work on prior to being added to final data structure
|
||||
int totalLength = 0;
|
||||
|
@ -770,7 +770,7 @@ public class TestEnv {
|
||||
* Open a read-only test program from the test data directory.
|
||||
* This program must be released prior to disposing this test environment.
|
||||
* NOTE: Some tests rely on this method returning null when file does
|
||||
* not yet exist within the resource area (e.g., CUnit binaries for Processor Tests)
|
||||
* not yet exist within the resource area (e.g., test binaries for P-Code Tests)
|
||||
*
|
||||
* @param programName name of program database within the test data directory.
|
||||
* @return program or null if program file not found
|
||||
|
@ -57,7 +57,7 @@ public class TestProgramManager {
|
||||
* Open a read-only test program from the test data directory.
|
||||
* This program must be released prior to disposing this test environment.
|
||||
* NOTE: Some tests rely on this method returning null when file does
|
||||
* not yet exist within the resource area (e.g., CUnit binaries for Processor Tests)
|
||||
* not yet exist within the resource area (e.g., test binaries for P-Code Tests)
|
||||
*
|
||||
* @param progName name of program database within the test data directory.
|
||||
* @return program or null if program file not found
|
||||
|
@ -0,0 +1,704 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors.support;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
|
||||
import generic.timer.GhidraSwinglessTimer;
|
||||
import generic.timer.TimerCallback;
|
||||
import ghidra.app.emulator.*;
|
||||
import ghidra.pcode.emulate.BreakCallBack;
|
||||
import ghidra.pcode.emulate.EmulateExecutionState;
|
||||
import ghidra.pcode.error.LowlevelError;
|
||||
import ghidra.pcode.memstate.MemoryFaultHandler;
|
||||
import ghidra.pcode.pcoderaw.PcodeOpRaw;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSpace;
|
||||
import ghidra.program.model.lang.Register;
|
||||
import ghidra.program.model.lang.RegisterValue;
|
||||
import ghidra.program.model.listing.Instruction;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.pcode.Varnode;
|
||||
import ghidra.test.processors.support.PCodeTestAbstractControlBlock.FunctionInfo;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.StringUtilities;
|
||||
import ghidra.util.exception.AssertException;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public class EmulatorTestRunner {
|
||||
|
||||
private Program program;
|
||||
private PCodeTestGroup testGroup;
|
||||
|
||||
private EmulatorHelper emuHelper;
|
||||
private Emulator emu;
|
||||
private ExecutionListener executionListener;
|
||||
|
||||
private volatile boolean haltedOnTimer = false;
|
||||
private String lastError;
|
||||
private int callOtherErrors; // only incremented on pass with callOtherCount != 0
|
||||
private int callOtherCount;
|
||||
|
||||
private TreeSet<String> unimplementedSet = new TreeSet<>();
|
||||
|
||||
private HashMap<Address, List<DumpPoint>> dumpPointMap = new HashMap<>();
|
||||
|
||||
public EmulatorTestRunner(Program program, PCodeTestGroup testGroup,
|
||||
ExecutionListener executionListener) {
|
||||
this.program = program;
|
||||
this.testGroup = testGroup;
|
||||
this.executionListener = executionListener;
|
||||
emuHelper = new EmulatorHelper(program);
|
||||
emu = emuHelper.getEmulator();
|
||||
emuHelper.setMemoryFaultHandler(new MyMemoryFaultHandler(executionListener));
|
||||
|
||||
emuHelper.registerDefaultCallOtherCallback(new BreakCallBack() {
|
||||
@Override
|
||||
public boolean pcodeCallback(PcodeOpRaw op) throws LowlevelError {
|
||||
int userOp = (int) op.getInput(0).getOffset();
|
||||
String pcodeOpName = emulate.getLanguage().getUserDefinedOpName(userOp);
|
||||
unimplementedSet.add(pcodeOpName);
|
||||
String outStr = "";
|
||||
Varnode output = op.getOutput();
|
||||
if (output != null) {
|
||||
outStr = ", unable to set output " + output.toString(program.getLanguage());
|
||||
}
|
||||
EmulatorTestRunner.this.executionListener.log(testGroup, "Unimplemented pcodeop '" +
|
||||
pcodeOpName + "' at: " + emu.getExecuteAddress() + outStr);
|
||||
++callOtherCount;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
emuHelper.dispose();
|
||||
emu = null;
|
||||
program = null;
|
||||
executionListener = null;
|
||||
testGroup = null;
|
||||
}
|
||||
|
||||
Set<String> getUnimplementedPcodeops() {
|
||||
return unimplementedSet;
|
||||
}
|
||||
|
||||
public PCodeTestGroup getTestGroup() {
|
||||
return testGroup;
|
||||
}
|
||||
|
||||
public Program getProgram() {
|
||||
return program;
|
||||
}
|
||||
|
||||
public EmulatorHelper getEmulatorHelper() {
|
||||
return emuHelper;
|
||||
}
|
||||
|
||||
public void setContextRegister(RegisterValue ctxRegValue) {
|
||||
emuHelper.setContextRegister(ctxRegValue);
|
||||
}
|
||||
|
||||
public Address getCurrentAddress() {
|
||||
return emuHelper.getExecutionAddress();
|
||||
}
|
||||
|
||||
public Instruction getCurrentInstruction() {
|
||||
// TODO: Pull instruction from emulator instead of program after
|
||||
// merge with SleighRefactor branch
|
||||
return program.getListing().getInstructionAt(emu.getExecuteAddress());
|
||||
}
|
||||
|
||||
private void flipBytes(byte[] bytes) {
|
||||
for (int i = 0; i < bytes.length / 2; i++) {
|
||||
byte b = bytes[i];
|
||||
int otherIndex = bytes.length - i - 1;
|
||||
bytes[i] = bytes[otherIndex];
|
||||
bytes[otherIndex] = b;
|
||||
}
|
||||
}
|
||||
|
||||
public RegisterValue getRegisterValue(Register reg) {
|
||||
Register baseReg = reg.getBaseRegister();
|
||||
byte[] bytes = emuHelper.readMemory(baseReg.getAddress(), baseReg.getMinimumByteSize());
|
||||
if (!reg.isBigEndian()) {
|
||||
flipBytes(bytes);
|
||||
}
|
||||
byte[] maskValue = new byte[2 * bytes.length];
|
||||
Arrays.fill(maskValue, (byte) 0xff);
|
||||
System.arraycopy(bytes, 0, maskValue, bytes.length, bytes.length);
|
||||
RegisterValue baseValue = new RegisterValue(baseReg, maskValue);
|
||||
return baseValue.getRegisterValue(reg);
|
||||
}
|
||||
|
||||
public String getRegisterValueString(Register reg) {
|
||||
String valStr = getRegisterValue(reg).getUnsignedValue().toString(16);
|
||||
return StringUtilities.pad(valStr, '0', reg.getMinimumByteSize() * 2);
|
||||
}
|
||||
|
||||
public void setRegister(String regName, long value) {
|
||||
Register reg = program.getRegister(regName);
|
||||
if (reg == null) {
|
||||
throw new IllegalArgumentException("Undefined register: " + regName);
|
||||
}
|
||||
emuHelper.writeRegister(reg, value);
|
||||
}
|
||||
|
||||
public void setRegister(String regName, BigInteger value) {
|
||||
Register reg = program.getRegister(regName);
|
||||
if (reg == null) {
|
||||
throw new IllegalArgumentException("Undefined register: " + regName);
|
||||
}
|
||||
emuHelper.writeRegister(reg, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add memory dump point
|
||||
* @param breakAddr instruction address at which execution should pause (before it is executed)
|
||||
* so that the specified memory may be dumped to the log during trace execution mode.
|
||||
* @param dumpAddr memory address which should be dumped
|
||||
* @param dumpSize number elements which should be dumped
|
||||
* @param elementSize size of each element in bytes (be reasonable!)
|
||||
* @param elementFormat HEX, DECIMAL or FLOAT
|
||||
* @param comment dump comment
|
||||
*/
|
||||
public void addDumpPoint(Address breakAddr, Address dumpAddr, int dumpSize, int elementSize,
|
||||
DumpFormat elementFormat, String comment) {
|
||||
List<DumpPoint> list = dumpPointMap.get(breakAddr);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
dumpPointMap.put(breakAddr, list);
|
||||
}
|
||||
list.add(new AddressDumpPoint(breakAddr, dumpAddr, dumpSize, elementSize, elementFormat,
|
||||
comment));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add memory dump point
|
||||
* @param breakAddr instruction address at which execution should pause (before it is executed)
|
||||
* so that the specified memory may be dumped to the log during trace execution mode.
|
||||
* @param dumpAddrReg register containing the memory address offset which should be dumped
|
||||
* @param relativeOffset dump register relative offset
|
||||
* @param dumpAddrSpace address space to which memory offset should be applied
|
||||
* @param dumpSize number elements which should be dumped
|
||||
* @param elementSize size of each element in bytes (be reasonable!)
|
||||
* @param elementFormat HEX, DECIMAL or FLOAT
|
||||
* @param comment dump comment
|
||||
*/
|
||||
public void addDumpPoint(Address breakAddr, Register dumpAddrReg, int relativeOffset,
|
||||
AddressSpace dumpAddrSpace, int dumpSize, int elementSize, DumpFormat elementFormat,
|
||||
String comment) {
|
||||
List<DumpPoint> list = dumpPointMap.get(breakAddr);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
dumpPointMap.put(breakAddr, list);
|
||||
}
|
||||
list.add(new RegisterRelativeDumpPoint(breakAddr, dumpAddrReg, relativeOffset,
|
||||
dumpAddrSpace, dumpSize, elementSize, elementFormat, comment));
|
||||
}
|
||||
|
||||
private void dump(List<DumpPoint> dumpList) {
|
||||
for (DumpPoint dumpPoint : dumpList) {
|
||||
Address dumpAddr = dumpPoint.getDumpAddress();
|
||||
executionListener.logState(this, dumpAddr, dumpPoint.dumpSize, dumpPoint.elementSize,
|
||||
dumpPoint.elementFormat, dumpPoint.comment);
|
||||
}
|
||||
}
|
||||
|
||||
private String getLastFunctionName(PCodeTestGroup testGroup, boolean logError) {
|
||||
return testGroup.mainTestControlBlock.getLastFunctionName(this,
|
||||
logError ? executionListener : null, testGroup);
|
||||
}
|
||||
|
||||
public String getEmuError() {
|
||||
return lastError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of CALLOTHER errors detected when a test pass was registered.
|
||||
* This number should be subtracted from the pass count and possibly added
|
||||
* to the failure count. Number does not reflect total number of CALLOTHER
|
||||
* pcodeops encountered but only the number of passed tests affected.
|
||||
* See log for all CALLOTHER executions detected.
|
||||
* @return number of CALLOTHER errors
|
||||
*/
|
||||
public int getCallOtherErrors() {
|
||||
return callOtherErrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute test group without instruction stepping/tracing
|
||||
* @param timeLimitMS
|
||||
* @param monitor
|
||||
* @return
|
||||
* @throws CancelledException
|
||||
*/
|
||||
public boolean execute(int timeLimitMS, TaskMonitor monitor) throws CancelledException {
|
||||
|
||||
testGroup.clearFailures();
|
||||
lastError = null;
|
||||
callOtherErrors = 0;
|
||||
|
||||
// Disable sprintf use
|
||||
testGroup.mainTestControlBlock.setSprintfEnabled(this, false);
|
||||
|
||||
int alignment = program.getLanguage().getInstructionAlignment();
|
||||
|
||||
Address breakOnDoneAddr =
|
||||
alignAddress(testGroup.mainTestControlBlock.getBreakOnDoneAddress(), alignment);
|
||||
Address breakOnPassAddr =
|
||||
alignAddress(testGroup.mainTestControlBlock.getBreakOnPassAddress(), alignment);
|
||||
Address breakOnErrorAddr =
|
||||
alignAddress(testGroup.mainTestControlBlock.getBreakOnErrorAddress(), alignment);
|
||||
|
||||
emuHelper.setBreakpoint(breakOnDoneAddr);
|
||||
emuHelper.setBreakpoint(breakOnPassAddr);
|
||||
emuHelper.setBreakpoint(breakOnErrorAddr);
|
||||
|
||||
GhidraSwinglessTimer safetyTimer = null;
|
||||
haltedOnTimer = false;
|
||||
boolean atBreakpoint = false;
|
||||
try {
|
||||
if (timeLimitMS > 0) {
|
||||
safetyTimer = new GhidraSwinglessTimer(timeLimitMS, new TimerCallback() {
|
||||
@Override
|
||||
public synchronized void timerFired() {
|
||||
haltedOnTimer = true;
|
||||
emuHelper.getEmulator().setHalt(true);
|
||||
}
|
||||
});
|
||||
safetyTimer.setRepeats(false);
|
||||
safetyTimer.start();
|
||||
}
|
||||
while (true) {
|
||||
callOtherCount = 0;
|
||||
|
||||
boolean success;
|
||||
if (atBreakpoint) {
|
||||
success = emuHelper.run(monitor);
|
||||
}
|
||||
else {
|
||||
success = emuHelper.run(alignAddress(testGroup.functionEntryPtr, alignment),
|
||||
null, monitor);
|
||||
}
|
||||
|
||||
String lastFuncName = getLastFunctionName(testGroup, false);
|
||||
String errFileName = testGroup.mainTestControlBlock.getLastErrorFile(this);
|
||||
int errLineNum = testGroup.mainTestControlBlock.getLastErrorLine(this);
|
||||
|
||||
Address executeAddr = emuHelper.getExecutionAddress();
|
||||
if (!success) {
|
||||
lastError = emuHelper.getLastError();
|
||||
testGroup.severeTestFailure(lastFuncName, errFileName, errLineNum, program,
|
||||
executionListener);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (haltedOnTimer) {
|
||||
lastError = "Emulation halted due to execution timeout";
|
||||
testGroup.severeTestFailure(lastFuncName, errFileName, errLineNum, program,
|
||||
executionListener);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (executeAddr.equals(breakOnDoneAddr)) {
|
||||
return true; // done
|
||||
}
|
||||
|
||||
if (executeAddr.equals(breakOnPassAddr)) {
|
||||
if (callOtherCount != 0) {
|
||||
// force error even if test passed - need to adjust pass count
|
||||
testGroup.testFailed(lastFuncName, errFileName, errLineNum, true, program,
|
||||
executionListener);
|
||||
++callOtherErrors;
|
||||
}
|
||||
else {
|
||||
testGroup.testPassed(lastFuncName, errFileName, errLineNum, program,
|
||||
executionListener);
|
||||
}
|
||||
atBreakpoint = true;
|
||||
continue;
|
||||
}
|
||||
else if (executeAddr.equals(breakOnErrorAddr)) {
|
||||
testGroup.testFailed(lastFuncName, errFileName, errLineNum, false, program,
|
||||
executionListener);
|
||||
atBreakpoint = true;
|
||||
continue; // resume from breakpoint
|
||||
}
|
||||
|
||||
throw new AssertException("Unexpected condition (executeAddr=" + executeAddr + ")");
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (safetyTimer != null) {
|
||||
synchronized (safetyTimer) {
|
||||
safetyTimer.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean executeSingleStep(int stepLimit) {
|
||||
|
||||
testGroup.clearFailures();
|
||||
lastError = null;
|
||||
callOtherErrors = 0;
|
||||
callOtherCount = 0;
|
||||
|
||||
// force function address alignment to compensate for address encoding (e.g., Thumb mode)
|
||||
int alignment = program.getLanguage().getInstructionAlignment();
|
||||
|
||||
HashMap<Address, FunctionInfo> subFunctionMap = new HashMap<>();
|
||||
int subFunctionCnt = testGroup.controlBlock.getNumberFunctions();
|
||||
for (int i = 1; i < subFunctionCnt; i++) {
|
||||
FunctionInfo functionInfo = testGroup.controlBlock.getFunctionInfo(i);
|
||||
subFunctionMap.put(alignAddress(functionInfo.functionAddr, alignment), functionInfo);
|
||||
}
|
||||
|
||||
Address executeAddr = alignAddress(testGroup.functionEntryPtr, alignment);
|
||||
|
||||
emuHelper.writeRegister(program.getLanguage().getProgramCounter(),
|
||||
executeAddr.getAddressableWordOffset());
|
||||
|
||||
// Enable sprintf use
|
||||
testGroup.mainTestControlBlock.setSprintfEnabled(this, true);
|
||||
|
||||
Address breakOnDoneAddr =
|
||||
alignAddress(testGroup.mainTestControlBlock.getBreakOnDoneAddress(), alignment);
|
||||
Address breakOnPassAddr =
|
||||
alignAddress(testGroup.mainTestControlBlock.getBreakOnPassAddress(), alignment);
|
||||
Address breakOnErrorAddr =
|
||||
alignAddress(testGroup.mainTestControlBlock.getBreakOnErrorAddress(), alignment);
|
||||
Address printfAddr =
|
||||
alignAddress(testGroup.mainTestControlBlock.getSprintf5Address(), alignment);
|
||||
|
||||
executionListener.log(testGroup, "TestInfo pointers of interest:");
|
||||
executionListener.log(testGroup, " onDone -> " + breakOnDoneAddr);
|
||||
executionListener.log(testGroup, " onPass -> " + breakOnPassAddr);
|
||||
executionListener.log(testGroup, " onError -> " + breakOnErrorAddr);
|
||||
executionListener.log(testGroup, " printf5 -> " + printfAddr);
|
||||
|
||||
if (!dumpPointMap.isEmpty()) {
|
||||
executionListener.log(testGroup, "Dump points:");
|
||||
List<Address> addressList = new ArrayList<>(dumpPointMap.keySet());
|
||||
Collections.sort(addressList);
|
||||
for (Address addr : addressList) {
|
||||
List<DumpPoint> dumpList = dumpPointMap.get(addr);
|
||||
for (DumpPoint dumpPoint : dumpList) {
|
||||
executionListener.log(testGroup, " " + dumpPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
executionListener.logState(this);
|
||||
|
||||
int stepCount = 0;
|
||||
Address lastAddress = null;
|
||||
Address printfCallAddr = null;
|
||||
boolean assertTriggered = false;
|
||||
FunctionInfo currentFunction = null;
|
||||
|
||||
MyMemoryAccessFilter memoryFilter = new MyMemoryAccessFilter();
|
||||
emu.addMemoryAccessFilter(memoryFilter);
|
||||
try {
|
||||
|
||||
while (true) {
|
||||
if (!emuHelper.step(TaskMonitor.DUMMY)) {
|
||||
lastError = emuHelper.getLastError();
|
||||
|
||||
String lastFuncName = getLastFunctionName(testGroup, true);
|
||||
String errFileName = testGroup.mainTestControlBlock.getLastErrorFile(this);
|
||||
int errLineNum = testGroup.mainTestControlBlock.getLastErrorLine(this);
|
||||
|
||||
testGroup.severeTestFailure(lastFuncName, errFileName, errLineNum, program,
|
||||
executionListener);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
executeAddr = emuHelper.getExecutionAddress();
|
||||
|
||||
List<DumpPoint> dumpList = dumpPointMap.get(executeAddr);
|
||||
if (dumpList != null) {
|
||||
dump(dumpList);
|
||||
}
|
||||
|
||||
if (executeAddr.equals(breakOnDoneAddr)) {
|
||||
return true; // done
|
||||
}
|
||||
|
||||
boolean onPass = executeAddr.equals(breakOnPassAddr);
|
||||
if (onPass || executeAddr.equals(breakOnErrorAddr)) {
|
||||
assertTriggered = true;
|
||||
String lastFuncName = getLastFunctionName(testGroup, true);
|
||||
String errFileName = testGroup.mainTestControlBlock.getLastErrorFile(this);
|
||||
int errLineNum = testGroup.mainTestControlBlock.getLastErrorLine(this);
|
||||
if (onPass) {
|
||||
if (callOtherCount != 0) {
|
||||
// force error even if test passed - need to adjust pass count
|
||||
testGroup.testFailed(lastFuncName, errFileName, errLineNum, true,
|
||||
program, executionListener);
|
||||
++callOtherErrors;
|
||||
callOtherCount = 0;
|
||||
}
|
||||
else {
|
||||
testGroup.testPassed(lastFuncName, errFileName, errLineNum, program,
|
||||
executionListener);
|
||||
}
|
||||
}
|
||||
else {
|
||||
testGroup.testFailed(lastFuncName, errFileName, errLineNum, false, program,
|
||||
executionListener);
|
||||
}
|
||||
}
|
||||
else if (executeAddr.equals(printfAddr)) {
|
||||
// enter printf function
|
||||
printfCallAddr = lastAddress;
|
||||
memoryFilter.enabled = false;
|
||||
executionListener.log(testGroup, "printf invocation (log supressed) ...");
|
||||
}
|
||||
else if (printfCallAddr != null && isPrintfReturn(executeAddr, printfCallAddr)) {
|
||||
// return from printf function
|
||||
printfCallAddr = null;
|
||||
memoryFilter.enabled = true;
|
||||
|
||||
String str = testGroup.controlBlock.emuReadString(emuHelper,
|
||||
testGroup.mainTestControlBlock.getPrintfBufferAddress());
|
||||
executionListener.log(testGroup, " " + str);
|
||||
}
|
||||
else {
|
||||
// detect start of new group test and remove from map
|
||||
FunctionInfo functionInfo = subFunctionMap.remove(executeAddr);
|
||||
if (functionInfo != null) {
|
||||
if (currentFunction != null && !assertTriggered) {
|
||||
executionListener.log(testGroup,
|
||||
"ERROR! Group test never executed pass/fail: " + currentFunction);
|
||||
}
|
||||
currentFunction = functionInfo;
|
||||
assertTriggered = (functionInfo.numberOfAsserts == 0);
|
||||
executionListener.log(testGroup,
|
||||
"-------- " + functionInfo.functionName + " (" +
|
||||
functionInfo.numberOfAsserts + functionInfo.numberOfAsserts +
|
||||
"-Asserts) --------");
|
||||
}
|
||||
}
|
||||
|
||||
if (++stepCount > stepLimit) {
|
||||
executionListener.log(testGroup,
|
||||
"Emulation halted due to excessive execution steps");
|
||||
|
||||
String lastFuncName = getLastFunctionName(testGroup, true);
|
||||
String errFileName = testGroup.mainTestControlBlock.getLastErrorFile(this);
|
||||
int errLineNum = testGroup.mainTestControlBlock.getLastErrorLine(this);
|
||||
|
||||
testGroup.severeTestFailure(lastFuncName, errFileName, errLineNum, program,
|
||||
executionListener);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (memoryFilter.enabled) {
|
||||
executionListener.logState(this);
|
||||
}
|
||||
|
||||
lastAddress = executeAddr;
|
||||
}
|
||||
}
|
||||
catch (Throwable t) {
|
||||
Msg.error(this, "Unexpected Exception", t);
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
memoryFilter.dispose();
|
||||
|
||||
List<FunctionInfo> list = new ArrayList<>(subFunctionMap.values());
|
||||
if (!list.isEmpty()) {
|
||||
// Show list of sub-functions which were never executed
|
||||
Collections.sort(list);
|
||||
executionListener.log(testGroup,
|
||||
"The following sub-functions were never executed:");
|
||||
for (FunctionInfo functionInfo : list) {
|
||||
executionListener.log(testGroup, " " + functionInfo);
|
||||
}
|
||||
}
|
||||
else {
|
||||
executionListener.log(testGroup,
|
||||
"All " + (testGroup.controlBlock.getNumberFunctions() - 1) +
|
||||
" sub-functions were executed");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static long alignAddressOffset(long offset, int alignment) {
|
||||
return (offset / alignment) * alignment;
|
||||
}
|
||||
|
||||
static Address alignAddress(Address addr, int alignment) {
|
||||
Address alignedAddr = addr;
|
||||
long offset = addr.getOffset();
|
||||
long alignedOffset = alignAddressOffset(offset, alignment);
|
||||
if (offset != alignedOffset) {
|
||||
alignedAddr = addr.getNewAddress(alignedOffset);
|
||||
}
|
||||
return alignedAddr;
|
||||
}
|
||||
|
||||
private boolean isPrintfReturn(Address executeAddr, Address printfCallAddr) {
|
||||
// look for approximate return relative to address of printf call
|
||||
long offset = executeAddr.getOffset();
|
||||
long maxEnd = printfCallAddr.getOffset() + 32;
|
||||
return (offset > printfCallAddr.getOffset() && offset <= maxEnd);
|
||||
}
|
||||
|
||||
private class MyMemoryAccessFilter extends MemoryAccessFilter {
|
||||
|
||||
boolean enabled = true;
|
||||
|
||||
@Override
|
||||
protected void processWrite(AddressSpace spc, long off, int size, byte[] values) {
|
||||
if (enabled) {
|
||||
executionListener.logWrite(EmulatorTestRunner.this, spc.getAddress(off), size,
|
||||
values);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processRead(AddressSpace spc, long off, int size, byte[] values) {
|
||||
if (enabled &&
|
||||
emu.getEmulateExecutionState() != EmulateExecutionState.INSTRUCTION_DECODE) {
|
||||
executionListener.logRead(EmulatorTestRunner.this, spc.getAddress(off), size,
|
||||
values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MyMemoryFaultHandler implements MemoryFaultHandler {
|
||||
|
||||
private ExecutionListener executionListener;
|
||||
|
||||
public MyMemoryFaultHandler(ExecutionListener executionListener) {
|
||||
this.executionListener = executionListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unknownAddress(Address address, boolean write) {
|
||||
Address pc = emuHelper.getExecutionAddress();
|
||||
String access = write ? "written" : "read";
|
||||
executionListener.log(testGroup,
|
||||
"Unknown address " + access + " at " + pc + ": " + address);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean uninitializedRead(Address address, int size, byte[] buf, int bufOffset) {
|
||||
if (emu.getEmulateExecutionState() == EmulateExecutionState.INSTRUCTION_DECODE) {
|
||||
return false;
|
||||
}
|
||||
Address pc = emuHelper.getExecutionAddress();
|
||||
if (!address.isUniqueAddress()) {
|
||||
Register reg = program.getRegister(address, size);
|
||||
if (reg != null) {
|
||||
executionListener.log(testGroup,
|
||||
"Uninitialized register read at " + pc + ": " + reg);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
executionListener.log(testGroup,
|
||||
"Uninitialized read at " + pc + ": " + address.toString(true) + ":" + size);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum DumpFormat {
|
||||
HEX, DECIMAL, FLOAT;
|
||||
}
|
||||
|
||||
private abstract class DumpPoint {
|
||||
final Address breakAddr;
|
||||
final int dumpSize;
|
||||
final int elementSize;
|
||||
final DumpFormat elementFormat;
|
||||
final String comment;
|
||||
|
||||
DumpPoint(Address breakAddr, int dumpSize, int elementSize, DumpFormat elementFormat,
|
||||
String comment) {
|
||||
this.breakAddr = breakAddr;
|
||||
this.dumpSize = dumpSize;
|
||||
this.elementSize = elementSize;
|
||||
this.elementFormat = elementFormat;
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
abstract Address getDumpAddress();
|
||||
|
||||
public String toString(String addrStr) {
|
||||
return getClass().getSimpleName() + ": " + dumpSize + " " + elementSize +
|
||||
"-byte elements at " + addrStr;
|
||||
}
|
||||
}
|
||||
|
||||
private class AddressDumpPoint extends DumpPoint {
|
||||
final Address dumpAddr;
|
||||
|
||||
AddressDumpPoint(Address breakAddr, Address dumpAddr, int dumpSize, int elementSize,
|
||||
DumpFormat elementFormat, String comment) {
|
||||
super(breakAddr, dumpSize, elementSize, elementFormat, comment);
|
||||
this.dumpAddr = dumpAddr;
|
||||
}
|
||||
|
||||
@Override
|
||||
Address getDumpAddress() {
|
||||
return dumpAddr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toString(dumpAddr.toString(true));
|
||||
}
|
||||
}
|
||||
|
||||
private class RegisterRelativeDumpPoint extends DumpPoint {
|
||||
final Register dumpAddrReg;
|
||||
final int relativeOffset;
|
||||
final AddressSpace dumpAddrSpace;
|
||||
|
||||
RegisterRelativeDumpPoint(Address breakAddr, Register dumpAddrReg, int relativeOffset,
|
||||
AddressSpace dumpAddrSpace, int dumpSize, int elementSize, DumpFormat elementFormat,
|
||||
String comment) {
|
||||
super(breakAddr, dumpSize, elementSize, elementFormat, comment);
|
||||
this.dumpAddrReg = dumpAddrReg;
|
||||
this.relativeOffset = relativeOffset;
|
||||
this.dumpAddrSpace = dumpAddrSpace;
|
||||
}
|
||||
|
||||
@Override
|
||||
Address getDumpAddress() {
|
||||
RegisterValue regVal = getRegisterValue(dumpAddrReg);
|
||||
return dumpAddrSpace.getAddress(regVal.getUnsignedValue().longValue()).add(
|
||||
relativeOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toString("0x" + Integer.toHexString(relativeOffset) + "[" + dumpAddrReg + "]");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors.support;
|
||||
|
||||
import ghidra.program.model.address.Address;
|
||||
|
||||
public interface ExecutionListener extends TestLogger {
|
||||
|
||||
public void stepCompleted(EmulatorTestRunner testRunner);
|
||||
|
||||
public void logWrite(EmulatorTestRunner testRunner, Address address, int size, byte[] values);
|
||||
|
||||
public void logRead(EmulatorTestRunner testRunner, Address address, int size, byte[] values);
|
||||
|
||||
}
|
@ -0,0 +1,477 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors.support;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import ghidra.app.emulator.EmulatorHelper;
|
||||
import ghidra.docking.settings.SettingsImpl;
|
||||
import ghidra.pcode.memstate.MemoryState;
|
||||
import ghidra.pcode.utils.Utils;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.data.DataUtilities.ClearDataMode;
|
||||
import ghidra.program.model.listing.Data;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.mem.*;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.exception.AssertException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
/**
|
||||
* <code>PCodeTestAbstractControlBlock</code> data is models the general capabilities
|
||||
* of the TestInfo data structure which is used for different puposes as handled
|
||||
* by extensions of this class.
|
||||
*/
|
||||
public abstract class PCodeTestAbstractControlBlock {
|
||||
|
||||
static final int SIZEOF_U4 = 4;
|
||||
|
||||
protected final Program program;
|
||||
protected final AddressSpace codeSpace;
|
||||
protected final AddressSpace dataSpace;
|
||||
|
||||
protected final int pointerSize;
|
||||
|
||||
protected final Address infoStructAddr;
|
||||
protected final Structure infoProgramStruct;
|
||||
|
||||
private List<FunctionInfo> functions = new ArrayList<>();
|
||||
private HashMap<String, FunctionInfo> functionMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Construct test control block instance for the specified program.
|
||||
* @param program program containing control block structure
|
||||
* @param infoStructAddr program address where structure resides
|
||||
* @param infoStruct appropriate Info structure definition which will have array
|
||||
* of FunctionInfo immediately following.
|
||||
*/
|
||||
PCodeTestAbstractControlBlock(Program program, Address infoStructAddr, Structure infoStruct) {
|
||||
this.program = program;
|
||||
this.pointerSize = program.getDataTypeManager().getDataOrganization().getPointerSize();
|
||||
this.infoStructAddr = infoStructAddr;
|
||||
this.infoProgramStruct = (Structure) infoStruct.clone(program.getDataTypeManager());
|
||||
|
||||
codeSpace = program.getAddressFactory().getDefaultAddressSpace();
|
||||
dataSpace = program.getLanguage().getDefaultDataSpace();
|
||||
}
|
||||
|
||||
public Address getInfoStructureAddress() {
|
||||
return infoStructAddr;
|
||||
}
|
||||
|
||||
public FunctionInfo getFunctionInfo(String functionName) {
|
||||
return functionMap.get(functionName);
|
||||
}
|
||||
|
||||
public FunctionInfo getFunctionInfo(int functionIndex) {
|
||||
return functions.get(functionIndex);
|
||||
}
|
||||
|
||||
public int getNumberFunctions() {
|
||||
return functions.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Force an existing reference to refer to the code space. Pointers
|
||||
* created in the data space refer to the data space by default, this method
|
||||
* is used to change these pointers in the data space to refer to
|
||||
* code.
|
||||
* @param addr location with data space which contains code reference
|
||||
*/
|
||||
void forceCodePointer(Address addr) {
|
||||
if (codeSpace == dataSpace) {
|
||||
return;
|
||||
}
|
||||
ReferenceManager refMgr = program.getReferenceManager();
|
||||
Reference ref = refMgr.getPrimaryReferenceFrom(addr, 0);
|
||||
if (ref == null) {
|
||||
return;
|
||||
}
|
||||
Address toAddr = ref.getToAddress();
|
||||
if (!toAddr.getAddressSpace().equals(codeSpace)) {
|
||||
toAddr = codeSpace.getAddress(toAddr.getAddressableWordOffset(), true);
|
||||
Reference newRef =
|
||||
refMgr.addMemoryReference(addr, toAddr, RefType.DATA, SourceType.ANALYSIS, 0);
|
||||
refMgr.setPrimary(newRef, true);
|
||||
refMgr.delete(ref);
|
||||
}
|
||||
}
|
||||
|
||||
static byte[] getCharArrayBytes(Program program, String string) {
|
||||
DataOrganization dataOrganization = program.getDataTypeManager().getDataOrganization();
|
||||
int charSize = dataOrganization.getCharSize();
|
||||
byte[] strBytes = string.getBytes();
|
||||
if (charSize == 1) {
|
||||
return strBytes;
|
||||
}
|
||||
|
||||
// generate aligned byte array
|
||||
int len = charSize * strBytes.length;
|
||||
byte[] bytes = new byte[len];
|
||||
boolean bigEndian = program.getMemory().isBigEndian();
|
||||
int index = 0;
|
||||
int pad = charSize - 1;
|
||||
for (byte strByte : strBytes) {
|
||||
if (bigEndian) {
|
||||
index += pad;
|
||||
}
|
||||
bytes[index++] = strByte;
|
||||
if (!bigEndian) {
|
||||
index += pad;
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
private Address readPointer(MemBuffer buffer, int bufferOffset, AddressSpace addrSpace,
|
||||
boolean updateReference) {
|
||||
byte[] bytes = new byte[pointerSize];
|
||||
buffer.getBytes(bytes, bufferOffset);
|
||||
long offset = Utils.bytesToLong(bytes, pointerSize, buffer.isBigEndian()) *
|
||||
addrSpace.getAddressableUnitSize();
|
||||
Address addr = addrSpace.getAddress(offset);
|
||||
if (updateReference) {
|
||||
ReferenceManager refMgr = program.getReferenceManager();
|
||||
Address fromAddr = buffer.getAddress().add(bufferOffset);
|
||||
Reference ref = refMgr.getPrimaryReferenceFrom(fromAddr, 0);
|
||||
if (ref != null && !ref.getToAddress().equals(addr)) {
|
||||
refMgr.delete(ref);
|
||||
ref = null;
|
||||
}
|
||||
if (ref == null) {
|
||||
refMgr.addMemoryReference(fromAddr, addr, RefType.DATA, SourceType.USER_DEFINED, 0);
|
||||
}
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for a Data pointer at the specified address and return the referenced
|
||||
* address.
|
||||
* @param addr address of stored pointer
|
||||
* @return pointer referenced address or null if no pointer found
|
||||
*/
|
||||
protected Address readDefinedDataPointer(Address addr) {
|
||||
Data data = program.getListing().getDefinedDataAt(addr);
|
||||
if (data == null || !(data.getDataType() instanceof Pointer)) {
|
||||
return null;
|
||||
}
|
||||
return (Address) data.getValue();
|
||||
}
|
||||
|
||||
protected Address readCodePointer(MemBuffer buffer, int bufferOffset, boolean updateReference) {
|
||||
Address codePtr = readPointer(buffer, bufferOffset, codeSpace, updateReference);
|
||||
|
||||
// shift the pointer if code pointers are stored in memory shifted.
|
||||
int ptrShift = program.getDataTypeManager().getDataOrganization().getPointerShift();
|
||||
if (ptrShift != 0) {
|
||||
codePtr = codePtr.getNewAddress(codePtr.getOffset() << ptrShift);
|
||||
}
|
||||
|
||||
// Check for potential procedure descriptor indirection (e.g., PPC64 .opd)
|
||||
// in which case a function pointer may refer to a procedure descriptor
|
||||
// record (we assume here that the first entry has been marked-up by the importer
|
||||
// and corresponds to the true function address
|
||||
|
||||
Address ptr = readDefinedDataPointer(codePtr);
|
||||
if (ptr != null) {
|
||||
codePtr = ptr;
|
||||
}
|
||||
|
||||
return codePtr;
|
||||
}
|
||||
|
||||
protected Address readDataPointer(MemBuffer buffer, int bufferOffset, boolean updateReference) {
|
||||
return readPointer(buffer, bufferOffset, dataSpace, updateReference);
|
||||
}
|
||||
|
||||
protected Address readPointer(int controlBlockOffset) throws MemoryAccessException {
|
||||
Address addr = infoStructAddr.add(controlBlockOffset);
|
||||
byte[] bytes = new byte[pointerSize];
|
||||
Memory memory = program.getMemory();
|
||||
if (memory.getBytes(addr, bytes) != pointerSize) {
|
||||
throw new MemoryAccessException(
|
||||
"Failed to read program memory: " + pointerSize + " bytes at " + addr);
|
||||
}
|
||||
long offset = Utils.bytesToLong(bytes, pointerSize, memory.isBigEndian());
|
||||
return infoStructAddr.getNewAddress(offset);
|
||||
}
|
||||
|
||||
// protected void applyPointerData(Program program, Address addr) {
|
||||
// Pointer dt = new PointerDataType(program.getDataTypeManager());
|
||||
// if (dt.getLength() != pointerSize) {
|
||||
// switch (pointerSize) {
|
||||
// case 2:
|
||||
// dt = new Pointer16DataType();
|
||||
// break;
|
||||
// case 3:
|
||||
// dt = new Pointer24DataType();
|
||||
// break;
|
||||
// case 4:
|
||||
// dt = new Pointer32DataType();
|
||||
// break;
|
||||
// case 5:
|
||||
// dt = new Pointer40DataType();
|
||||
// break;
|
||||
// case 6:
|
||||
// dt = new Pointer48DataType();
|
||||
// break;
|
||||
// case 7:
|
||||
// dt = new Pointer56DataType();
|
||||
// break;
|
||||
// case 8:
|
||||
// dt = new Pointer64DataType();
|
||||
// break;
|
||||
// default:
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// try {
|
||||
// program.getListing().createData(addr, dt);
|
||||
// }
|
||||
// catch (CodeUnitInsertionException e) {
|
||||
// // ignore
|
||||
// }
|
||||
// catch (DataTypeConflictException e) {
|
||||
// // ignore
|
||||
// }
|
||||
// }
|
||||
|
||||
protected void applyU4Data(Address addr) {
|
||||
try {
|
||||
program.getListing().createData(addr, DWordDataType.dataType);
|
||||
}
|
||||
catch (CodeUnitInsertionException e) {
|
||||
// ignore
|
||||
}
|
||||
catch (DataTypeConflictException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
protected int getStructureComponent(Structure testInfoStruct, String fieldName) {
|
||||
for (DataTypeComponent component : testInfoStruct.getComponents()) {
|
||||
if (fieldName.equals(component.getFieldName())) {
|
||||
return component.getOffset();
|
||||
}
|
||||
}
|
||||
throw new RuntimeException(fieldName + " field not found within " +
|
||||
testInfoStruct.getName() + " structure definition at " + infoStructAddr.toString(true));
|
||||
}
|
||||
|
||||
protected void readControlBlock(boolean applyStruct)
|
||||
throws InvalidControlBlockException, CodeUnitInsertionException {
|
||||
|
||||
if (applyStruct) {
|
||||
DataUtilities.createData(program, infoStructAddr, infoProgramStruct, -1, false,
|
||||
ClearDataMode.CLEAR_ALL_CONFLICT_DATA);
|
||||
}
|
||||
|
||||
TerminatedStringDataType stringType =
|
||||
new TerminatedStringDataType(program.getDataTypeManager());
|
||||
|
||||
Structure functionInfoStruct =
|
||||
(Structure) infoProgramStruct.getDataTypeManager().getDataType(CategoryPath.ROOT,
|
||||
"FunctionInfo");
|
||||
if (functionInfoStruct == null) {
|
||||
throw new AssertException("FunctionInfo structure not yet resolved");
|
||||
}
|
||||
|
||||
int nameOffset = getStructureComponent(functionInfoStruct, "name");
|
||||
int funcOffset = getStructureComponent(functionInfoStruct, "func");
|
||||
int numTestOffset = getStructureComponent(functionInfoStruct, "numTest");
|
||||
|
||||
try {
|
||||
|
||||
DumbMemBufferImpl memBuffer =
|
||||
new DumbMemBufferImpl(program.getMemory(), infoStructAddr);
|
||||
int functionArrayPtrOffset =
|
||||
getStructureComponent(infoProgramStruct, "funcInfoArrayPtr");
|
||||
Address functionInfoAddress =
|
||||
readDataPointer(memBuffer, functionArrayPtrOffset, applyStruct);
|
||||
|
||||
Msg.info(this, "Loading FunctionInfo array at " + functionInfoAddress);
|
||||
|
||||
while (true) {
|
||||
// Read function table
|
||||
memBuffer.setPosition(functionInfoAddress);
|
||||
|
||||
if (applyStruct) {
|
||||
DataUtilities.createData(program, functionInfoAddress, functionInfoStruct, -1,
|
||||
false, ClearDataMode.CLEAR_ALL_CONFLICT_DATA);
|
||||
forceCodePointer(functionInfoAddress.add(funcOffset));
|
||||
}
|
||||
|
||||
Address funcNamePtr = readDataPointer(memBuffer, nameOffset, applyStruct);
|
||||
Address funcPtr = readCodePointer(memBuffer, funcOffset, applyStruct);
|
||||
int numTest = memBuffer.getInt(numTestOffset);
|
||||
|
||||
if (funcNamePtr.getOffset() == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
memBuffer.setPosition(funcNamePtr);
|
||||
String functionName =
|
||||
(String) stringType.getValue(memBuffer, SettingsImpl.NO_SETTINGS, 0);
|
||||
|
||||
if (funcPtr.getOffset() != 0) {
|
||||
MemoryBlock block = program.getMemory().getBlock(funcPtr);
|
||||
if (block == null || !block.isInitialized()) {
|
||||
throw new InvalidControlBlockException(
|
||||
infoProgramStruct.getName() + " @ " + infoStructAddr.toString(true) +
|
||||
" has invalid pointer offset for function: " + functionName +
|
||||
" -> " + funcPtr);
|
||||
}
|
||||
}
|
||||
|
||||
if (funcPtr.getOffset() != 0) {
|
||||
FunctionInfo info = new FunctionInfo(functionName, funcPtr, numTest);
|
||||
functions.add(info);
|
||||
functionMap.put(functionName, info);
|
||||
}
|
||||
|
||||
functionInfoAddress = functionInfoAddress.add(functionInfoStruct.getLength());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (MemoryAccessException e) {
|
||||
throw new InvalidControlBlockException(
|
||||
infoProgramStruct.getName() + " program read error", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected String emuReadString(EmulatorHelper emu, Address strPtrAddr) {
|
||||
|
||||
DataOrganization dataOrganization =
|
||||
emu.getProgram().getDataTypeManager().getDataOrganization();
|
||||
int charSize = dataOrganization.getCharSize();
|
||||
boolean isBigEndian = emu.getProgram().getMemory().isBigEndian();
|
||||
|
||||
MemoryState memState = emu.getEmulator().getMemState();
|
||||
long offset = strPtrAddr.getOffset();
|
||||
if (isBigEndian) {
|
||||
offset += (charSize - 1);
|
||||
}
|
||||
char[] buffer = new char[128];
|
||||
int index = 0;
|
||||
while (index < buffer.length) {
|
||||
buffer[index] =
|
||||
(char) (memState.getValue(strPtrAddr.getAddressSpace(), offset, 1) & 0xff);
|
||||
if (buffer[index] == 0) {
|
||||
break;
|
||||
}
|
||||
offset += charSize;
|
||||
++index;
|
||||
}
|
||||
return new String(buffer, 0, index);
|
||||
}
|
||||
|
||||
protected long emuRead(EmulatorHelper emu, Address addr, int size) {
|
||||
if (size < 1 || size > 8) {
|
||||
throw new IllegalArgumentException("Unsupported EMU read size: " + size);
|
||||
}
|
||||
MemoryState memState = emu.getEmulator().getMemState();
|
||||
return memState.getValue(addr.getAddressSpace(), addr.getOffset(), size);
|
||||
}
|
||||
|
||||
protected void emuWrite(EmulatorHelper emu, Address addr, int size, long value) {
|
||||
if (size < 1 || size > 8) {
|
||||
throw new IllegalArgumentException("Unsupported EMU read size: " + size);
|
||||
}
|
||||
MemoryState memState = emu.getEmulator().getMemState();
|
||||
memState.setValue(addr.getAddressSpace(), addr.getOffset(), size, value);
|
||||
}
|
||||
|
||||
protected Address getMirroredDataAddress(EmulatorTestRunner emuTestRunner, Address addr) {
|
||||
AddressSpace defaultDataSpace =
|
||||
emuTestRunner.getProgram().getLanguage().getDefaultDataSpace();
|
||||
if (defaultDataSpace != null && !addr.getAddressSpace().equals(defaultDataSpace)) {
|
||||
addr = defaultDataSpace.getAddress(addr.getOffset());
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
||||
static Address findBytes(Memory memory, AddressSetView set, byte[] bytes) {
|
||||
for (AddressRange range : set.getAddressRanges()) {
|
||||
Address addr = memory.findBytes(range.getMinAddress(), range.getMaxAddress(), bytes,
|
||||
null, true, TaskMonitor.DUMMY);
|
||||
if (addr != null) {
|
||||
// ignore overlay blocks which may have been created by the importer
|
||||
if (addr.getAddressSpace().isOverlaySpace()) {
|
||||
continue;
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static class InvalidControlBlockException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 9137869694955008327L;
|
||||
|
||||
public InvalidControlBlockException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public InvalidControlBlockException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
|
||||
public static class FunctionInfo implements Comparable<FunctionInfo> {
|
||||
|
||||
public final String functionName;
|
||||
public final Address functionAddr;
|
||||
public final int numberOfAsserts;
|
||||
|
||||
FunctionInfo(String functionName, Address functionAddr, int numberOfAsserts) {
|
||||
this.functionName = functionName;
|
||||
this.functionAddr = functionAddr;
|
||||
this.numberOfAsserts = numberOfAsserts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(FunctionInfo other) {
|
||||
return functionName.compareTo(other.functionName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof FunctionInfo)) {
|
||||
return false;
|
||||
}
|
||||
FunctionInfo other = (FunctionInfo) obj;
|
||||
return functionName.equals(other.functionName) &
|
||||
functionAddr.equals(other.functionAddr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return functionAddr.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return functionName + "@" + functionAddr.toString(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,528 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors.support;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
|
||||
import ghidra.test.processors.support.PCodeTestResults.TestResults;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.xml.GenericXMLOutputter;
|
||||
import ghidra.util.xml.XmlUtilities;
|
||||
import resources.ResourceManager;
|
||||
|
||||
public class PCodeTestCombinedTestResults {
|
||||
|
||||
public static final String FILENAME = "pcode_test_results";
|
||||
|
||||
private static String XML_VERSION = "1";
|
||||
|
||||
// char width used when computing result column width
|
||||
private static int CHAR_WIDTH = 6;
|
||||
|
||||
private File xmlFile;
|
||||
private File htmlFile;
|
||||
|
||||
private Map<String, PCodeTestResults> combinedResults = new HashMap<>();
|
||||
|
||||
PCodeTestCombinedTestResults(File reportsDir, boolean readExisting) throws IOException {
|
||||
this.xmlFile = new File(reportsDir, FILENAME + ".xml");
|
||||
this.htmlFile = new File(reportsDir, FILENAME + ".html");
|
||||
if (readExisting && xmlFile.exists()) {
|
||||
restoreFromXml();
|
||||
}
|
||||
}
|
||||
|
||||
public PCodeTestResults getTestResults(String jUnitName, boolean create) {
|
||||
PCodeTestResults testResults = combinedResults.get(jUnitName);
|
||||
if (testResults == null && create) {
|
||||
testResults = new PCodeTestResults(jUnitName);
|
||||
combinedResults.put(jUnitName, testResults);
|
||||
}
|
||||
return testResults;
|
||||
}
|
||||
|
||||
private void restoreFromXml() throws IOException {
|
||||
|
||||
FileInputStream istream = new FileInputStream(xmlFile);
|
||||
BufferedInputStream bis = new BufferedInputStream(istream);
|
||||
try {
|
||||
SAXBuilder sax = XmlUtilities.createSecureSAXBuilder(false, false);
|
||||
Document doc = sax.build(bis);
|
||||
Element root = doc.getRootElement();
|
||||
|
||||
if (!"PCODE_TESTS".equals(root.getName()) ||
|
||||
!XML_VERSION.equals(root.getAttributeValue("VERSION"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Element> elementList = root.getChildren(PCodeTestResults.TAG_NAME);
|
||||
for (Element element : elementList) {
|
||||
PCodeTestResults testResults = new PCodeTestResults(element);
|
||||
combinedResults.put(testResults.getJUnitName(), testResults);
|
||||
}
|
||||
}
|
||||
catch (org.jdom.JDOMException je) {
|
||||
throw new IOException("Invalid P-Code test results xml file: " + xmlFile, je);
|
||||
}
|
||||
finally {
|
||||
istream.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void saveToXml() throws IOException {
|
||||
|
||||
File dir = xmlFile.getParentFile();
|
||||
if (!dir.exists() && !dir.mkdir()) {
|
||||
throw new IOException("Failed to created directory: " + dir);
|
||||
}
|
||||
|
||||
Element root = new Element("PCODE_TESTS");
|
||||
root.setAttribute("VERSION", XML_VERSION);
|
||||
|
||||
for (String name : combinedResults.keySet()) {
|
||||
PCodeTestResults testResults = combinedResults.get(name);
|
||||
root.addContent(testResults.saveToXml());
|
||||
}
|
||||
|
||||
// Store checkout data in temporary file
|
||||
File tmpFile = new File(xmlFile.getParentFile(), xmlFile.getName() + ".new");
|
||||
tmpFile.delete();
|
||||
FileOutputStream ostream = new FileOutputStream(tmpFile);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(ostream);
|
||||
|
||||
try {
|
||||
Document doc = new Document(root);
|
||||
XMLOutputter xmlout = new GenericXMLOutputter();
|
||||
xmlout.output(doc, bos);
|
||||
}
|
||||
finally {
|
||||
bos.close();
|
||||
}
|
||||
|
||||
// Rename files
|
||||
File oldFile = null;
|
||||
if (xmlFile.exists()) {
|
||||
oldFile = new File(xmlFile.getParentFile(), xmlFile.getName() + ".bak");
|
||||
oldFile.delete();
|
||||
if (!xmlFile.renameTo(oldFile)) {
|
||||
throw new IOException("Failed to update: " + xmlFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
if (!tmpFile.renameTo(xmlFile)) {
|
||||
if (oldFile != null) {
|
||||
oldFile.renameTo(xmlFile);
|
||||
}
|
||||
throw new IOException("Failed to update: " + xmlFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
Msg.info(this, "XML results file updated: " + xmlFile.getAbsolutePath());
|
||||
|
||||
if (oldFile != null) {
|
||||
oldFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
void copyResourceFile(String resourceName, PrintWriter w) throws IOException {
|
||||
InputStream in = ResourceManager.getResourceAsStream(resourceName);
|
||||
if (in == null) {
|
||||
throw new FileNotFoundException("Resource not found: " + resourceName);
|
||||
}
|
||||
in = new BufferedInputStream(in);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
w.println(line);
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
|
||||
private static class NamedTestColumn implements Comparable<NamedTestColumn> {
|
||||
private final String groupTestName;
|
||||
//String groupName;
|
||||
private final String testName;
|
||||
int charCount = 5; // char-count (minimum: -/-/-)
|
||||
|
||||
/**
|
||||
*
|
||||
* @param groupTestName <group-name>.<test-name>
|
||||
*/
|
||||
NamedTestColumn(String groupTestName) {
|
||||
this.groupTestName = groupTestName;
|
||||
|
||||
int index = groupTestName.indexOf('.');
|
||||
//String groupName = "";
|
||||
String testName = groupTestName;
|
||||
if (index >= 0) {
|
||||
//groupName = groupTestName.substring(0, index);
|
||||
testName = groupTestName.substring(index + 1);
|
||||
}
|
||||
|
||||
this.testName = testName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <group-name>.<test-name>
|
||||
*/
|
||||
public String getGroupTestName() {
|
||||
return groupTestName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <test-name>
|
||||
*/
|
||||
public String getTestName() {
|
||||
return testName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(NamedTestColumn o) {
|
||||
return testName.compareTo(o.testName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return testName.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof NamedTestColumn)) {
|
||||
return false;
|
||||
}
|
||||
NamedTestColumn other = (NamedTestColumn) obj;
|
||||
return testName.equals(other.testName);
|
||||
}
|
||||
|
||||
public int getColumnWidth() {
|
||||
return (charCount + 2) * CHAR_WIDTH;
|
||||
}
|
||||
|
||||
public void adjustWidth(TestResults testResults) {
|
||||
if (testResults == null) {
|
||||
return;
|
||||
}
|
||||
int count =
|
||||
computeCharCount(testResults.passCount) + computeCharCount(testResults.failCount) +
|
||||
computeCharCount(testResults.callOtherCount) + 2;
|
||||
charCount = Math.max(count, charCount);
|
||||
}
|
||||
|
||||
private static int computeCharCount(int value) {
|
||||
int count = 1;
|
||||
while (value > 9) {
|
||||
++count;
|
||||
value /= 10;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
void saveToHTML() throws IOException {
|
||||
File dir = htmlFile.getParentFile();
|
||||
if (!dir.exists() && !dir.mkdir()) {
|
||||
throw new IOException("Failed to created directory: " + dir);
|
||||
}
|
||||
|
||||
List<String> sortedJUnitTestNames = new ArrayList<>();
|
||||
Map<String, Set<NamedTestColumn>> allTestNamesMap = new HashMap<>(); // mapped by <group-name>
|
||||
Map<String, NamedTestColumn> namedTestColumnMap = new HashMap<>(); // mapped by <group-name>.<test-name> key
|
||||
for (PCodeTestResults unitTestResults : combinedResults.values()) {
|
||||
sortedJUnitTestNames.add(unitTestResults.getJUnitName());
|
||||
for (String groupTestName : unitTestResults.getGroupTestNames()) {
|
||||
|
||||
int index = groupTestName.indexOf('.');
|
||||
String groupName = "";
|
||||
if (index >= 0) {
|
||||
groupName = groupTestName.substring(0, index);
|
||||
}
|
||||
|
||||
Set<NamedTestColumn> set = allTestNamesMap.get(groupName);
|
||||
if (set == null) {
|
||||
set = new HashSet<>();
|
||||
allTestNamesMap.put(groupName, set);
|
||||
}
|
||||
|
||||
NamedTestColumn namedTestColumn = namedTestColumnMap.get(groupTestName);
|
||||
if (namedTestColumn == null) {
|
||||
namedTestColumn = new NamedTestColumn(groupTestName);
|
||||
namedTestColumnMap.put(groupTestName, namedTestColumn);
|
||||
set.add(namedTestColumn);
|
||||
}
|
||||
|
||||
namedTestColumn.adjustWidth(unitTestResults.getTestResults(groupTestName, false));
|
||||
}
|
||||
}
|
||||
|
||||
String[] groupNames = allTestNamesMap.keySet().toArray(new String[allTestNamesMap.size()]);
|
||||
Arrays.sort(groupNames);
|
||||
|
||||
Map<String, NamedTestColumn[]> allTestNamesByGroup = new HashMap<>();
|
||||
for (String groupName : groupNames) {
|
||||
Set<NamedTestColumn> set = allTestNamesMap.get(groupName);
|
||||
NamedTestColumn[] namedTestColumns = set.toArray(new NamedTestColumn[set.size()]);
|
||||
Arrays.sort(namedTestColumns);
|
||||
allTestNamesByGroup.put(groupName, namedTestColumns);
|
||||
}
|
||||
|
||||
Collections.sort(sortedJUnitTestNames);
|
||||
|
||||
// Store checkout data in temporary file
|
||||
File tmpFile = new File(xmlFile.getParentFile(), xmlFile.getName() + ".new");
|
||||
tmpFile.delete();
|
||||
|
||||
PrintWriter w = new PrintWriter(tmpFile);
|
||||
try {
|
||||
copyResourceFile("pcodetest/chunk1.hinc", w);
|
||||
|
||||
writeTableHeader(w, groupNames, allTestNamesByGroup);
|
||||
|
||||
copyResourceFile("pcodetest/chunk2.hinc", w);
|
||||
|
||||
int rownum = 1;
|
||||
for (String name : sortedJUnitTestNames) {
|
||||
PCodeTestResults testResults = combinedResults.get(name);
|
||||
writeTestSummaryRow(w, testResults, (rownum++ % 2) == 1);
|
||||
}
|
||||
|
||||
copyResourceFile("pcodetest/chunk3.hinc", w);
|
||||
|
||||
boolean firstRow = true;
|
||||
for (String name : sortedJUnitTestNames) {
|
||||
PCodeTestResults testResults = combinedResults.get(name);
|
||||
writeTestResultsRow(w, groupNames, allTestNamesByGroup, testResults,
|
||||
(rownum++ % 2) == 1, firstRow);
|
||||
firstRow = false;
|
||||
}
|
||||
|
||||
copyResourceFile("pcodetest/chunk4.hinc", w);
|
||||
}
|
||||
finally {
|
||||
w.flush();
|
||||
w.close();
|
||||
}
|
||||
|
||||
// Rename files
|
||||
File oldFile = null;
|
||||
if (htmlFile.exists()) {
|
||||
oldFile = new File(htmlFile.getParentFile(), htmlFile.getName() + ".bak");
|
||||
oldFile.delete();
|
||||
if (!htmlFile.renameTo(oldFile)) {
|
||||
throw new IOException("Failed to update: " + htmlFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
if (!tmpFile.renameTo(htmlFile)) {
|
||||
if (oldFile != null) {
|
||||
oldFile.renameTo(htmlFile);
|
||||
}
|
||||
throw new IOException("Failed to update: " + htmlFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
Msg.info(this, "HTML results file updated: " + htmlFile.getAbsolutePath());
|
||||
|
||||
if (oldFile != null) {
|
||||
oldFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeTableHeader(PrintWriter w, String[] groupNames,
|
||||
Map<String, NamedTestColumn[]> allTestNamesByGroup) {
|
||||
|
||||
int[] groupWidth = new int[groupNames.length];
|
||||
|
||||
w.println("<tr>");
|
||||
for (int groupIndex = 0; groupIndex < groupNames.length; groupIndex++) {
|
||||
String groupName = groupNames[groupIndex];
|
||||
NamedTestColumn[] namedTestColumns = allTestNamesByGroup.get(groupName);
|
||||
for (NamedTestColumn namedTestColumn : namedTestColumns) {
|
||||
int columnWidth = namedTestColumn.getColumnWidth();
|
||||
w.print("<td class=\"ResultHead\" align=\"center\" valign=\"bottom\">");
|
||||
w.print("<img src=\"X\" border=0 height=1 width=" + columnWidth + "><br>");
|
||||
w.print("<div class=\"r90\">");
|
||||
w.print(HTMLUtilities.friendlyEncodeHTML(namedTestColumn.getTestName()));
|
||||
w.println("</div></td>");
|
||||
groupWidth[groupIndex] += columnWidth;
|
||||
}
|
||||
}
|
||||
|
||||
w.println("</tr><tr>");
|
||||
|
||||
for (int groupIndex = 0; groupIndex < groupNames.length; groupIndex++) {
|
||||
String groupName = groupNames[groupIndex];
|
||||
NamedTestColumn[] namedTestColumns = allTestNamesByGroup.get(groupName);
|
||||
w.print(
|
||||
"<td class=\"GroupHead\" valign=\"middle\" colspan=\"" + namedTestColumns.length +
|
||||
"\" style=\"max-width:" + groupWidth[groupIndex] + ";\"> ");
|
||||
if (groupName.length() != 0) {
|
||||
w.print(HTMLUtilities.friendlyEncodeHTML(groupName));
|
||||
}
|
||||
w.println("</td>");
|
||||
}
|
||||
|
||||
w.println("</tr>");
|
||||
}
|
||||
|
||||
private void writeResultCount(PrintWriter w, int count, String color) {
|
||||
if (count == 0) {
|
||||
w.print("<font color=\"gray\">-</font>");
|
||||
}
|
||||
else {
|
||||
w.print("<font color=\"" + color + "\">" + Integer.toString(count) + "</font>");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeTestSummaryRow(PrintWriter w, PCodeTestResults testResults, boolean shaded) {
|
||||
String shadeStyle = "";
|
||||
if (shaded) {
|
||||
shadeStyle = " class=\"shade\"";
|
||||
}
|
||||
w.println("<tr" + shadeStyle + ">");
|
||||
|
||||
w.print(" <td class=\"TestName\"><a href=\"../logs/" + testResults.getJUnitName() +
|
||||
".log\" target=\"_log\">");
|
||||
w.print(testResults.getJUnitName());
|
||||
w.println("</a></td><td class=\"DateTime\">");
|
||||
|
||||
String time = testResults.getTime();
|
||||
if (time == null) {
|
||||
time = " ";
|
||||
}
|
||||
w.print(time);
|
||||
w.println("</td>");
|
||||
|
||||
// Summary result
|
||||
if (testResults.summaryHasIngestErrors || testResults.summaryHasRelocationErrors ||
|
||||
testResults.summaryHasDisassemblyErrors) {
|
||||
// analyzed program has relocation or disassembly errors
|
||||
w.print("<td align=\"center\" class=\"ResultSummary bad\">");
|
||||
if (testResults.summaryHasIngestErrors) {
|
||||
w.print("<font color=\"red\">Ingest-Err</font><br>");
|
||||
}
|
||||
if (testResults.summaryHasRelocationErrors) {
|
||||
w.print("<font color=\"red\">Reloc-Err</font><br>");
|
||||
}
|
||||
if (testResults.summaryHasDisassemblyErrors) {
|
||||
w.print("<font color=\"red\">Dis-Err</font>");
|
||||
}
|
||||
}
|
||||
else {
|
||||
w.print("<td align=\"center\" class=\"ResultSummary " +
|
||||
getSummaryHighlightColorClass(testResults) + "\">");
|
||||
writeResultCount(w, testResults.summaryPassCount, "green");
|
||||
w.print("/");
|
||||
writeResultCount(w, testResults.summaryFailCount, "red");
|
||||
w.print("/");
|
||||
writeResultCount(w, testResults.summaryCallOtherCount, "orange");
|
||||
if (testResults.summarySevereFailures != 0) {
|
||||
w.print("<br><font color=\"red\">ERR: " + testResults.summarySevereFailures +
|
||||
"</font>");
|
||||
}
|
||||
}
|
||||
|
||||
w.println("</td>");
|
||||
|
||||
w.println("</tr>");
|
||||
}
|
||||
|
||||
private String getSummaryHighlightColorClass(PCodeTestResults testResults) {
|
||||
int failCount = testResults.summaryFailCount;
|
||||
String summaryHighlight = "";
|
||||
int totalAsserts =
|
||||
testResults.summaryPassCount + failCount + testResults.summaryCallOtherCount;
|
||||
if (testResults.summarySevereFailures != 0 ||
|
||||
totalAsserts != testResults.summaryTotalAsserts) {
|
||||
summaryHighlight = "bad";
|
||||
// bump-up failure count to reflect expected number of assertions
|
||||
int diff =
|
||||
totalAsserts - (testResults.summaryPassCount + testResults.summaryCallOtherCount);
|
||||
if (diff > 0) {
|
||||
failCount = diff;
|
||||
}
|
||||
}
|
||||
else if ((testResults.summaryPassCount != 0) && (failCount == 0) &&
|
||||
(testResults.summaryCallOtherCount == 0)) {
|
||||
summaryHighlight = "good";
|
||||
}
|
||||
return summaryHighlight;
|
||||
}
|
||||
|
||||
private void writeTestResultsRow(PrintWriter w, String[] groupNames,
|
||||
Map<String, NamedTestColumn[]> allTestNamesByGroup, PCodeTestResults testResults,
|
||||
boolean shaded, boolean firstRow) {
|
||||
|
||||
String shadeStyle = "";
|
||||
if (shaded) {
|
||||
shadeStyle = " class=\"shade\"";
|
||||
}
|
||||
w.println("<tr" + shadeStyle + ">");
|
||||
|
||||
for (String groupName : groupNames) {
|
||||
NamedTestColumn[] namedTestColumns = allTestNamesByGroup.get(groupName);
|
||||
for (NamedTestColumn namedTestColumn : namedTestColumns) {
|
||||
String testName = namedTestColumn.getTestName();
|
||||
int pass = testResults.getPassResult(groupName, testName);
|
||||
int fail = testResults.getFailResult(groupName, testName);
|
||||
int callother = testResults.getCallOtherResult(groupName, testName);
|
||||
int total = pass + fail + callother;
|
||||
int totalAsserts = testResults.getTotalAsserts(groupName, testName);
|
||||
|
||||
boolean severeFailure = testResults.hadSevereFailure(groupName, testName);
|
||||
|
||||
boolean highlightBad = !severeFailure && (total != 0) && (total != totalAsserts);
|
||||
|
||||
w.print(
|
||||
" <td align=\"center\" class=\"Result" + (highlightBad ? " bad" : "") + "\">");
|
||||
if (firstRow) {
|
||||
w.print("<img src=\"X\" border=0 height=1 width=" +
|
||||
namedTestColumn.getColumnWidth() + "><br>");
|
||||
}
|
||||
if (severeFailure) {
|
||||
w.print("<font color=\"red\">ERR</font>");
|
||||
}
|
||||
else {
|
||||
if (total == 0) {
|
||||
if (totalAsserts == 0) {
|
||||
w.print("<font color=\"gray\">-</font>");
|
||||
}
|
||||
else {
|
||||
w.print("<font color=\"red\">x</font>");
|
||||
}
|
||||
}
|
||||
else {
|
||||
writeResultCount(w, pass, "green");
|
||||
w.print("/");
|
||||
writeResultCount(w, fail, "red");
|
||||
w.print("/");
|
||||
writeResultCount(w, callother, "orange");
|
||||
if (total != totalAsserts) {
|
||||
w.print("<br><font color=\"red\">(!=" + totalAsserts + ")</font>");
|
||||
}
|
||||
}
|
||||
}
|
||||
w.println("</td>");
|
||||
}
|
||||
}
|
||||
w.println("</tr>");
|
||||
}
|
||||
}
|
@ -0,0 +1,418 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors.support;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.data.DataOrganization;
|
||||
import ghidra.program.model.data.Structure;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.mem.*;
|
||||
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||
import ghidra.util.Msg;
|
||||
|
||||
/**
|
||||
* <code>PCodeTestControlBlock</code> data is read from each binary test file and
|
||||
* identified by the MAIN_CONTROL_BLOCK_MAGIC 64-bit character field value at the start of the
|
||||
* data structure. Only one instance of this should exist within the binary.
|
||||
*/
|
||||
public class PCodeTestControlBlock extends PCodeTestAbstractControlBlock {
|
||||
|
||||
static final String INITIAL_FUNCTION_NAME = "<NONE>";
|
||||
static final String UNKNOWN_FUNCTION_NAME = "<UNKNOWN>";
|
||||
|
||||
private static final String MAIN_CONTROL_BLOCK_MAGIC = "AbCdEFgH";
|
||||
|
||||
private static Structure testInfoStruct; // TestInfo structure
|
||||
private static Structure groupInfoStruct; // GroupInfo structure
|
||||
|
||||
private final AddressSetView restrictedSet;
|
||||
|
||||
public final PCodeTestFile testFile;
|
||||
public final String cachedProgramPath;
|
||||
|
||||
private List<PCodeTestGroup> testGroups; // test group data
|
||||
|
||||
// TestInfo data read from program memory
|
||||
private Address onPassFunctionAddress;
|
||||
private Address onErrorFunctionAddress;
|
||||
private Address onDoneFunctionAddress;
|
||||
private Address sprintfFunctionAddress;
|
||||
private Address sprintfBufferAddress;
|
||||
|
||||
// TestInfo structure offsets for runtime use
|
||||
private int numPassOffset;
|
||||
private int numFailOffset;
|
||||
private int lastTestPosOffset;
|
||||
private int lastErrorLineOffset;
|
||||
private int lastErrorFileOffset;
|
||||
private int lastFuncOffset;
|
||||
|
||||
private int sprintfEnableOffset;
|
||||
|
||||
private final PCodeTestResults testResults;
|
||||
|
||||
/**
|
||||
* Construct test control block instance for the specified
|
||||
* program. Create TestInfo structure data within program if requested.
|
||||
* @param program program containing control block structure
|
||||
* @param restrictedSet the restricted memory area which should be searched
|
||||
* for control structures
|
||||
* @param testInfoStructAddr address of Main TestInfo structure
|
||||
* @param testFile original binary test file
|
||||
* @param cachedProgramPath program path within program file cache
|
||||
* @param applyStruct create structure Data within program if true
|
||||
* @throws InvalidControlBlockException
|
||||
* @throws CodeUnitInsertionException if applyStruct failed
|
||||
*/
|
||||
private PCodeTestControlBlock(Program program, AddressSetView restrictedSet,
|
||||
Address testInfoStructAddr, PCodeTestFile testFile, String cachedProgramPath,
|
||||
boolean applyStruct, PCodeTestResults testResults)
|
||||
throws InvalidControlBlockException, CodeUnitInsertionException {
|
||||
super(program, testInfoStructAddr, testInfoStruct);
|
||||
|
||||
this.restrictedSet = restrictedSet;
|
||||
this.testFile = testFile;
|
||||
this.cachedProgramPath = cachedProgramPath;
|
||||
this.testResults = testResults;
|
||||
|
||||
readControlBlock(applyStruct);
|
||||
|
||||
numPassOffset = getStructureComponent(infoProgramStruct, "numpass");
|
||||
numFailOffset = getStructureComponent(infoProgramStruct, "numfail");
|
||||
lastTestPosOffset = getStructureComponent(infoProgramStruct, "lastTestPos");
|
||||
lastErrorLineOffset = getStructureComponent(infoProgramStruct, "lastErrorLine");
|
||||
lastErrorFileOffset = getStructureComponent(infoProgramStruct, "lastErrorFile");
|
||||
lastFuncOffset = getStructureComponent(infoProgramStruct, "lastFunc");
|
||||
|
||||
sprintfEnableOffset = getStructureComponent(infoProgramStruct, "sprintf5Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Main TestInfo structure within memory and return instance of PCodeTestControlBlock
|
||||
* @param program
|
||||
* @param testFile original binary test file
|
||||
* @param restrictedSet a restricted set to be searched for control structures
|
||||
* @param cachedProgramPath program path within program file cache
|
||||
* @param testInfoStruct TestInfo structure definition
|
||||
* @param groupInfoStruct GroupInfo structure definition
|
||||
* @param applyStruct create structure Data within program if true
|
||||
* @param testResults test results storage object
|
||||
* @return instance of PCodeTestControlBlock
|
||||
* @throws InvalidControlBlockException
|
||||
* @throws CodeUnitInsertionException
|
||||
*/
|
||||
static PCodeTestControlBlock getMainControlBlock(Program program, PCodeTestFile testFile,
|
||||
AddressSetView restrictedSet, String cachedProgramPath, Structure testInfoStruct,
|
||||
Structure groupInfoStruct, boolean applyStruct, PCodeTestResults testResults)
|
||||
throws InvalidControlBlockException, CodeUnitInsertionException {
|
||||
|
||||
PCodeTestControlBlock.testInfoStruct = testInfoStruct;
|
||||
PCodeTestControlBlock.groupInfoStruct = groupInfoStruct;
|
||||
|
||||
Memory memory = program.getMemory();
|
||||
byte[] magicBytes = getCharArrayBytes(program, MAIN_CONTROL_BLOCK_MAGIC);
|
||||
|
||||
Address startOfControlBlock = findBytes(memory, restrictedSet, magicBytes);
|
||||
if (startOfControlBlock == null) {
|
||||
throw new InvalidControlBlockException("TestInfo structure not found");
|
||||
}
|
||||
|
||||
return new PCodeTestControlBlock(program, restrictedSet, startOfControlBlock, testFile,
|
||||
cachedProgramPath, applyStruct, testResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + ":" + testFile;
|
||||
}
|
||||
|
||||
public List<PCodeTestGroup> getTestGroups() {
|
||||
return testGroups;
|
||||
}
|
||||
|
||||
public Address getBreakOnDoneAddress() {
|
||||
return onDoneFunctionAddress;
|
||||
}
|
||||
|
||||
public Address getBreakOnPassAddress() {
|
||||
return onPassFunctionAddress;
|
||||
}
|
||||
|
||||
public Address getBreakOnErrorAddress() {
|
||||
return onErrorFunctionAddress;
|
||||
}
|
||||
|
||||
public Address getSprintf5Address() {
|
||||
return sprintfFunctionAddress;
|
||||
}
|
||||
|
||||
public Address getPrintfBufferAddress() {
|
||||
return sprintfBufferAddress;
|
||||
}
|
||||
|
||||
public PCodeTestResults getTestResults() {
|
||||
return testResults;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readControlBlock(boolean applyStruct)
|
||||
throws InvalidControlBlockException, CodeUnitInsertionException {
|
||||
|
||||
super.readControlBlock(applyStruct);
|
||||
|
||||
int ptrSzOffset = getStructureComponent(infoProgramStruct, "ptrSz");
|
||||
int byteOrderOffset = getStructureComponent(infoProgramStruct, "byteOrder");
|
||||
int onPassPtrOffset = getStructureComponent(infoProgramStruct, "onPass");
|
||||
int onErrorPtrOffset = getStructureComponent(infoProgramStruct, "onError");
|
||||
int onDonePtrOffset = getStructureComponent(infoProgramStruct, "onDone");
|
||||
|
||||
int sprintfPtrOffset = getStructureComponent(infoProgramStruct, "sprintf5");
|
||||
int sprintfBufferPtrOffset = getStructureComponent(infoProgramStruct, "sprintf5buffer");
|
||||
|
||||
if (applyStruct) {
|
||||
forceCodePointer(infoStructAddr.add(onPassPtrOffset));
|
||||
forceCodePointer(infoStructAddr.add(onErrorPtrOffset));
|
||||
forceCodePointer(infoStructAddr.add(onDonePtrOffset));
|
||||
forceCodePointer(infoStructAddr.add(sprintfBufferPtrOffset));
|
||||
}
|
||||
|
||||
DumbMemBufferImpl memBuffer = new DumbMemBufferImpl(program.getMemory(), infoStructAddr);
|
||||
try {
|
||||
|
||||
// Check byte-order
|
||||
int byteOrder = memBuffer.getInt(byteOrderOffset);
|
||||
if (byteOrder != 0x1020304) {
|
||||
throw new InvalidControlBlockException(
|
||||
"TestInfo @ " + infoStructAddr.toString(true) +
|
||||
" has invalid byteOrder - language endianess may be incorrect (" +
|
||||
Integer.toHexString(byteOrder) + ")");
|
||||
}
|
||||
|
||||
// Check pointer size
|
||||
// Must adjust size recorded by compiler
|
||||
int ptrSize = memBuffer.getInt(ptrSzOffset);
|
||||
DataOrganization dataOrganization = program.getDataTypeManager().getDataOrganization();
|
||||
ptrSize *= dataOrganization.getCharSize();
|
||||
if (ptrSize < 2 || ptrSize > 8) {
|
||||
throw new InvalidControlBlockException("TestInfo @ " +
|
||||
infoStructAddr.toString(true) + " has unsupported pointer size: " + ptrSize);
|
||||
}
|
||||
if (ptrSize != pointerSize) {
|
||||
String id =
|
||||
program.getLanguageID() + ":" + program.getCompilerSpec().getCompilerSpecID();
|
||||
Msg.warn(this, "TestInfo @ " + infoStructAddr.toString(true) + " ptrSz=" + ptrSize +
|
||||
" differs from data-organization size of " + pointerSize + " (" + id + ")");
|
||||
}
|
||||
|
||||
// get onPass function pointer
|
||||
onPassFunctionAddress = readCodePointer(memBuffer, onPassPtrOffset, applyStruct);
|
||||
|
||||
// get onError function pointer
|
||||
onErrorFunctionAddress = readCodePointer(memBuffer, onErrorPtrOffset, applyStruct);
|
||||
|
||||
// get onDone function pointer
|
||||
onDoneFunctionAddress = readCodePointer(memBuffer, onDonePtrOffset, applyStruct);
|
||||
|
||||
// get sprintf function pointer
|
||||
sprintfFunctionAddress = readCodePointer(memBuffer, sprintfPtrOffset, applyStruct);
|
||||
|
||||
// get sprintf buffer pointer
|
||||
sprintfBufferAddress = readCodePointer(memBuffer, sprintfBufferPtrOffset, applyStruct);
|
||||
|
||||
}
|
||||
catch (MemoryAccessException e) {
|
||||
throw new InvalidControlBlockException("TestInfo program read error", e);
|
||||
}
|
||||
|
||||
// Find all test groups by locating corresponding TestInfo structure
|
||||
findTestGroups(applyStruct);
|
||||
|
||||
}
|
||||
|
||||
private void findTestGroups(boolean applyStruct)
|
||||
throws InvalidControlBlockException, CodeUnitInsertionException {
|
||||
|
||||
Memory memory = program.getMemory();
|
||||
|
||||
byte[] groupStructMagicBytes =
|
||||
getCharArrayBytes(program, PCodeTestGroupControlBlock.GROUP_CONTROL_BLOCK_MAGIC);
|
||||
|
||||
testGroups = new ArrayList<>();
|
||||
|
||||
AddressSet set = new AddressSet(restrictedSet);
|
||||
while (true) {
|
||||
|
||||
Address startOfControlBlock = findBytes(memory, set, groupStructMagicBytes);
|
||||
if (startOfControlBlock == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
PCodeTestGroupControlBlock controlBlock = new PCodeTestGroupControlBlock(program,
|
||||
startOfControlBlock, groupInfoStruct, applyStruct, this);
|
||||
PCodeTestGroup testGroup = new PCodeTestGroup(controlBlock);
|
||||
testGroups.add(testGroup);
|
||||
|
||||
// Remove previously searched addresses from search address set
|
||||
Address endAddr = startOfControlBlock.add(groupInfoStruct.getLength()).previous();
|
||||
AddressRange nextRange = set.getFirstRange();
|
||||
while (nextRange != null && !nextRange.contains(endAddr)) {
|
||||
set.delete(nextRange);
|
||||
nextRange = set.getFirstRange();
|
||||
}
|
||||
if (set.contains(endAddr)) {
|
||||
set = set.subtract(new AddressSet(set.getMinAddress(),
|
||||
startOfControlBlock.add(groupInfoStruct.getLength()).previous()));
|
||||
}
|
||||
}
|
||||
|
||||
if (testGroups.size() == 0) {
|
||||
throw new InvalidControlBlockException(
|
||||
"P-Code test binary does not define any test groups");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Diable sprintf use within P-Code test emulation.
|
||||
* @param emuTestRunner emulator test runner
|
||||
* @param enable sprintf enablement
|
||||
*/
|
||||
void setSprintfEnabled(EmulatorTestRunner emuTestRunner, boolean enable) {
|
||||
Address addr =
|
||||
getMirroredDataAddress(emuTestRunner, infoStructAddr.add(sprintfEnableOffset));
|
||||
emuWrite(emuTestRunner.getEmulatorHelper(), addr, SIZEOF_U4, enable ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 'numpass' field value from emulation memory state
|
||||
* @param emuTestRunner emulator test runner
|
||||
* @return 'numpass' field value
|
||||
*/
|
||||
int getNumberPassed(EmulatorTestRunner emuTestRunner) {
|
||||
Address addr = getMirroredDataAddress(emuTestRunner, infoStructAddr.add(numPassOffset));
|
||||
return (int) emuRead(emuTestRunner.getEmulatorHelper(), addr, SIZEOF_U4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set 'numpass' field value within emulation memory state
|
||||
* @param emuTestRunner emulator test runner
|
||||
* @param value field value
|
||||
*/
|
||||
void setNumberPassed(EmulatorTestRunner emuTestRunner, int value) {
|
||||
Address addr = getMirroredDataAddress(emuTestRunner, infoStructAddr.add(numPassOffset));
|
||||
emuWrite(emuTestRunner.getEmulatorHelper(), addr, SIZEOF_U4, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 'numfail' field value from emulation memory state
|
||||
* @param emuTestRunner emulator test runner
|
||||
* @return 'numfail' field value
|
||||
*/
|
||||
int getNumberFailed(EmulatorTestRunner emuTestRunner) {
|
||||
Address addr = getMirroredDataAddress(emuTestRunner, infoStructAddr.add(numFailOffset));
|
||||
return (int) emuRead(emuTestRunner.getEmulatorHelper(), addr, SIZEOF_U4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set 'numfail' field value within emulation memory state
|
||||
* @param emuTestRunner emulator test runner
|
||||
* @param value field value
|
||||
*/
|
||||
void setNumberFailed(EmulatorTestRunner emuTestRunner, int value) {
|
||||
Address addr = getMirroredDataAddress(emuTestRunner, infoStructAddr.add(numFailOffset));
|
||||
emuWrite(emuTestRunner.getEmulatorHelper(), addr, SIZEOF_U4, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 'lastTestPos' field value from emulation memory state
|
||||
* @param emuTestRunner emulator test runner
|
||||
* @return 'lastTestPos' field value
|
||||
*/
|
||||
int getLastTestIndex(EmulatorTestRunner emuTestRunner) {
|
||||
Address addr = getMirroredDataAddress(emuTestRunner, infoStructAddr.add(lastTestPosOffset));
|
||||
return (int) emuRead(emuTestRunner.getEmulatorHelper(), addr, SIZEOF_U4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 'lastErrorLine' field value from emulation memory state
|
||||
* @param emuTestRunner emulator test runner
|
||||
* @return 'lastErrorLine' field value
|
||||
*/
|
||||
int getLastErrorLine(EmulatorTestRunner emuTestRunner) {
|
||||
Address addr =
|
||||
getMirroredDataAddress(emuTestRunner, infoStructAddr.add(lastErrorLineOffset));
|
||||
return (int) emuRead(emuTestRunner.getEmulatorHelper(), addr, SIZEOF_U4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 'lastErrorFile' string value from emulation memory state. Must follow string
|
||||
* pointer contained within lastErrorFile field.
|
||||
* @param emuTestRunner emulator test runner
|
||||
* @return 'lastErrorLine' field value
|
||||
*/
|
||||
String getLastErrorFile(EmulatorTestRunner emuTestRunner) {
|
||||
Address addr =
|
||||
getMirroredDataAddress(emuTestRunner, infoStructAddr.add(lastErrorFileOffset));
|
||||
long fileNameOffset = emuRead(emuTestRunner.getEmulatorHelper(), addr, pointerSize);
|
||||
addr = addr.getNewAddress(fileNameOffset, true);
|
||||
addr = getMirroredDataAddress(emuTestRunner, addr);
|
||||
return emuReadString(emuTestRunner.getEmulatorHelper(), addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the last test function to be run
|
||||
* @param emuTestRunner
|
||||
* @return last test function name
|
||||
*/
|
||||
String getLastFunctionName(EmulatorTestRunner emuTestRunner, TestLogger logger,
|
||||
PCodeTestGroup activeGroup) {
|
||||
Address ptrStorageAddr = infoStructAddr.add(lastFuncOffset);
|
||||
Address ptrAddr = getMirroredDataAddress(emuTestRunner, ptrStorageAddr);
|
||||
long funcNameOffset = emuRead(emuTestRunner.getEmulatorHelper(), ptrAddr, pointerSize);
|
||||
Address strAddr = ptrAddr.getNewAddress(funcNameOffset, true);
|
||||
strAddr = getMirroredDataAddress(emuTestRunner, strAddr);
|
||||
String fnName = emuReadString(emuTestRunner.getEmulatorHelper(), strAddr);
|
||||
if ("none".equals(fnName)) {
|
||||
if (logger != null) {
|
||||
logger.log(activeGroup, "ERROR last executed function name pointer stored at " +
|
||||
ptrStorageAddr + " has not been set (reported as <NONE>)");
|
||||
}
|
||||
return INITIAL_FUNCTION_NAME;
|
||||
}
|
||||
String altName = null;
|
||||
if (!fnName.endsWith(PCodeTestGroupControlBlock.TEST_GROUP_FUNCTION_SUFFIX)) {
|
||||
altName = fnName + PCodeTestGroupControlBlock.TEST_GROUP_FUNCTION_SUFFIX;
|
||||
}
|
||||
if (activeGroup != null) {
|
||||
if (activeGroup.controlBlock.getFunctionInfo(fnName) != null) {
|
||||
return fnName;
|
||||
}
|
||||
if (altName != null && activeGroup.controlBlock.getFunctionInfo(altName) != null) {
|
||||
return fnName;
|
||||
}
|
||||
}
|
||||
if (logger != null) {
|
||||
logger.log(activeGroup,
|
||||
"ERROR last executed function name pointer stored at " + ptrStorageAddr +
|
||||
" was improperly set (reported as <UNKNOWN>, pointer=" + strAddr + ")");
|
||||
}
|
||||
return UNKNOWN_FUNCTION_NAME;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors.support;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class PCodeTestFile {
|
||||
|
||||
public final File file;
|
||||
public final String fileReferencePath;
|
||||
|
||||
public PCodeTestFile(File f, String fileReferencePath) {
|
||||
this.file = f;
|
||||
this.fileReferencePath = fileReferencePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return fileReferencePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((file == null) ? 0 : file.hashCode());
|
||||
result = prime * result + ((fileReferencePath == null) ? 0 : fileReferencePath.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
PCodeTestFile other = (PCodeTestFile) obj;
|
||||
if (file == null) {
|
||||
if (other.file != null)
|
||||
return false;
|
||||
}
|
||||
else if (!file.equals(other.file))
|
||||
return false;
|
||||
if (fileReferencePath == null) {
|
||||
if (other.fileReferencePath != null)
|
||||
return false;
|
||||
}
|
||||
else if (!fileReferencePath.equals(other.fileReferencePath))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors.support;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.symbol.Symbol;
|
||||
import ghidra.program.model.symbol.SymbolUtilities;
|
||||
import ghidra.util.Msg;
|
||||
|
||||
/**
|
||||
* <code>PCodeTestGroup</code> identifies a test group function and its corresponding
|
||||
* PCodeTestGroupControlBlock.
|
||||
*/
|
||||
public class PCodeTestGroup implements Comparable<PCodeTestGroup> {
|
||||
|
||||
/**
|
||||
* All test-group function names defined within the test binary must start with "main_"
|
||||
*/
|
||||
public static final String FUNCTION_NAME_PREFIX = "main_";
|
||||
|
||||
public final String testGroupName;
|
||||
public final Address functionEntryPtr;
|
||||
// public final int testCount; // TODO: not yet fully implemented - do not use!
|
||||
|
||||
public final PCodeTestControlBlock mainTestControlBlock;
|
||||
public final PCodeTestGroupControlBlock controlBlock;
|
||||
|
||||
private ArrayList<String> testFailures = new ArrayList<>();
|
||||
|
||||
PCodeTestGroup(PCodeTestGroupControlBlock controlBlock) {
|
||||
this.testGroupName = controlBlock.getTestGroupName();
|
||||
this.functionEntryPtr = controlBlock.getTestGroupMainAddress();
|
||||
// this.testCount = testCount;
|
||||
this.controlBlock = controlBlock;
|
||||
this.mainTestControlBlock = controlBlock.mainTestControlBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return testGroupName + "@" + functionEntryPtr;
|
||||
}
|
||||
|
||||
void testPassed(String testName, String errFileName, int errLineNum, Program program,
|
||||
TestLogger logger) {
|
||||
mainTestControlBlock.getTestResults().addPassResult(testGroupName, testName);
|
||||
}
|
||||
|
||||
void testFailed(String testName, String errFileName, int errLineNum, boolean callOtherFailure,
|
||||
Program program, TestLogger logger) {
|
||||
if (callOtherFailure) {
|
||||
mainTestControlBlock.getTestResults().addCallOtherResult(testGroupName, testName);
|
||||
}
|
||||
else {
|
||||
mainTestControlBlock.getTestResults().addFailResult(testGroupName, testName);
|
||||
}
|
||||
String failure = testName;
|
||||
if (testName != null) {
|
||||
Symbol symbol = SymbolUtilities.getLabelOrFunctionSymbol(program, testName,
|
||||
err -> Msg.error(this, err));
|
||||
if (symbol != null) {
|
||||
failure += " @ " + symbol.getAddress().toString(true);
|
||||
}
|
||||
failure += " (" + errFileName + ":" + errLineNum + ")";
|
||||
}
|
||||
testFailures.add(failure);
|
||||
logger.log(this,
|
||||
"Test Failed: " + failure + (callOtherFailure ? " (callother error)" : ""));
|
||||
}
|
||||
|
||||
void severeTestFailure(String testName, String errFileName, int errLineNum, Program program,
|
||||
TestLogger logger) {
|
||||
mainTestControlBlock.getTestResults().addSevereFailResult(testGroupName, testName);
|
||||
testFailed(testName, errFileName, errLineNum, false, program, logger);
|
||||
}
|
||||
|
||||
void clearFailures() {
|
||||
testFailures.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of recorded emulation test failures
|
||||
*/
|
||||
public List<String> getTestFailures() {
|
||||
return new ArrayList<>(testFailures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return testGroupName.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof PCodeTestGroup)) {
|
||||
return false;
|
||||
}
|
||||
PCodeTestGroup other = (PCodeTestGroup) obj;
|
||||
return (controlBlock == other.controlBlock) && testGroupName.equals(other.testGroupName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(PCodeTestGroup o) {
|
||||
return testGroupName.compareTo(o.testGroupName);
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors.support;
|
||||
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.data.Structure;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||
|
||||
/**
|
||||
* <code>PCodeTestGroupControlBlock</code> corresponds to each test group contained within
|
||||
* a binary test file and identified by the GROUP_CONTROL_BLOCK_MAGIC 64-bit character
|
||||
* field value at the start of the data structure.
|
||||
*/
|
||||
public class PCodeTestGroupControlBlock extends PCodeTestAbstractControlBlock {
|
||||
|
||||
static String TEST_GROUP_NAME_SUFFIX = "_main";
|
||||
static String TEST_GROUP_FUNCTION_SUFFIX = "_Main";
|
||||
|
||||
static final String GROUP_CONTROL_BLOCK_MAGIC = "aBcDefGh";
|
||||
|
||||
public final PCodeTestControlBlock mainTestControlBlock;
|
||||
|
||||
private String testGroupName;
|
||||
private Address testGroupMainAddr;
|
||||
|
||||
/**
|
||||
* Construct test group control block instance for the specified
|
||||
* program. Create GroupInfo structure data within program if requested.
|
||||
* @param program
|
||||
* @param groupInfoStructAddr program address where structure resides
|
||||
* @param groupInfoStruct GroupInfo structure definition
|
||||
* @param applyStruct create GroupInfo structure data within program if true
|
||||
* @throws InvalidControlBlockException
|
||||
* @throws CodeUnitInsertionException if applyStruct failed
|
||||
*/
|
||||
PCodeTestGroupControlBlock(Program program, Address groupInfoStructAddr,
|
||||
Structure groupInfoStruct, boolean applyStruct,
|
||||
PCodeTestControlBlock mainTestControlBlock)
|
||||
throws InvalidControlBlockException, CodeUnitInsertionException {
|
||||
super(program, groupInfoStructAddr, groupInfoStruct);
|
||||
|
||||
this.mainTestControlBlock = mainTestControlBlock;
|
||||
|
||||
readControlBlock(applyStruct);
|
||||
|
||||
if (getNumberFunctions() < 1) {
|
||||
throw new InvalidControlBlockException("GroupInfo @ " + infoStructAddr.toString(true) +
|
||||
" does not define any functions: " + infoStructAddr);
|
||||
}
|
||||
|
||||
testGroupName = getFunctionInfo(0).functionName;
|
||||
if (!testGroupName.endsWith(TEST_GROUP_NAME_SUFFIX)) {
|
||||
throw new InvalidControlBlockException("GroupInfo @ " + infoStructAddr.toString(true) +
|
||||
" does not define <group>_main function as first function");
|
||||
}
|
||||
testGroupName =
|
||||
testGroupName.substring(0, testGroupName.length() - TEST_GROUP_NAME_SUFFIX.length());
|
||||
testGroupMainAddr = getFunctionInfo(0).functionAddr;
|
||||
|
||||
}
|
||||
|
||||
public String getTestGroupName() {
|
||||
return testGroupName;
|
||||
}
|
||||
|
||||
public Address getTestGroupMainAddress() {
|
||||
return testGroupMainAddr;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,334 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors.support;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Element;
|
||||
|
||||
public class PCodeTestResults {
|
||||
|
||||
private String jUnitName;
|
||||
|
||||
boolean summaryHasIngestErrors;
|
||||
boolean summaryHasRelocationErrors;
|
||||
boolean summaryHasDisassemblyErrors;
|
||||
|
||||
int summaryTotalAsserts;
|
||||
int summaryPassCount;
|
||||
int summaryFailCount;
|
||||
int summaryCallOtherCount;
|
||||
int summarySevereFailures;
|
||||
|
||||
long time;
|
||||
|
||||
// map keys formed with "<groupName>.<testName>" string
|
||||
private Map<String, TestResults> results = new HashMap<>();
|
||||
|
||||
PCodeTestResults(String jUnitName) {
|
||||
this.jUnitName = jUnitName;
|
||||
time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String getJUnitName() {
|
||||
return jUnitName;
|
||||
}
|
||||
|
||||
private static DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm");
|
||||
|
||||
public String getTime() {
|
||||
if (time == 0) {
|
||||
return null;
|
||||
}
|
||||
Date d = new Date(time);
|
||||
return dateFormat.format(d);
|
||||
}
|
||||
|
||||
public int getNumberOfTests() {
|
||||
return results.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return collection of group/testNames in the form "<groupName>.<testName>"
|
||||
*/
|
||||
public Collection<String> getGroupTestNames() {
|
||||
return results.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get groupName.testName combined into single string
|
||||
* @param groupName
|
||||
* @param testName
|
||||
* @return
|
||||
*/
|
||||
private String getGroupTestName(String groupName, String testName) {
|
||||
if (testName.endsWith(PCodeTestGroupControlBlock.TEST_GROUP_FUNCTION_SUFFIX)) {
|
||||
testName = testName.substring(0,
|
||||
testName.length() - PCodeTestGroupControlBlock.TEST_GROUP_FUNCTION_SUFFIX.length());
|
||||
}
|
||||
// Exclude any trailing digits from groupName which may have been appended to filename
|
||||
return groupName.replaceAll("\\d*$", "") + "." + testName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get results entry keyed by "<groupName>.<testName>"
|
||||
* @param groupTestName
|
||||
* @param create
|
||||
* @return
|
||||
*/
|
||||
TestResults getTestResults(String groupTestName, boolean create) {
|
||||
TestResults testResults = results.get(groupTestName);
|
||||
if (testResults == null && create) {
|
||||
testResults = new TestResults();
|
||||
results.put(groupTestName, testResults);
|
||||
}
|
||||
return testResults;
|
||||
}
|
||||
|
||||
void declareTest(String groupName, String testName, int totalAsserts) {
|
||||
String groupTestName = getGroupTestName(groupName, testName);
|
||||
getTestResults(groupTestName, true).totalAsserts = totalAsserts;
|
||||
summaryTotalAsserts += totalAsserts;
|
||||
}
|
||||
|
||||
public int getTotalAsserts(String groupName, String testName) {
|
||||
String groupTestName = getGroupTestName(groupName, testName);
|
||||
TestResults testResults = getTestResults(groupTestName, false);
|
||||
if (testResults != null) {
|
||||
return testResults.totalAsserts;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void addPassResult(String groupName, String testName) {
|
||||
String groupTestName = getGroupTestName(groupName, testName);
|
||||
getTestResults(groupTestName, true).passCount++;
|
||||
++summaryPassCount;
|
||||
}
|
||||
|
||||
public int getPassResult(String groupName, String testName) {
|
||||
String groupTestName = getGroupTestName(groupName, testName);
|
||||
TestResults testResults = getTestResults(groupTestName, false);
|
||||
if (testResults != null) {
|
||||
return testResults.passCount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void addFailResult(String groupName, String testName) {
|
||||
String groupTestName = getGroupTestName(groupName, testName);
|
||||
getTestResults(groupTestName, true).failCount++;
|
||||
summaryFailCount++;
|
||||
}
|
||||
|
||||
public int getFailResult(String groupName, String testName) {
|
||||
String groupTestName = getGroupTestName(groupName, testName);
|
||||
TestResults testResults = getTestResults(groupTestName, false);
|
||||
if (testResults != null) {
|
||||
return testResults.failCount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void addSevereFailResult(String groupName, String testName) {
|
||||
String groupTestName = getGroupTestName(groupName, testName);
|
||||
getTestResults(groupTestName, true).severeFailure = true;
|
||||
summarySevereFailures++;
|
||||
}
|
||||
|
||||
public boolean hadSevereFailure(String groupName, String testName) {
|
||||
String groupTestName = getGroupTestName(groupName, testName);
|
||||
TestResults testResults = getTestResults(groupTestName, false);
|
||||
if (testResults != null) {
|
||||
return testResults.severeFailure;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void addCallOtherResult(String groupName, String testName) {
|
||||
String groupTestName = getGroupTestName(groupName, testName);
|
||||
getTestResults(groupTestName, true).callOtherCount++;
|
||||
summaryCallOtherCount++;
|
||||
}
|
||||
|
||||
public int getCallOtherResult(String groupName, String testName) {
|
||||
String groupTestName = getGroupTestName(groupName, testName);
|
||||
TestResults testResults = getTestResults(groupTestName, false);
|
||||
if (testResults != null) {
|
||||
return testResults.callOtherCount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
results.clear();
|
||||
summaryHasIngestErrors = false;
|
||||
summaryHasRelocationErrors = false;
|
||||
summaryHasDisassemblyErrors = false;
|
||||
summaryTotalAsserts = 0;
|
||||
summaryPassCount = 0;
|
||||
summaryFailCount = 0;
|
||||
summaryCallOtherCount = 0;
|
||||
summarySevereFailures = 0;
|
||||
time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private static String XML_VERSION = "1";
|
||||
|
||||
public static String TAG_NAME = "PCodeTestResults";
|
||||
|
||||
public PCodeTestResults(Element root) {
|
||||
|
||||
if (!TAG_NAME.equals(root.getName())) {
|
||||
throw new IllegalArgumentException("Unsupported root element: " + root.getName());
|
||||
}
|
||||
String ver = root.getAttributeValue("VERSION");
|
||||
if (!XML_VERSION.equals(ver)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unsupported XML format version " + ver + ", required format is " + XML_VERSION);
|
||||
}
|
||||
|
||||
jUnitName = root.getAttributeValue("JUNIT");
|
||||
|
||||
time = 0;
|
||||
String timeStr = root.getAttributeValue("TIME");
|
||||
if (timeStr != null) {
|
||||
try {
|
||||
time = Long.parseLong(timeStr);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
summaryHasIngestErrors = getAttributeValue(root, "INGEST_ERR", false);
|
||||
summaryHasRelocationErrors = getAttributeValue(root, "RELOC_ERR", false);
|
||||
summaryHasDisassemblyErrors = getAttributeValue(root, "DIS_ERR", false);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Element> elementList = root.getChildren("TestResults");
|
||||
for (Element element : elementList) {
|
||||
|
||||
String testName = element.getAttributeValue("NAME");
|
||||
if (testName == null) {
|
||||
throw new IllegalArgumentException("Invalid TestResults element in XML");
|
||||
}
|
||||
TestResults testResults = new TestResults();
|
||||
testResults.totalAsserts = getAttributeValue(element, "TOTAL_ASSERTS", 0);
|
||||
testResults.passCount = getAttributeValue(element, "PASS", 0);
|
||||
testResults.failCount = getAttributeValue(element, "FAIL", 0);
|
||||
testResults.callOtherCount = getAttributeValue(element, "CALLOTHER", 0);
|
||||
testResults.severeFailure = getAttributeValue(element, "SEVERE_FAILURE", false);
|
||||
|
||||
summaryTotalAsserts += testResults.totalAsserts;
|
||||
summaryPassCount += testResults.passCount;
|
||||
summaryFailCount += testResults.failCount;
|
||||
summaryCallOtherCount += testResults.callOtherCount;
|
||||
if (testResults.severeFailure) {
|
||||
++summarySevereFailures;
|
||||
}
|
||||
|
||||
results.put(testName, testResults);
|
||||
}
|
||||
}
|
||||
|
||||
int getAttributeValue(Element element, String attrName, int defaultValue) {
|
||||
String val = element.getAttributeValue(attrName);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(val);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
boolean getAttributeValue(Element element, String attrName, boolean defaultValue) {
|
||||
String val = element.getAttributeValue(attrName);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Boolean.valueOf(val);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Element saveToXml() {
|
||||
|
||||
Element root = new Element("PCodeTestResults");
|
||||
root.setAttribute(new Attribute("VERSION", XML_VERSION));
|
||||
root.setAttribute(new Attribute("JUNIT", jUnitName));
|
||||
if (time != 0) {
|
||||
root.setAttribute(new Attribute("TIME", Long.toString(time)));
|
||||
}
|
||||
|
||||
if (summaryHasIngestErrors) {
|
||||
root.setAttribute(new Attribute("INGEST_ERR", "TRUE"));
|
||||
}
|
||||
|
||||
if (summaryHasRelocationErrors) {
|
||||
root.setAttribute(new Attribute("RELOC_ERR", "TRUE"));
|
||||
}
|
||||
|
||||
if (summaryHasDisassemblyErrors) {
|
||||
root.setAttribute(new Attribute("DIS_ERR", "TRUE"));
|
||||
}
|
||||
|
||||
ArrayList<String> testNames = new ArrayList<>(results.keySet());
|
||||
Collections.sort(testNames);
|
||||
|
||||
for (String testName : testNames) {
|
||||
TestResults testResults = results.get(testName);
|
||||
Element element = new Element("TestResults");
|
||||
element.setAttribute(new Attribute("NAME", testName));
|
||||
element.setAttribute(
|
||||
new Attribute("TOTAL_ASSERTS", Integer.toString(testResults.totalAsserts)));
|
||||
element.setAttribute(new Attribute("PASS", Integer.toString(testResults.passCount)));
|
||||
element.setAttribute(new Attribute("FAIL", Integer.toString(testResults.failCount)));
|
||||
element.setAttribute(
|
||||
new Attribute("CALLOTHER", Integer.toString(testResults.callOtherCount)));
|
||||
if (testResults.severeFailure) {
|
||||
element.setAttribute(new Attribute("SEVERE_FAILURE", "TRUE"));
|
||||
}
|
||||
root.addContent(element);
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
static class TestResults {
|
||||
int totalAsserts;
|
||||
int passCount;
|
||||
int failCount;
|
||||
int callOtherCount;
|
||||
|
||||
boolean severeFailure = false;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// TODO Auto-generated method stub
|
||||
return "{" + passCount + "/" + failCount + "/" + callOtherCount + "(" + totalAsserts +
|
||||
")}";
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,32 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors.support;
|
||||
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.test.processors.support.EmulatorTestRunner.DumpFormat;
|
||||
|
||||
interface TestLogger {
|
||||
|
||||
void logState(EmulatorTestRunner testRunner);
|
||||
|
||||
public void logState(EmulatorTestRunner emulatorTestRunner, Address dumpAddr, int dumpSize,
|
||||
int elementSize, DumpFormat elementFormat, String comment);
|
||||
|
||||
void log(PCodeTestGroup testGroup, String msg);
|
||||
|
||||
void log(PCodeTestGroup testGroup, String msg, Throwable t);
|
||||
|
||||
}
|
148
Ghidra/Features/Base/src/main/resources/pcodetest/chunk1.hinc
Normal file
148
Ghidra/Features/Base/src/main/resources/pcodetest/chunk1.hinc
Normal file
@ -0,0 +1,148 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
|
||||
<TITLE>CUnit Processor Emulation Test Results"</TITLE>
|
||||
|
||||
<STYLE TYPE="text/css">
|
||||
|
||||
div { font-family: verdana; }
|
||||
td { background-color: white; font-family: verdana; }
|
||||
|
||||
.r90 { -moz-transform: rotate(-90deg); -webkit-transform: rotate(-90deg); margin-bottom: 8; width: 1em; line-height: 1ex; }
|
||||
|
||||
.shade { background-color:#f0f8ff; }
|
||||
.bad { background-color:#ffefef; }
|
||||
.good { background-color:#efffef; }
|
||||
|
||||
.TestNameHead { width: 300; background-color:#efefef; font-weight: bold; font-family: verdana; }
|
||||
.DateTimeHead { width: 80; background-color:#efefef; font-weight: bold; font-family: verdana; }
|
||||
.ResultSummaryHead { width: 80; background-color:#efefef; font-weight: bold; font-family: verdana; }
|
||||
|
||||
.ResultHead { background-color:#efefef; font-family: verdana; font-size: 90%; }
|
||||
.GroupHead { height: 30; background-color:#efefef; font-weight: bold; font-family: verdana; text-align: left; overflow: hidden; text-overflow: ellipsis; }
|
||||
|
||||
.TestName { height: 35; width: 295; padding-left: 5; font-family: verdana; font-size: 90%; }
|
||||
.DateTime { height: 35; width: 80; font-family: verdana; font-size: 75%; text-align: center; }
|
||||
.ResultSummary { height: 35; width: 80; font-family: verdana; font-size: 75%; text-align: center; }
|
||||
|
||||
.Result { height: 35; font-family: verdana; font-size: 75%; text-align: center; }
|
||||
|
||||
.message { font-family: verdana; font-style: italic; font-size: 75%; padding-left: 5; background-color:#efef00; }
|
||||
|
||||
</STYLE>
|
||||
|
||||
<SCRIPT>
|
||||
|
||||
headerMinHeight = 250;
|
||||
headerMaxHeight = 450;
|
||||
|
||||
function pageInit() {
|
||||
topLeftTable = document.getElementById("topLeftTable");
|
||||
hsTableTop = document.getElementById("hsTableTop");
|
||||
vsTableLeft = document.getElementById("vsTableLeft");
|
||||
sTableRight = document.getElementById("sTableRight");
|
||||
|
||||
headerTable1 = document.getElementById("headerTable1");
|
||||
headerTable2 = document.getElementById("headerTable2");
|
||||
|
||||
messageLayer = document.getElementById("messageLayer");
|
||||
|
||||
setHeaderHeight(headerMinHeight);
|
||||
|
||||
setLayerPositions();
|
||||
|
||||
window.addEventListener("resize", onResize, false);
|
||||
|
||||
onResize();
|
||||
}
|
||||
|
||||
function setLayerPositions() {
|
||||
// set top/left corner of each layer
|
||||
|
||||
vsTableLeft.style.top = topLeftTable.offsetTop + topLeftTable.offsetHeight;
|
||||
vsTableLeft.style.left = topLeftTable.offsetLeft;
|
||||
|
||||
hsTableTop.style.top = topLeftTable.offsetTop;
|
||||
hsTableTop.style.left = topLeftTable.offsetLeft + topLeftTable.offsetWidth;
|
||||
|
||||
sTableRight.style.top = vsTableLeft.offsetTop;
|
||||
sTableRight.style.left = hsTableTop.offsetLeft;
|
||||
}
|
||||
|
||||
function onResize() {
|
||||
// adjust layer viewport dimensions
|
||||
|
||||
sTableRight.style.width = window.innerWidth - sTableRight.offsetLeft;
|
||||
sTableRight.style.height = window.innerHeight - sTableRight.offsetTop;
|
||||
|
||||
var pad = sTableRight.offsetHeight - sTableRight.clientHeight;
|
||||
var vsTableLeftHeight = window.innerHeight - vsTableLeft.offsetTop - pad;
|
||||
vsTableLeft.style.height = vsTableLeftHeight;
|
||||
|
||||
pad = sTableRight.offsetWidth - sTableRight.clientWidth;
|
||||
hsTableTop.style.width = window.innerWidth - hsTableTop.offsetLeft - pad;
|
||||
|
||||
// NOTE: The -4 adjustment resolved scrollbar problem
|
||||
messageLayer.style.top = vsTableLeft.offsetTop + vsTableLeftHeight - 4;
|
||||
messageLayer.style.width = vsTableLeft.offsetWidth;
|
||||
messageLayer.style.height = pad;
|
||||
}
|
||||
|
||||
function onScrollDiv() {
|
||||
// perform synchronized scroll
|
||||
vsTableLeft.scrollTop = sTableRight.scrollTop;
|
||||
hsTableTop.scrollLeft = sTableRight.scrollLeft;
|
||||
}
|
||||
|
||||
function toggleHeaderHeight() {
|
||||
var h = headerTable1.offsetHeight <= headerMinHeight ? headerMaxHeight : headerMinHeight;
|
||||
setHeaderHeight(h);
|
||||
}
|
||||
|
||||
function setHeaderHeight(h) {
|
||||
headerTable1.style.height = h;
|
||||
headerTable2.style.height = h;
|
||||
|
||||
setLayerPositions();
|
||||
|
||||
onResize();
|
||||
}
|
||||
|
||||
function mouseOverHeader() {
|
||||
showMessage("<font>Click header to shrink/expand</font>");
|
||||
}
|
||||
|
||||
function mouseOutHeader() {
|
||||
hideMessage();
|
||||
}
|
||||
|
||||
function showMessage(msg) {
|
||||
//window.alert(messageLayer.offsetTop + " " + messageLayer.offsetLeft + " " + messageLayer.innerHTML);
|
||||
messageLayer.innerHTML=msg;
|
||||
messageLayer.style.visibility = "visible";
|
||||
}
|
||||
|
||||
function hideMessage() {
|
||||
messageLayer.style.visibility = "hidden";
|
||||
}
|
||||
|
||||
</SCRIPT>
|
||||
|
||||
</HEAD>
|
||||
<BODY onLoad="pageInit()">
|
||||
|
||||
<DIV ID="messageLayer" CLASS="message" STYLE="position: absolute; top: 0; left: 0; z-index: 2; visibility: hidden;">MESSAGE</DIV>
|
||||
|
||||
<DIV ID="topLeftTable" STYLE="position: absolute; top: 0; left: 0;">
|
||||
<TABLE ID="headerTable1" BORDER=1 CELLSPACING=0 CELLPADDING=0 style="height: 100; cursor: pointer;" onclick="toggleHeaderHeight()" onmouseover="mouseOverHeader()" onmouseout="mouseOutHeader()">
|
||||
<TR>
|
||||
<TD CLASS="TestNameHead"><DIV STYLE="position:absolute; left: 8px; top: 5px; ">P-Code Test Results</DIV><DIV STYLE="position:absolute; left: 140px; bottom: 5px; "><font color="green" size="2">Pass</font>/<font color="red" size="2">Fail</font>/<font color="orange" size="2">CallOther</font></DIV></TD>
|
||||
<TD CLASS="DateTimeHead" ALIGN="center" VALIGN="bottom"><DIV CLASS="r90">DATE/TIME</DIV></TD>
|
||||
<TD CLASS="ResultSummaryHead" ALIGN="center" VALIGN="bottom"><DIV CLASS="r90">SUMMARY</DIV></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<DIV ID="hsTableTop" STYLE="position: absolute; overflow-x: hidden;">
|
||||
<TABLE ID="headerTable2" BORDER=1 CELLSPACING=0 CELLPADDING=0 style="height: 100; cursor: pointer;" onclick="toggleHeaderHeight()" onmouseover="mouseOverHeader()" onmouseout="mouseOutHeader()">
|
||||
<!-- top of hsTableTop (p-code test/group headers) -->
|
@ -0,0 +1,8 @@
|
||||
<!-- end of hsTableTop (p-code test/group headers) -->
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<DIV ID="vsTableLeft" STYLE="position: absolute; overflow-y: hidden;">
|
||||
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>
|
||||
<!-- top of vsTableLeft (p-code test/group names, date/time, and summary) -->
|
||||
|
@ -0,0 +1,7 @@
|
||||
<!-- end of vsTableLeft (p-code test/group names, date/time, and summary) -->
|
||||
</TABLE>
|
||||
</DIV>
|
||||
|
||||
<DIV ID="sTableRight" STYLE="position: absolute; overflow: scroll;" onscroll="onScrollDiv()">
|
||||
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0>
|
||||
<!-- top of sTableRight (test results) -->
|
@ -0,0 +1,6 @@
|
||||
<!-- bottom of sTableRight (test results) -->
|
||||
</TABLE>
|
||||
</DIV>
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
@ -15,6 +15,9 @@
|
||||
*/
|
||||
//@category CodeAnalysis
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import generic.jar.ResourceFile;
|
||||
import ghidra.app.analyzers.Patterns;
|
||||
import ghidra.app.script.GhidraScript;
|
||||
@ -24,9 +27,6 @@ import ghidra.program.model.mem.Memory;
|
||||
import ghidra.util.bytesearch.*;
|
||||
import ghidra.util.constraint.ProgramDecisionTree;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DumpMissedStarts extends GhidraScript implements PatternFactory {
|
||||
private static int bufsize = 20;
|
||||
private DummyMatchAction dummyaction;
|
||||
@ -43,10 +43,10 @@ public class DumpMissedStarts extends GhidraScript implements PatternFactory {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean detectThunk(Function func, CodeUnit cunit) {
|
||||
if (cunit == null)
|
||||
private boolean detectThunk(Function func, CodeUnit cu) {
|
||||
if (cu == null)
|
||||
return true;
|
||||
if (cunit instanceof Data)
|
||||
if (cu instanceof Data)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@ -65,12 +65,12 @@ public class DumpMissedStarts extends GhidraScript implements PatternFactory {
|
||||
File file =
|
||||
Application.getModuleDataFile("BytePatterns", "funcstartsamples.txt").getFile(true);
|
||||
dummyaction = new DummyMatchAction();
|
||||
matchlist = new ArrayList<Match>();
|
||||
matchlist = new ArrayList<>();
|
||||
memory = currentProgram.getMemory();
|
||||
bytebuffer = new byte[bufsize];
|
||||
ProgramDecisionTree patternDecisionTree = Patterns.getPatternDecisionTree();
|
||||
ResourceFile[] fileList = Patterns.findPatternFiles(currentProgram, patternDecisionTree);
|
||||
ArrayList<Pattern> patternlist = new ArrayList<Pattern>();
|
||||
ArrayList<Pattern> patternlist = new ArrayList<>();
|
||||
for (int i = 0; i < fileList.length; ++i)
|
||||
Pattern.readPostPatterns(fileList[i].getFile(true), patternlist, this);
|
||||
FileWriter fileWriter = new FileWriter(file);
|
||||
@ -80,8 +80,8 @@ public class DumpMissedStarts extends GhidraScript implements PatternFactory {
|
||||
FunctionIterator iter = functionManager.getFunctions(true);
|
||||
while (iter.hasNext()) {
|
||||
Function func = iter.next();
|
||||
CodeUnit cunit = listing.getCodeUnitAt(func.getEntryPoint());
|
||||
if (detectThunk(func, cunit))
|
||||
CodeUnit cu = listing.getCodeUnitAt(func.getEntryPoint());
|
||||
if (detectThunk(func, cu))
|
||||
continue;
|
||||
int numbytes = memory.getBytes(func.getEntryPoint(), bytebuffer);
|
||||
if ((numbytes > 0) && (!functionMatchesPattern(bytebuffer, numbytes))) {
|
||||
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class m68000_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "68000:BE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public m68000_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "m68000_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(m68000_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class m68000_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "68000:BE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public m68000_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "m68000_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(m68000_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class AARCH64_BE_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "AARCH64:BE:64:v8A";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public AARCH64_BE_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "AARCH64_BE_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(
|
||||
AARCH64_BE_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class AARCH64_BE_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "AARCH64:BE:64:v8A";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public AARCH64_BE_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "AARCH64_BE_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(
|
||||
AARCH64_BE_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class AARCH64_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "AARCH64:LE:64:v8A";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public AARCH64_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "AARCH64_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(AARCH64_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class AARCH64_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "AARCH64:LE:64:v8A";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public AARCH64_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "AARCH64_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(AARCH64_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class ARM10e_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "ARM:LE:32:v8";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public ARM10e_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ARM10e_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(ARM10e_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class ARM10e_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "ARM:LE:32:v8";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public ARM10e_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ARM10e_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(ARM10e_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class ARM_BE_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "ARM:BE:32:v8";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public ARM_BE_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ARM_BE_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(ARM_BE_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class ARM_BE_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "ARM:BE:32:v8";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public ARM_BE_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ARM_BE_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(ARM_BE_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class ARM_BE_thumb_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "ARM:BE:32:v8";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public ARM_BE_thumb_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ARM_BE_thumb_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(
|
||||
ARM_BE_thumb_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class ARM_BE_thumb_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "ARM:BE:32:v8";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public ARM_BE_thumb_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ARM_BE_thumb_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(
|
||||
ARM_BE_thumb_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class ARM_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "ARM:LE:32:v8";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public ARM_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ARM_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(ARM_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class ARM_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "ARM:LE:32:v8";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public ARM_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ARM_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(ARM_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class ARM_thumb_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "ARM:LE:32:v8";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public ARM_thumb_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ARM_thumb_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(ARM_thumb_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class ARM_thumb_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "ARM:LE:32:v8";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public ARM_thumb_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ARM_thumb_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(ARM_thumb_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class AVR32_BE_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "avr32:BE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public AVR32_BE_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "AVR_GCC_O0";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setAnalysisOptions(Options analysisOptions) {
|
||||
super.setAnalysisOptions(analysisOptions);
|
||||
analysisOptions.setBoolean("Reference", false); // too many bad disassemblies
|
||||
analysisOptions.setBoolean("Data Reference", false);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(AVR32_BE_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.framework.options.Options;
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class AVR32_BE_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "avr32:BE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public AVR32_BE_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "AVR_GCC_O3";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setAnalysisOptions(Options analysisOptions) {
|
||||
super.setAnalysisOptions(analysisOptions);
|
||||
analysisOptions.setBoolean("Reference", false); // too many bad disassemblies
|
||||
analysisOptions.setBoolean("Data Reference", false); // too many bad disassemblies
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(AVR32_BE_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class CR16C_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "CR16C:LE:16:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public CR16C_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "CR16C_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(CR16C_O0_EmulatorTest.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class CR16C_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "CR16C:LE:16:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public CR16C_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "CR16C_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(CR16C_O3_EmulatorTest.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPS16MIX_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPS16MIX_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPS16MIX_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(MIPS16MIX_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPS16MIX_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPS16MIX_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPS16MIX_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(MIPS16MIX_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPS16_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPS16_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPS16_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(MIPS16_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPS16_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPS16_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPS16_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(MIPS16_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPS64R6_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:64:R6";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPS64R6_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPS64R6_GCC_O0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean failOnDisassemblyErrors() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(MIPS64R6_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPS64R6_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:64:R6";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPS64R6_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPS64R6_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(MIPS64R6_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPS64_32addr_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:64:64-32addr";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPS64_32addr_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPS64_32addr_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(
|
||||
MIPS64_32addr_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPS64_32addr_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:64:64-32addr";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPS64_32addr_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPS64_32addr_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(
|
||||
MIPS64_32addr_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPS64_64addr_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:64:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPS64_64addr_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPS64_64addr_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(
|
||||
MIPS64_64addr_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPS64_64addr_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:64:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPS64_64addr_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPS64_64addr_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(
|
||||
MIPS64_64addr_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPSEL_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:LE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPSEL_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPSEL_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(MIPS_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPSEL_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:LE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPSEL_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPSEL_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(MIPS_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPSMICROMIX_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:32:micro";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPSMICROMIX_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPSMICMIX_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(
|
||||
MIPSMICROMIX_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPSMICROMIX_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:32:micro";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPSMICROMIX_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPSMICMIX_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(
|
||||
MIPSMICROMIX_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPSMICRO_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:32:micro";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPSMICRO_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPSMIC_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(MIPSMICRO_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPSMICRO_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:32:micro";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPSMICRO_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPSMIC_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(MIPSMICRO_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPSR6_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:32:R6";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPSR6_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPSR6_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(MIPSR6_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPSR6_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:32:R6";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPSR6_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPSR6_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(MIPSR6_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPS_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPS_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPS_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(MIPS_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class MIPS_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "MIPS:BE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public MIPS_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "MIPS_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(MIPS_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.lang.Register;
|
||||
import ghidra.program.model.lang.RegisterValue;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.mem.MemoryBlock;
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PARISC_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "pa-risc:BE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PARISC_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "HPPA1.1_GCC_O0";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preAnalyze(Program program) throws Exception {
|
||||
MemoryBlock block = program.getMemory().getBlock(".data");
|
||||
if (block != null) {
|
||||
Register dpReg = program.getRegister("dp");
|
||||
RegisterValue value =
|
||||
new RegisterValue(dpReg, block.getStart().getOffsetAsBigInteger());
|
||||
AddressSetView loadedMemory = program.getMemory().getLoadedAndInitializedAddressSet();
|
||||
program.getProgramContext().setRegisterValue(loadedMemory.getMinAddress(),
|
||||
loadedMemory.getMaxAddress(), value);
|
||||
}
|
||||
super.preAnalyze(program);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PARISC_O0_EmulatorTest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean failOnDisassemblyErrors() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.lang.Register;
|
||||
import ghidra.program.model.lang.RegisterValue;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.mem.MemoryBlock;
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PARISC_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "pa-risc:BE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PARISC_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "HPPA1.1_GCC_O3";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preAnalyze(Program program) throws Exception {
|
||||
MemoryBlock block = program.getMemory().getBlock(".data");
|
||||
if (block != null) {
|
||||
Register dpReg = program.getRegister("dp");
|
||||
RegisterValue value =
|
||||
new RegisterValue(dpReg, block.getStart().getOffsetAsBigInteger());
|
||||
AddressSetView loadedMemory = program.getMemory().getLoadedAndInitializedAddressSet();
|
||||
program.getProgramContext().setRegisterValue(loadedMemory.getMinAddress(),
|
||||
loadedMemory.getMaxAddress(), value);
|
||||
}
|
||||
super.preAnalyze(program);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PARISC_O3_EmulatorTest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean failOnDisassemblyErrors() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PIC30_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "dsPIC30F:LE:24:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PIC30_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "PIC30_GCC_O0";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPreferredStackSymbolName() {
|
||||
return "__SP_init";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PIC30_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PPC64_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "PowerPC:BE:64:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PPC64_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "powerpc64_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PPC64_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PPC64_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "PowerPC:BE:64:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PPC64_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "powerpc64_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PPC64_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PPCA2Alt_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "PowerPC:BE:64:A2ALT-32addr";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PPCA2Alt_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ppcA2Alt_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PPCA2Alt_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PPCA2Alt_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "PowerPC:BE:64:A2ALT-32addr";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PPCA2Alt_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ppcA2Alt_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PPCA2Alt_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PPCA2_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "PowerPC:BE:64:A2-32addr";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PPCA2_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ppcA2_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PPCA2_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PPCA2_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "PowerPC:BE:64:A2-32addr";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PPCA2_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ppcA2_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PPCA2_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PPCP8Alt_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "PowerPC:BE:64:A2ALT-32addr";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PPCP8Alt_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ppcP8Alt_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PPCP8Alt_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PPCP8Alt_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "PowerPC:BE:64:A2ALT-32addr";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PPCP8Alt_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ppcP8Alt_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PPCP8Alt_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PPCP9Alt_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "PowerPC:BE:64:A2ALT-32addr";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PPCP9Alt_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ppcP9Alt_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PPCP9Alt_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PPCP9Alt_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "PowerPC:BE:64:A2ALT-32addr";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PPCP9Alt_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "ppcP9Alt_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PPCP9Alt_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PPC_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "PowerPC:BE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PPC_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "powerpc32_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PPC_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class PPC_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "PowerPC:BE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "default";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public PPC_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "powerpc32_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(PPC_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class AVX2_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "x86:LE:64:default";
|
||||
private static final String COMPILER_SPEC_ID = "gcc";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public AVX2_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "AVX2_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(AVX2_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class AVX2_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "x86:LE:64:default";
|
||||
private static final String COMPILER_SPEC_ID = "gcc";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public AVX2_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "AVX2_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(AVX2_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class X86m32_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "x86:LE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "gcc";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public X86m32_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "pentium_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(X86m32_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class X86m32_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "x86:LE:32:default";
|
||||
private static final String COMPILER_SPEC_ID = "gcc";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public X86m32_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "pentium_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(X86m32_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class X86m64_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "x86:LE:64:default";
|
||||
private static final String COMPILER_SPEC_ID = "gcc";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public X86m64_O0_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "x86_m64_GCC_O0";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(X86m64_O0_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test.processors;
|
||||
|
||||
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
|
||||
import junit.framework.Test;
|
||||
|
||||
public class X86m64_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
|
||||
|
||||
private static final String LANGUAGE_ID = "x86:LE:64:default";
|
||||
private static final String COMPILER_SPEC_ID = "gcc";
|
||||
|
||||
private static final String[] REG_DUMP_SET = new String[] {};
|
||||
|
||||
public X86m64_O3_EmulatorTest(String name) throws Exception {
|
||||
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessorDesignator() {
|
||||
return "x86_m64_GCC_O3";
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(X86m64_O3_EmulatorTest.class);
|
||||
}
|
||||
}
|
@ -83,7 +83,7 @@ sourceSets {
|
||||
runtimeClasspath += main.output
|
||||
}
|
||||
}
|
||||
cunitTest {
|
||||
pcodeTest {
|
||||
java {
|
||||
srcDir 'src/test.processors/java'
|
||||
compileClasspath += main.output
|
||||
@ -104,7 +104,7 @@ sourceSets {
|
||||
configurations {
|
||||
integrationTestCompile.extendsFrom testCompile
|
||||
integrationTestRuntime.extendsFrom testRuntime, integrationTestCompile
|
||||
cunitTestCompile.extendsFrom compile
|
||||
pcodeTestCompile.extendsFrom compile
|
||||
testArtifacts.extendsFrom testRuntime
|
||||
integrationTestArtifacts.extendsFrom integrationTestRuntime
|
||||
}
|
||||
@ -135,6 +135,7 @@ dependencies {
|
||||
testCompile "org.jmockit:jmockit:1.44"
|
||||
|
||||
testCompile "junit:junit:4.12"
|
||||
pcodeTestCompile "junit:junit:4.12"
|
||||
}
|
||||
|
||||
// For Java 9, we must explicitly export references to the internal classes we are using.
|
||||
|
@ -64,16 +64,16 @@ task integrationTest (type: Test) { t ->
|
||||
}
|
||||
}
|
||||
|
||||
task cunitTest (type: Test) { t ->
|
||||
group "cunit"
|
||||
task pcodeTest (type: Test) { t ->
|
||||
group "pcodeTest"
|
||||
dependsOn { project(":FunctionID").unpackFidDatabases }
|
||||
testClassesDirs = files sourceSets.cunitTest.output.classesDirs
|
||||
classpath = sourceSets.cunitTest.runtimeClasspath
|
||||
testClassesDirs = files sourceSets.pcodeTest.output.classesDirs
|
||||
classpath = sourceSets.pcodeTest.runtimeClasspath
|
||||
|
||||
// Enable if you want to force Gradle to launch a new JVM for each test.
|
||||
forkEvery 1
|
||||
|
||||
initTestJVM(t, rootProject.ext.cunitTestRootDirName)
|
||||
initTestJVM(t, rootProject.ext.pcodeTestRootDirName)
|
||||
|
||||
doFirst {
|
||||
startTestTimer(t)
|
||||
@ -86,8 +86,8 @@ task cunitTest (type: Test) { t ->
|
||||
rootProject.unitTestReport {
|
||||
reportOn this.project.test
|
||||
}
|
||||
rootProject.cunitTestReport {
|
||||
reportOn this.project.cunitTest
|
||||
rootProject.pcodeTestReport {
|
||||
reportOn this.project.pcodeTest
|
||||
}
|
||||
rootProject.combinedTestReport {
|
||||
reportOn this.project.test
|
||||
|
@ -56,17 +56,17 @@ if (!project.hasProperty('srcTreeName')) {
|
||||
}
|
||||
|
||||
project.ext.testRootDirName = "JunitTest_" + srcTreeName
|
||||
project.ext.cunitTestRootDirName = "CunitTest_" + srcTreeName
|
||||
project.ext.pcodeTestRootDirName = "PCodeTest_" + srcTreeName
|
||||
|
||||
project.ext.shareDir = System.properties.get('share.dir')
|
||||
if (project.ext.shareDir != null) {
|
||||
// add src tree name to machine specified share path
|
||||
project.ext.testShareDir = shareDir + "/" + testRootDirName
|
||||
project.ext.cunitTestShareDir = shareDir + "/" + cunitTestRootDirName
|
||||
project.ext.pcodeTestShareDir = shareDir + "/" + pcodeTestRootDirName
|
||||
}
|
||||
else {
|
||||
project.ext.testShareDir = "$rootTestDir" + "/JUnit"
|
||||
project.ext.cunitTestShareDir = "$rootTestDir" + "/CUnit"
|
||||
project.ext.pcodeTestShareDir = "$rootTestDir" + "/PCodeTest"
|
||||
}
|
||||
|
||||
project.ext.upgradeProgramErrorMessage = "WARNING! Attempting data upgrade for "
|
||||
@ -454,27 +454,27 @@ task combinedTestReport(type: TestReport) { t ->
|
||||
}
|
||||
|
||||
/*********************************************************************************
|
||||
* CUNIT TEST REPORT
|
||||
* P-CODE TEST REPORT
|
||||
*
|
||||
* Summary: Runs all CUNIT tests
|
||||
* Summary: Runs all P-Code Tests
|
||||
*
|
||||
*********************************************************************************/
|
||||
task cunitTestReport(type: TestReport) { t ->
|
||||
group "cunit"
|
||||
destinationDir = file("$cunitTestShareDir" + "/reports")
|
||||
task pcodeTestReport(type: TestReport) { t ->
|
||||
group "pcodeTest"
|
||||
destinationDir = file("$pcodeTestShareDir" + "/reports")
|
||||
}
|
||||
|
||||
/*********************************************************************************
|
||||
* CUNIT TEST REPORT w/ CUNIT MATRIX REPORT
|
||||
* P-CODE TEST REPORT w/ MATRIX REPORT
|
||||
*
|
||||
* Summary: Runs all CUNIT tests and consolidate JUnit and Matrix report in
|
||||
* Summary: Runs all P-Code Tests and consolidates JUnit and Matrix report in
|
||||
* results directory.
|
||||
*
|
||||
*********************************************************************************/
|
||||
task cunitConsolidatedTestReport(type: Copy) {
|
||||
group "cunit"
|
||||
dependsOn ':cunitTestReport'
|
||||
into (cunitTestShareDir + "/reports")
|
||||
task pcodeConsolidatedTestReport(type: Copy) {
|
||||
group "pcodeTest"
|
||||
dependsOn ':pcodeTestReport'
|
||||
into (pcodeTestShareDir + "/reports")
|
||||
from (testOutputDir + "/test-output") {
|
||||
exclude '**/*.xml', 'cache/**'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user