본문 바로가기

pintool30

Instrumenting Threaded Applications #include #include "pin.H" KNOB KnobOutputFile(KNOB_MODE_WRITEONCE, "pintool", "o", "malloc_mt.out", "specify output file name"); //============================================================== // Analysis Routines //============================================================== // Note: threadid+1 is used as an argument to the PIN_GetLock() // routine as a debugging aid. This is the value that .. 2018. 9. 28.
Finding Functions By Name on Windows /* ===================================================================== */ /* This example demonstrates finding a function by name on Windows. */ /* ===================================================================== */ #include "pin.H" namespace WINDOWS { #include } #include #include /* ===================================================================== */ /* Global Variables */ /* =======.. 2018. 9. 18.
Finding the Value of Function Arguments #include "pin.H" #include #include /* ===================================================================== */ /* Names of malloc and free */ /* ===================================================================== */ #if defined(TARGET_MAC) #define MALLOC "_malloc" #define FREE "_free" #else #define MALLOC "malloc" #define FREE "free" #endif /* ==================================================.. 2018. 9. 18.
Order of Instrumentation #include "pin.H" #include #include using namespace std; KNOB KnobOutputFile(KNOB_MODE_WRITEONCE, "pintool", "o", "invocation.out", "specify output file name"); ofstream OutFile; /* * Analysis routines */ VOID Taken( const CONTEXT * ctxt) { ADDRINT TakenIP = (ADDRINT)PIN_GetContextReg( ctxt, REG_INST_PTR ); OutFile 2018. 9. 18.
Using PIN_SafeCopy() #include #include "pin.H" #include #include std::ofstream* out = 0; //======================================================= // Analysis routines //======================================================= // Move from memory to register ADDRINT DoLoad(REG reg, ADDRINT * addr) { *out 2018. 9. 18.
Procedure Instruction Count (Routine Instrumentation) *질문 // // This tool counts the number of times a routine is executed and // the number of instructions executed in a routine // #include #include #include #include #include "pin.H" ofstream outFile; // Holds instruction count for a single procedure typedef struct RtnCount { string _name; string _image; ADDRINT _address; RTN _rtn; UINT64 _rtnCount; UINT64 _icount; struct RtnCount * _next; } RTN_COUNT.. 2018. 9. 14.
More Efficient Instruction Counting (Trace Instrumentation) +질문 #include #include #include "pin.H" ofstream OutFile; // The running count of instructions is kept here // make it static to help the compiler optimize docount static UINT64 icount = 0; // This function is called before every block VOID docount(UINT32 c) { icount += c; } // Pin calls this function every time a new basic block is encountered // It inserts a call to docount VOID Trace(TRACE trace, .. 2018. 9. 14.
Detecting the Loading and Unloading of Images (Image Instrumentation)+질문 // // This tool prints a trace of image load and unload events // #include "pin.H" #include #include #include using namespace std; KNOB KnobOutputFile(KNOB_MODE_WRITEONCE, "pintool", "o", "imageload.out", "specify file name"); ofstream TraceFile; // Pin calls this function every time a new img is loaded // It can instrument the image, but this example does not // Note that imgs (including shared.. 2018. 9. 14.
Memory Reference Trace (Instruction Instrument) /* * This file contains an ISA-portable PIN tool for tracing memory accesses. */ #include #include "pin.H" FILE * trace; // Print a memory read record VOID RecordMemRead(VOID * ip, VOID * addr) { fprintf(trace, "%p: R %p\n", ip, addr); } // Print a memory write record VOID RecordMemWrite(VOID * ip, VOID * addr) { fprintf(trace, "%p: W %p\n", ip, addr); } // Is called for every instruction and in.. 2018. 9. 14.