support added for predicated instructions that are not executed
This commit is contained in:
parent
98a305645d
commit
fa8251d31d
|
@ -505,7 +505,7 @@ VOID BarrierInit(ADDRINT first_arg, ADDRINT val, UINT32 encode, THREADID tid) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*** This function is called on every instruction ***/
|
/*** This function is called on every instruction ***/
|
||||||
VOID printip(THREADID tid, VOID *ip, char *asmString) {
|
VOID printip(THREADID tid, VOID *ip, char *asmString, bool predicateInsnNotExecuted) {
|
||||||
|
|
||||||
if(outOfROIPhase)
|
if(outOfROIPhase)
|
||||||
{
|
{
|
||||||
|
@ -612,8 +612,17 @@ VOID printip(THREADID tid, VOID *ip, char *asmString) {
|
||||||
uint64_t nip = MASK & (uint64_t) ip;
|
uint64_t nip = MASK & (uint64_t) ip;
|
||||||
|
|
||||||
if(traceMethod==SharedMemory) {
|
if(traceMethod==SharedMemory) {
|
||||||
while (tst->analysisFn(tid, nip, INSTRUCTION, 1) == -1) {
|
if(predicateInsnNotExecuted)
|
||||||
PIN_Yield();
|
{
|
||||||
|
while (tst->analysisFn(tid, nip, PREDICATE_INSN_NOT_EXECUTED, 1) == -1) {
|
||||||
|
PIN_Yield();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (tst->analysisFn(tid, nip, INSTRUCTION, 1) == -1) {
|
||||||
|
PIN_Yield();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if(traceMethod==File) {
|
} else if(traceMethod==File) {
|
||||||
while (tst->analysisFnAssembly(tid, nip, ASSEMBLY, asmString) == -1) {
|
while (tst->analysisFnAssembly(tid, nip, ASSEMBLY, asmString) == -1) {
|
||||||
|
@ -674,7 +683,7 @@ VOID Instruction(INS ins, VOID *v) {
|
||||||
asmChar = (char *)asmString->c_str();
|
asmChar = (char *)asmString->c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR)printip, IARG_THREAD_ID, IARG_INST_PTR, IARG_PTR, asmChar, IARG_END);
|
INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR)printip, IARG_THREAD_ID, IARG_INST_PTR, IARG_PTR, asmChar, IARG_EXECUTING, IARG_END);
|
||||||
|
|
||||||
|
|
||||||
UINT32 memOperands = INS_MemoryOperandCount(ins);
|
UINT32 memOperands = INS_MemoryOperandCount(ins);
|
||||||
|
|
|
@ -31,5 +31,7 @@
|
||||||
#define PARENT_SPAWN 35
|
#define PARENT_SPAWN 35
|
||||||
#define CHILD_START 36
|
#define CHILD_START 36
|
||||||
|
|
||||||
|
#define PREDICATE_INSN_NOT_EXECUTED 37
|
||||||
|
|
||||||
|
|
||||||
const char* findType(int type);
|
const char* findType(int type);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -44,6 +44,8 @@ public class DynamicInstructionBuffer implements Encoding
|
||||||
|
|
||||||
private long ip;
|
private long ip;
|
||||||
|
|
||||||
|
private boolean predicateInsnNotExecuted;
|
||||||
|
|
||||||
public DynamicInstructionBuffer()
|
public DynamicInstructionBuffer()
|
||||||
{
|
{
|
||||||
memRead = new long[64];
|
memRead = new long[64];
|
||||||
|
@ -59,6 +61,8 @@ public class DynamicInstructionBuffer implements Encoding
|
||||||
|
|
||||||
branchAddress = -1;
|
branchAddress = -1;
|
||||||
|
|
||||||
|
predicateInsnNotExecuted = false;
|
||||||
|
|
||||||
ip = arrayListPacket.get(0).ip;
|
ip = arrayListPacket.get(0).ip;
|
||||||
|
|
||||||
int numAssemblyPackets = 0;
|
int numAssemblyPackets = 0;
|
||||||
|
@ -100,6 +104,10 @@ public class DynamicInstructionBuffer implements Encoding
|
||||||
branchTaken = false;
|
branchTaken = false;
|
||||||
branchAddress = p.tgt;
|
branchAddress = p.tgt;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case (PREDICATE_INSN_NOT_EXECUTED):
|
||||||
|
predicateInsnNotExecuted = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case (ASSEMBLY):
|
case (ASSEMBLY):
|
||||||
numAssemblyPackets++;
|
numAssemblyPackets++;
|
||||||
|
@ -190,4 +198,8 @@ public class DynamicInstructionBuffer implements Encoding
|
||||||
boolean readAuthenticBranch = branchInformationRead==false && branchAddress!=-1;
|
boolean readAuthenticBranch = branchInformationRead==false && branchAddress!=-1;
|
||||||
return readAuthenticBranch;
|
return readAuthenticBranch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPredicateInsnNotExecuted() {
|
||||||
|
return predicateInsnNotExecuted;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -204,6 +204,7 @@ public class RunnableThread implements Encoding, Runnable {
|
||||||
iNew.setDestinationOperandMemValue(Long.parseLong(splited[i+2]));
|
iNew.setDestinationOperandMemValue(Long.parseLong(splited[i+2]));
|
||||||
iNew.setBranchTargetAddress(Long.parseLong(splited[i+3]));
|
iNew.setBranchTargetAddress(Long.parseLong(splited[i+3]));
|
||||||
iNew.setBranchTaken(Boolean.parseBoolean(splited[i+4]));
|
iNew.setBranchTaken(Boolean.parseBoolean(splited[i+4]));
|
||||||
|
iNew.setPredicateAndNotExecuted(Boolean.parseBoolean(splited[i+7]));
|
||||||
//iNew.setSerialNo(Long.parseLong(splited[i+6]));
|
//iNew.setSerialNo(Long.parseLong(splited[i+6]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -833,7 +834,7 @@ public class RunnableThread implements Encoding, Runnable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pnew.value!=INSTRUCTION && !(pnew.value>6 && pnew.value<26) && pnew.value!=Encoding.ASSEMBLY ) {
|
if (pnew.value!=INSTRUCTION && !(pnew.value>6 && pnew.value<26) && pnew.value!=Encoding.ASSEMBLY && pnew.value!=Encoding.PREDICATE_INSN_NOT_EXECUTED ) {
|
||||||
// just append the packet to outstanding packetList for current instruction pointer
|
// just append the packet to outstanding packetList for current instruction pointer
|
||||||
thread.packetList.add(pnew);
|
thread.packetList.add(pnew);
|
||||||
|
|
||||||
|
|
|
@ -41,5 +41,7 @@ public interface Encoding {
|
||||||
static final int CPL_SWITCH = 34;
|
static final int CPL_SWITCH = 34;
|
||||||
static final int PARENT_SPAWN = 35;
|
static final int PARENT_SPAWN = 35;
|
||||||
static final int CHILD_START = 36;
|
static final int CHILD_START = 36;
|
||||||
|
|
||||||
|
static final int PREDICATE_INSN_NOT_EXECUTED = 37;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class IntegerALU implements DynamicInstructionHandler
|
||||||
public int handle(int microOpIndex,
|
public int handle(int microOpIndex,
|
||||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||||
{
|
{
|
||||||
//nothing to be done in such cases
|
microOp.setPredicateAndNotExecuted(dynamicInstructionBuffer.isPredicateInsnNotExecuted());
|
||||||
return ++microOpIndex;
|
return ++microOpIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,9 @@ public class ConditionalMove implements X86StaticInstructionHandler
|
||||||
(operand2.isIntegerRegisterOperand() || operand2.isImmediateOperand()) &&
|
(operand2.isIntegerRegisterOperand() || operand2.isImmediateOperand()) &&
|
||||||
(operand3==null))
|
(operand3==null))
|
||||||
{
|
{
|
||||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2, Registers.getEFlagsRegister(), operand1));
|
Operand temp = Registers.getTempIntReg(tempRegisterNum);
|
||||||
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(), operand1, temp));
|
||||||
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2, temp, operand1));
|
||||||
}
|
}
|
||||||
|
|
||||||
//if operand1 = register and operand2 = memory - load
|
//if operand1 = register and operand2 = memory - load
|
||||||
|
@ -52,8 +54,10 @@ public class ConditionalMove implements X86StaticInstructionHandler
|
||||||
operand2.isMemoryOperand() &&
|
operand2.isMemoryOperand() &&
|
||||||
operand3==null)
|
operand3==null)
|
||||||
{
|
{
|
||||||
|
Operand temp = Registers.getTempIntReg(tempRegisterNum);
|
||||||
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(), operand1, temp));
|
||||||
Operand sourceOperand = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true);
|
Operand sourceOperand = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true);
|
||||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(sourceOperand, Registers.getEFlagsRegister(), operand1));
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(sourceOperand, temp, operand1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// //if operand1 = memory and operand2 = memory - store
|
// //if operand1 = memory and operand2 = memory - store
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class ConditionalSet implements X86StaticInstructionHandler
|
||||||
operand2==null && operand3==null)
|
operand2==null && operand3==null)
|
||||||
{
|
{
|
||||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(),
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(),
|
||||||
Operand.getImmediateOperand(), operand1));
|
operand1, operand1));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(operand1.isMemoryOperand())
|
else if(operand1.isMemoryOperand())
|
||||||
|
|
|
@ -44,11 +44,14 @@ public class Instruction implements Serializable
|
||||||
private long serialNo;
|
private long serialNo;
|
||||||
private int threadID;
|
private int threadID;
|
||||||
|
|
||||||
|
private boolean isPredicateAndNotExecuted;
|
||||||
|
|
||||||
public Instruction()
|
public Instruction()
|
||||||
{
|
{
|
||||||
this.sourceOperand1 = null;
|
this.sourceOperand1 = null;
|
||||||
this.sourceOperand2 = null;
|
this.sourceOperand2 = null;
|
||||||
this.destinationOperand = null;
|
this.destinationOperand = null;
|
||||||
|
isPredicateAndNotExecuted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear()
|
public void clear()
|
||||||
|
@ -57,6 +60,7 @@ public class Instruction implements Serializable
|
||||||
this.sourceOperand1 = null;
|
this.sourceOperand1 = null;
|
||||||
this.sourceOperand2 = null;
|
this.sourceOperand2 = null;
|
||||||
this.destinationOperand = null;
|
this.destinationOperand = null;
|
||||||
|
isPredicateAndNotExecuted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instruction(OperationType type, Operand sourceOperand1,
|
public Instruction(OperationType type, Operand sourceOperand1,
|
||||||
|
@ -66,6 +70,7 @@ public class Instruction implements Serializable
|
||||||
this.sourceOperand1 = sourceOperand1;
|
this.sourceOperand1 = sourceOperand1;
|
||||||
this.sourceOperand2 = sourceOperand2;
|
this.sourceOperand2 = sourceOperand2;
|
||||||
this.destinationOperand = destinationOperand;
|
this.destinationOperand = destinationOperand;
|
||||||
|
isPredicateAndNotExecuted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void set(OperationType type, Operand sourceOperand1,
|
private void set(OperationType type, Operand sourceOperand1,
|
||||||
|
@ -75,6 +80,7 @@ public class Instruction implements Serializable
|
||||||
this.sourceOperand1 = sourceOperand1;
|
this.sourceOperand1 = sourceOperand1;
|
||||||
this.sourceOperand2 = sourceOperand2;
|
this.sourceOperand2 = sourceOperand2;
|
||||||
this.destinationOperand = destinationOperand;
|
this.destinationOperand = destinationOperand;
|
||||||
|
isPredicateAndNotExecuted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /* our clone constructor */
|
// /* our clone constructor */
|
||||||
|
@ -123,6 +129,8 @@ public class Instruction implements Serializable
|
||||||
|
|
||||||
this.serialNo = sourceInstruction.serialNo;
|
this.serialNo = sourceInstruction.serialNo;
|
||||||
this.threadID = sourceInstruction.threadID;
|
this.threadID = sourceInstruction.threadID;
|
||||||
|
|
||||||
|
this.isPredicateAndNotExecuted = sourceInstruction.isPredicateAndNotExecuted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Instruction getIntALUInstruction(Operand sourceOperand1, Operand sourceOperand2, Operand destinationOperand)
|
public static Instruction getIntALUInstruction(Operand sourceOperand1, Operand sourceOperand2, Operand destinationOperand)
|
||||||
|
@ -492,6 +500,14 @@ public class Instruction implements Serializable
|
||||||
this.destinationOperandMemValue = destinationOperandMemValue;
|
this.destinationOperandMemValue = destinationOperandMemValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPredicateAndNotExecuted() {
|
||||||
|
return isPredicateAndNotExecuted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPredicateAndNotExecuted(boolean isPredicateAndNotExecuted) {
|
||||||
|
this.isPredicateAndNotExecuted = isPredicateAndNotExecuted;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* strInstruction method returns the instruction information in a string.
|
* strInstruction method returns the instruction information in a string.
|
||||||
* @return String describing the instruction
|
* @return String describing the instruction
|
||||||
|
|
|
@ -448,7 +448,7 @@ public class ReorderBuffer extends SimulationElement{
|
||||||
else bw.write(" null null null");
|
else bw.write(" null null null");
|
||||||
bw.write(" "+tmp.getSourceOperand1MemValue()+" "+
|
bw.write(" "+tmp.getSourceOperand1MemValue()+" "+
|
||||||
tmp.getSourceOperand2MemValue()+" "+tmp.getDestinationOperandMemValue()+" "+
|
tmp.getSourceOperand2MemValue()+" "+tmp.getDestinationOperandMemValue()+" "+
|
||||||
tmp.getBranchTargetAddress()+" "+tmp.isBranchTaken()+" "+tmp.getThreadID()+" "+tmp.getSerialNo()+"\n");
|
tmp.getBranchTargetAddress()+" "+tmp.isBranchTaken()+" "+tmp.getThreadID()+" "+tmp.getSerialNo()+" "+tmp.isPredicateAndNotExecuted()+"\n");
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue