I get confused about the two functions, I want to find out when the function passed though INS_AddInstrumentFunction will be invoked, and when the ones passed though INS_InsertCall will be invoked.
I've look though the official manual of Intel PIN but didn't find the answer
According to the documentation: PIN: Instrumentation API
INS_AddInstrumentFunction: "Add a function used to instrument at instruction granularity"
INS_InsertCall: "Insert a call to funptr relative to instruction ins."
In short, the callback argument of INS_AddInstrumentFunction gets called once for every instruction, when it is loaded by PIN.
The callback argument of INS_InsertCall gets called everytime that instruction is executed.