How can i pass instruction to a call back in intel-pintool?

925 views Asked by At

I'm new in pintool, i know how to pass instruction address to call back, by using:
INS_InsertPredicatedCall( ins, IPOINT_BEFORE, (AFUNPTR)MyFunction, IARG_ADDRINT, INS_Address(ins), IARG_END); // My call back function is: MyFunction(UINT64 insAddress) { .... }

Is there is a way to pass instruction to the call back, or can extract it from its address.
like:

MyFunction( UINT64 insAddress, INS ins ) {.... }
MyFunction(UINT64 insAddress) { INS ins = someFunction(insAddress);// some function that return instruction of a specified address }

2

There are 2 answers

1
Mos Moh On

I found some one say that:
" this is about the analysis routine, not the instrumentation routine. AFAIK, you can't deal with INS, BBL or TRACE types in an analysis routine, and as you have seen there's no way to pass them to the analysis routine... "

0
douggard On

The solution I used for this is to pass the INS into a custom object and save those objects to a map of std::map<ADDRINT, Instruction>. Then when I need to access the instructions I have them mapped by their address. Appears to be working fine.