int numLinks; int numUnlinks; numLinks = 0; numUnlinks = 0; /* ================================================================== */ /* Print details of links patched */ VOID WatchLinks(ADDRINT branch_pc, ADDRINT target_pc) { numLinks++; TraceFile << "LINK #" << dec << numLinks; TraceFile << "\tcache pc=0x" << hex << branch_pc; TraceFile << " \tpatched to pc=0x" << hex << target_pc << endl; } /* ================================================================== */ /* Print details of links unpatched */ VOID WatchUnlinks(ADDRINT branch_pc, ADDRINT stub_pc) { numUnlinks++; TraceFile << "UNLINK #" << dec << numUnlinks; TraceFile << "\tcache pc=0x" << hex << branch_pc; TraceFile << " \trestored to stub pc=0x" << hex << stub_pc << endl; } /* ================================================================== */ /* Print details at the end of the run */ VOID PrintDetailsOnExit(INT32 code, VOID *v) { int traces = CODECACHE_NumTracesInCache(); TraceFile << endl << "------------------------" << endl; TraceFile << dec << traces << " traces" << endl; TraceFile << numLinks << " links set in the code cache" << endl; TraceFile << numUnlinks << " links removed from the code cache" << endl; TraceFile << "#eof" << endl; TraceFile.close(); } // Register a routine that gets called when patch a link in // the code cache CODECACHE_AddTraceLinkedFunction(WatchLinks, 0); // Register a routine that gets called when we unpatch a link in // the code cache CODECACHE_AddTraceUnlinkedFunction(WatchUnlinks, 0);