Hi, I'm trying to add compression to ZSim which uses Pin. So, I need to get value of memory accessed from pin.
I can get the value of memory read instructions using the memory address ('IARG_MEMORYREAD_EA' argument) in the follwing instruction:
INS_InsertCall(ins, IPOINT_BEFORE, beforeFunc, IARG_FAST_ANALYSIS_CALL, IARG_THREAD_ID, IARG_MEMORYREAD_EA, IARG_END);
In write instructions, i couldn't use the address because 'beforeFunc' function is called before running the instruction and the data is not written in memory.So i have to read the data using 'IPOINT_AFTER'. But, 'IARG_MEMORY_EA' is not valid in 'IPOINT_AFTER'.
I used a variable to save the address of write data in 'beforeFunc' function and i used it to read the written data in 'afterFunc' function using 'IPOINT_AFTER':
INS_InsertCall(ins, IPOINT_AFTER, afterFunc, IARG_FAST_ANALYSIS_CALL, IARG_THREAD_ID, IARG_INST_PTR /*PC*/, IARG_END);
The problem is that i don't know the order of calling 'beforeFunc' finction, running instructions and calling 'afterFunc' functions in multiple instructions. For example if two instructions A and B write on same address and 'afterFunc' is called on both instructions, then pin runs both instructions, and at the end 'afterFunc' is called on both instructions. In this order the data written by instruction A is lost because instruction B overwrites the data.
now I'm stuck. I will appreciate any solution for mentioned problems and I'm open to any other suggestions on how to get memory value from pin.