pintool30 Managed platforms support2 #include "pin.H" #include #include // ===================================================================== // Global variables // ===================================================================== std::ostream * out = &cerr; // ===================================================================== // Command line switches // ====================================================================.. 2018. 10. 2. Managed platforms support1 #include "pin.H" #include #include // ================================================================== // Global variables // ================================================================== UINT64 insNativeDiscoveredCount = 0; //number of discovered native instructions UINT64 insDynamicDiscoveredCount = 0; //number of discovered dynamic instructions UINT64 insNoRtnDiscoveredCount = 0; //num.. 2018. 10. 2. Instrumenting Before and After Forks #include #include #include #include #include "pin.H" #include #include using namespace std; INT32 Usage() { cerr 2018. 10. 2. Instrumenting Child Processes #include "pin.H" #include #include #include /* ===================================================================== */ /* Command line Switches */ /* ===================================================================== */ BOOL FollowChild(CHILD_PROCESS childProcess, VOID * userData) { fprintf(stdout, "before child:%u\n", getpid()); return TRUE; } /* ============================================.. 2018. 10. 2. Replacing a Routine in Probe Mode // Replace an original function with a custom function defined in the tool using // probes. The replacement function has a different signature from that of the // original replaced function. #include "pin.H" #include using namespace std; typedef VOID * ( *FP_MALLOC )( size_t ); // This is the replacement routine. // VOID * NewMalloc( FP_MALLOC orgFuncptr, UINT32 arg0, ADDRINT returnIp ) { // Nor.. 2018. 10. 2. Detaching Pin from the Application #include #include "pin.H" #include // 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, I.. 2018. 10. 2. Finding the Static Properties of an Image // // This tool prints a trace of image load and unload events // #include #include #include "pin.H" // Pin calls this function every time a new img is loaded // It can instrument the image, but this example merely // counts the number of static instructions in the image VOID ImageLoad(IMG img, VOID *v) { UINT32 count = 0; for (SEC sec = IMG_SecHead(img); SEC_Valid(sec); sec = SEC_Next(sec)) { f.. 2018. 10. 2. Using the Fast Buffering APIs /* * Sample buffering tool * * This tool collects an address trace of instructions that access memory * by filling a buffer. When the buffer overflows,the callback writes all * of the collected records to a file. * */ #include #include #include #include #include #include "pin.H" using namespace std; /* * Name of the output file */ KNOB KnobOutputFile(KNOB_MODE_WRITEONCE, "pintool", "o", "buffer... 2018. 9. 28. Using TLS #include #include #include #include "pin.H" KNOB KnobOutputFile(KNOB_MODE_WRITEONCE, "pintool", "o", "", "specify output file name"); INT32 numThreads = 0; ostream* OutFile = NULL; // Force each thread's data to be in its own data cache line so that // multiple threads do not contend for the same data cache line. // This avoids the false sharing problem. #define PADSIZE 56 // 64 byte line size: .. 2018. 9. 28. 이전 1 2 3 4 다음