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
}
Asked
Active
Viewed 846 times
3

Mos Moh
- 317
- 3
- 15
-
can you explain what you're trying to achieve by passing the INS to myFunction? In general it is better (performance wise) to do as much processing as possible in the instrumentation function, so why not pass the results of the processing instead of the INS object? – nitzanms Jul 08 '15 at 14:32
-
@nitzanms , Thanks, first i want to do some processing at run time, but now i didn't need the INS in the callback, i do some processing in the instrumentation function and pass it to the callback function, ( as you advice ), thanks again. – Mos Moh Jul 10 '15 at 13:23
-
consider answering your own question with something to this effect. – nitzanms Jul 11 '15 at 13:50
2 Answers
3
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.

douggard
- 692
- 1
- 12
- 29
0
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... "

Mos Moh
- 317
- 3
- 15
-
But if i can't pass INS as argument in a call back inside my instrumentation function, can i add another instrumentation function inside another one ( add: INS_AddInstrumentFunction(MyFunction, 0) inside TRACE_AddInstrumentFunction(Trace, 0) , i success in it, but i wasn't sure if it a good way and give a right results ?? – Mos Moh Jun 16 '15 at 12:38