#include <iostream> #include <fstream> #include "pin.H" FILE * trace; // This function is called before every instruction is executed //and prints the IP; VOID printip(VOID * ip) { fprintf(trace, "%p\n", ip); } // Pin calls this function every time a new instruction is encountered VOID Instruction(INS ins, VOID *v) { // Insert a call to printip before every instruction, and pass it the IP INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR)printip, IARG_INST_PTR,IARG_END); } // This function is called when the application exits VOID Fini(INT32 code, VOID *v) { fprintf(trace, "#eof\n"); fclose(trace); } /* ===================================================================== */ /* Print Help Message */ /* ===================================================================== */ INT32 Usage() { PIN_ERROR("This Pintool prints the IPs of every instruction executed\n" + KNOB_BASE::StringKnobSummary() + "\n"); return -1; } /* ===================================================================== */ /* Main */ /* ===================================================================== */ /* argc, argv are the entire command line: pin -t <toolname> -- ... */ /* ===================================================================== */ int main(int argc, char * argv[]) { trace = fopen("itrace.out", "w"); // Initialize pin if (PIN_Init(argc, argv)) return Usage(); // Register Instruction to be called to instrument instructions INS_AddInstrumentFunction(Instruction, 0); // Register Fini to be called when the application exits PIN_AddFiniFunction(Fini, 0); // Start the program, never returns PIN_StartProgram(); return 0;
Prints the address of every instruction that is executed.
This tool is useful for understanding the control flow of a program for debugging, or in processor design when simulating an instruction cache.
여기서 추가된 것은!
IARG_INST_PTR
IARG_INST_PTR : Type: ADDRINT. The address of the instrumented instruction. This value does not change at IPOINT_AFTER. This is simply shorthand for IARG_ADDRINT, INS_Address.
'pintool' 카테고리의 다른 글
More Efficient Instruction Counting (Trace Instrumentation) +질문 (0) | 2018.09.14 |
---|---|
Detecting the Loading and Unloading of Images (Image Instrumentation)+질문 (0) | 2018.09.14 |
Memory Reference Trace (Instruction Instrument) (0) | 2018.09.14 |
Simple Instruction Count(Instruction Instrument) (0) | 2018.09.11 |
핀툴 기초1 (0) | 2018.09.11 |