/* * Copyright 2002-2019 Intel Corporation. * * This software is provided to you as Sample Source Code as defined in the accompanying * End User License Agreement for the Intel(R) Software Development Products ("Agreement") * section 1.L. * * This software and the related documents are provided as is, with no express or implied * warranties, other than those that are expressly stated in the License. */ #include #include "pin.H" // This tool causes one trace to be instrumented with so many calls that it will not // fit into the default code-cache-block (which is 256K), until Pin reduces the // trace to 1 application instruction ADDRINT addrOfTraceToInstrument = 0; BOOL traceInstrumented = FALSE; UINT32 numCallsToInsert = 4000; UINT32 numAnalysisCalls = 0; VOID AnalysisFunc(CONTEXT *ctxt) { numAnalysisCalls++; } // Pin calls this function every time a new Trace is jitted VOID Trace(TRACE trace, VOID *v) { if (((!traceInstrumented) && TRACE_NumIns(trace) > 3) || addrOfTraceToInstrument==TRACE_Address(trace)) { printf ("Instrumenting Trace\n"); addrOfTraceToInstrument = TRACE_Address(trace); traceInstrumented = TRUE; if (TRACE_NumIns(trace)==1) { numCallsToInsert = 1; } for (UINT32 i=0; i -- ... int main(int argc, char * argv[]) { // Initialize pin PIN_Init(argc, argv); // Register Trace to be called to instrument the trace TRACE_AddInstrumentFunction(Trace, 0); // Register Fini to be called when the application exits PIN_AddFiniFunction(Fini, 0); // Start the program, never returns PIN_StartProgram(); return 0; }