pintool
Detaching Pin from the Application
sonysame
2018. 10. 2. 13:42
#include <stdio.h> #include "pin.H" #include <iostream> // This tool shows how to detach Pin from an // application that is under Pin's control. UINT64 icount = 0; #define N 10000 VOID docount() { icount++; // Release control of application if 10000 // instructions have been executed if ((icount % N) == 0) { PIN_Detach(); } } VOID Instruction(INS ins, VOID *v) { INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR)docount, IARG_END); } VOID ByeWorld(VOID *v) { std::cerr << endl << "Detached at icount = " << N << endl; } /* ===================================================================== */ /* Print Help Message */ /* ===================================================================== */ INT32 Usage() { cerr << "This tool demonstrates how to detach Pin from an " << endl; cerr << "application that is under Pin's control" << endl; cerr << endl << KNOB_BASE::StringKnobSummary() << endl; return -1; } /* ===================================================================== */ /* Main */ /* ===================================================================== */ int main(int argc, char * argv[]) { if (PIN_Init(argc, argv)) return Usage(); // Callback function to invoke for every // execution of an instruction INS_AddInstrumentFunction(Instruction, 0); // Callback functions to invoke before // Pin releases control of the application PIN_AddDetachFunction(ByeWorld, 0); // Never returns PIN_StartProgram(); return 0; }
instrumentation code로부터 application을 detach하는 방법이다.
PIN_AddDetachFunction()<-main함수내에서 & PIN_Detach()를 사용하면된다.