void activate() { //FIXME: only one aligner at a time -- not changing output file //name based on a static count of the number of sse_aligner_t //objects. if (knob_verbose) { string filename = knob_output_file.Value(); if( knob_pid ) filename += "." + decstr( getpid_portable() ); out = new std::ofstream(filename.c_str()); } realign_stores = (knob_stores==1); realign_loads = (knob_loads==1); verbose = (knob_verbose==1); // obtain a key for TLS storage tls_key = PIN_CreateThreadDataKey(0); PIN_AddThreadStartFunction(thread_start, this); PIN_AddThreadFiniFunction(thread_fini, this); TRACE_AddInstrumentFunction(instrument_trace, this); if (verbose) *out << "sse aligner activated" << endl; }
int main(int argc, char *argv[]) { if (PIN_Init(argc, argv)) return Usage(); if (PIN_GetDebugStatus() == DEBUG_STATUS_DISABLED) { std::cerr << "Application level debugging must be enabled to use this tool.\n"; std::cerr << "Start Pin with either -appdebug or -appdebug_enable.\n"; std::cerr << std::flush; return 1; } if (!KnobOut.Value().empty()) Output = new std::ofstream(KnobOut.Value().c_str()); // Allocate a virtual register that each thread uses to point to its // TINFO data. Threads can use this virtual register to quickly access // their own thread-private data. // RegTinfo = PIN_ClaimToolRegister(); if (!REG_valid(RegTinfo)) { std::cerr << "Cannot allocate a scratch register.\n"; std::cerr << std::flush; return 1; } PIN_AddDebugInterpreter(DebugInterpreter, 0); PIN_AddThreadStartFunction(OnThreadStart, 0); PIN_AddThreadFiniFunction(OnThreadEnd, 0); PIN_StartProgram(); return 0; }
int main(INT32 argc, CHAR **argv) { // Initialize the pin lock PIN_InitLock(&lock); // Initialize pin if (PIN_Init(argc, argv)) return Usage(); PIN_InitSymbols(); out = fopen(KnobOutputFile.Value().c_str(), "w"); // Register ImageLoad to be called when each image is loaded. IMG_AddInstrumentFunction(ImageLoad, 0); // Register Analysis routines to be called when a thread begins/ends PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadFini, 0); // Register Fini to be called when the application exits PIN_AddFiniFunction(Fini, 0); // Never returns PIN_StartProgram(); return 0; }
int main(int argc, char *argv[]) { PIN_InitLock(&lock); if (PIN_Init(argc, argv)) return Usage(); PIN_InitLock(&lock); tls_key = PIN_CreateThreadDataKey(0); dl1cache = new L1Cache("L1 Data Cache", 64 * KILO, 64, 1); dl3cache = new L3Cache("L3 Unified Cache", /* size = */ 8192 * KILO, /* block size = */ 64, /* associativity = */ 16); std::srand(std::time(0)); PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadFini, 0); INS_AddInstrumentFunction(Instruction, 0); PIN_AddFiniFunction(Fini, 0); // Never returns PIN_StartProgram(); return 0; }
int main(int argc, char * argv[]) { // Initialize pin PIN_InitSymbols(); if (PIN_Init(argc, argv)) return Usage(); start_symbol = KnobStartSymbol.Value(); stop_symbol = KnobStopSymbol.Value(); LOG ( "start symbol" + start_symbol + "\n"); LOG ( "stop symbol = " + stop_symbol + "\n"); PIN_InitLock(&lock); tls_key = PIN_CreateThreadDataKey(0); PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadFini, 0); RTN_AddInstrumentFunction(Routine, 0); PIN_AddFiniFunction(Fini, 0); PIN_StartProgram(); return 0; }
int main(int argc, char * argv[]) { // We accumlate counts into a register, make sure it is 64 bits to // avoid overflow ASSERTX(sizeof(ADDRINT) == sizeof(UINT64)); if (PIN_Init(argc, argv)) return Usage(); OutFile.open(KnobOutputFile.Value().c_str()); ScratchReg = PIN_ClaimToolRegister(); if (!REG_valid(ScratchReg)) { std::cerr << "Cannot allocate a scratch register.\n"; std::cerr << std::flush; return 1; } PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadFini, 0); PIN_AddFiniFunction(Fini, 0); TRACE_AddInstrumentFunction(Trace, 0); PIN_StartProgram(); return 0; }
int main( int argc, char *argv[] ) { if ( PIN_Init( argc, argv ) ) { return Usage(); } PIN_InitSymbols(); initRcdcSim(); IMG_AddInstrumentFunction( instrumentImage, NULL ); TRACE_AddInstrumentFunction( instrumentTrace, NULL ); cerr << " Before this function\n"; //INS_AddInstrumentFunction(Instruction, 0); cerr << " After this function\n"; PIN_AddThreadStartFunction( threadBegin, NULL ); PIN_AddThreadFiniFunction( threadEnd, NULL ); PIN_AddContextChangeFunction( beforeSignal, NULL ); PIN_AddSyscallEntryFunction( beforeSyscall, NULL ); PIN_AddSyscallExitFunction( afterSyscall, NULL ); PIN_AddFiniUnlockedFunction( pinFini, NULL ); if ( !CODECACHE_ChangeMaxInsPerTrace( 4096 * 1024 ) ) { fprintf( stderr, "TLSProf::CODECACHE_ChangeMaxInsPerTrace failed.\n" ); } THREADID tid = PIN_SpawnInternalThread( ioThread, NULL, 0, &s_IOThreadId ); assert( tid != INVALID_THREADID ); PIN_StartProgram(); return 0; }
int main( int argc, char **argv ){ PIN_InitSymbols(); if( PIN_Init(argc,argv) ) { return Usage(); } //out_file.open(KnobOutputFile.Value().c_str(), fstream::out); stringstream ss(KnobThreadCount.Value()); ss >> total_threads; char *out_file_name = new char[BUF_SIZE]; out_file = new fstream*[total_threads]; for (INT32 i = 0; i < total_threads; i++) { sprintf(out_file_name, "%s.%d", KnobOutputFile.Value().c_str(), i); //cout<< out_file_name << endl; out_file[i] = new fstream(out_file_name, fstream::out); } stringstream ss_count(KnobSampleRate.Value()); ss_count >> sample_counter; cout << "::PINTOOL:: sample per " << sample_counter << " inst" << endl; string stdinFile = KnobStdinFile.Value(); if(stdinFile.size() > 0) { assert(freopen(stdinFile.c_str(), "rt", stdin)); } string isSeqProgram = KnobSeqProgram.Value(); if(isSeqProgram.size() > 0) { SeqProgram = true; } CacheUtil::getInstance().initialize(); CacheCore::getInstance().initialize(total_threads); if(!SeqProgram) { PIN_AddThreadStartFunction(ThreadBegin,0); PIN_AddThreadFiniFunction(ThreadEnd,0); } /* initialize random seed: */ srand (time(NULL)); IMG_AddInstrumentFunction(Image, 0); PIN_AddFiniFunction(Fini, 0); PIN_StartProgram(); }
int main(int argc, char * argv[]) { PIN_Init(argc, argv); Out.open(KnobOut.Value().c_str()); PIN_AddThreadStartFunction(OnThreadStart, 0); PIN_AddThreadFiniFunction(OnThreadFini, 0); PIN_AddFiniFunction(OnExit, 0); PIN_StartProgram(); return 0; }
// ------------------------------------------------------------- // Tool startup function // ------------------------------------------------------------- void STool_Run(STool_TSetup* s) { // make setup configuration globally available gSetup = *s; // extract application (path)name and full application command line for (int i=0; i<gSetup.argc-1;) if (!strcmp("--", gSetup.argv[i++])) { int len = 0, j; for (j=i; j<gSetup.argc; ++j) len += strlen(gSetup.argv[j])+1; gAppName = gSetup.argv[i]; gCommandLine = (char*)calloc(len, 1); if (gCommandLine == NULL) exit((printf("Can't allocate command line string\n"),1)); strcat(gCommandLine, gSetup.argv[i]); for (j=i+1; j<gSetup.argc; ++j) { strcat(gCommandLine, " "); strcat(gCommandLine, gSetup.argv[j]); } } // initialize symbol table code, needed for rtn instrumentation PIN_InitSymbols(); // initialize pin if (PIN_Init(gSetup.argc, gSetup.argv)) { Usage(); return; } // obtain a key for TLS storage. gTlsKey = PIN_CreateThreadDataKey(0); // if using memory operations buffering, define a BUF_SIZE-pages trace buffer // and register BufferOverflow to be called when the buffer fills up if (gSetup.memBuf) buf_id = PIN_DefineTraceBuffer(sizeof(STool_TMemRec), BUF_SIZE, BufferOverflow, 0); // register ThreadStart to be called when a thread starts PIN_AddThreadStartFunction(ThreadStart, 0); // register ThreadEnd to be called when a thread ends PIN_AddThreadFiniFunction(ThreadEnd, 0); // register I_Trace to be called to instrument traces TRACE_AddInstrumentFunction(I_Trace, 0); // register Fini to be called when application exits if (gSetup.appEnd) PIN_AddFiniFunction(Fini, 0); // start the program, never returns PIN_StartProgram(); }
int main(INT32 argc, CHAR **argv) { PIN_InitLock(&lock); out = fopen("thread_count.out", "w"); PIN_Init(argc, argv); PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadFini, 0); PIN_AddFiniFunction(Fini, 0); // Never returns PIN_StartProgram(); return 0; }
int main(int argc, char * argv[]) { // We accumlate counts into a register, make sure it is 64 bits to // avoid overflow ASSERTX(sizeof(ADDRINT) == sizeof(UINT64)); PIN_Init(argc, argv); PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadFini, 0); PIN_AddFiniFunction(Fini, 0); TRACE_AddInstrumentFunction(Trace, 0); PIN_StartProgram(); return 0; }
int main(INT32 argc, CHAR **argv) { PIN_InitLock(&Lock); PIN_Init(argc, argv); Out.open(KnobOutputFile.Value().c_str()); PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadFini, 0); INS_AddInstrumentFunction(Instruction, 0); PIN_AddFiniFunction(Fini, 0); // Never returns PIN_StartProgram(); return 0; }
int main(INT32 argc, CHAR **argv) { InitLock(&lock); out = fopen("mt.out", "w"); PIN_Init(argc, argv); TRACE_AddInstrumentFunction(Trace, 0); PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadFini, 0); PIN_AddFiniFunction(Fini, 0); // Never returns PIN_StartProgram(); return 0; }
int main(int argc, char *argv[]) { prof_ctrl->Initialize(); prof_ctrl->PreSetup(); PIN_InitSymbols(); PIN_Init(argc, argv); prof_ctrl->PostSetup(); TRACE_AddInstrumentFunction(I_InstrumentTrace, NULL); IMG_AddInstrumentFunction(I_ImageLoad, NULL); IMG_AddUnloadFunction(I_ImageUnload, NULL); PIN_AddSyscallEntryFunction(I_SyscallEntry, NULL); PIN_AddSyscallExitFunction(I_SyscallExit, NULL); PIN_InterceptSignal(SIGUSR2, I_IntSignal, NULL); PIN_AddContextChangeFunction(I_ContextChange, NULL); PIN_AddFiniFunction(I_ProgramExit, NULL); PIN_AddThreadStartFunction(I_ThreadStart, NULL); PIN_AddThreadFiniFunction(I_ThreadExit, NULL); I_ProgramStart(); // start the program PIN_StartProgram(); }
int main (int argc, char *argv[]) { char buff[20]; if(PIN_Init(argc,argv)) { printf("command line error\n"); return 1; } pid = PIN_GetPid(); sprintf(buff, "ct%d.log", pid); logfp = fopen(buff, "w"); if (logfp == NULL) { printf("cannot open '%s' for writing\n", buff); return 1; } sprintf(buff, "ct%d.trace", pid); if (tb_create(buff)) { fprintf(logfp, "tb_create() failed\n"); fflush(logfp); return 1; } PIN_AddFiniFunction(fini, 0); PIN_AddThreadStartFunction(thread_start, 0); PIN_AddThreadFiniFunction(thread_fini, 0); IMG_AddInstrumentFunction(img_load, NULL); IMG_AddUnloadFunction(img_unload, NULL); TRACE_AddInstrumentFunction(trace, NULL); INS_AddInstrumentFunction(instruction, NULL); PIN_AddSyscallEntryFunction(sys_enter, NULL); PIN_AddSyscallExitFunction(sys_exit, NULL); PIN_AddContextChangeFunction(context_switch, NULL); PIN_InitSymbols(); PIN_StartProgram(); // Never returns return 0; }
//-------------------------------------------------------------------------------------- int main(int argc, char *argv[]) { time(&m_StartTime); // Initialize PIN library. Print help message if -h(elp) is specified // in the command line or the command line is invalid if (PIN_Init(argc, argv)) { return Usage(); } cerr << APP_NAME; for (int i = 0; i < argc; i++) { m_CommandLine += argv[i]; m_CommandLine += " "; } m_ProcessId = PIN_GetPid(); // Register function to be called to instrument traces TRACE_AddInstrumentFunction(Trace, 0); // Register function to be called for every loaded module IMG_AddInstrumentFunction(ImageLoad, 0); // Register functions to be called for every thread starting and termination PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadEnd, 0); // Register function to be called when the application exits PIN_AddFiniFunction(Fini, 0); cerr << "Starting application..." << endl; // Start the program, never returns PIN_StartProgram(); return 0; }
int main(int argc, char *argv[]) { PIN_InitSymbols(); if(PIN_Init(argc,argv)) { cerr << "Bad arguments\n"; return -1; } IMG_AddInstrumentFunction(ImageLoadCallback, 0); PIN_AddThreadStartFunction(ThreadCreateCallback, 0); PIN_AddThreadFiniFunction (ThreadExitCallback, 0); PIN_AddContextChangeFunction(ContextChangeCallback, 0); if (!KnobFromCallback) INS_AddInstrumentFunction (AddInstrumentation, 0); PIN_StartProgram(); }
int main(INT32 argc, CHAR **argv) { InitLock(&lock); out = fopen("thread_callback.out", "w"); numThreads = 1; PIN_InitSymbols(); PIN_Init(argc, argv); PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadFini, 0); PIN_AddFiniFunction(Fini, 0); IMG_AddInstrumentFunction(ImageLoad, 0); // Never returns PIN_StartProgram(); return 0; }
int main(int argc, char * argv[]) { // Initialize pin if (PIN_Init(argc, argv)) return Usage(); PIN_InitSymbols(); OutFile.open(KnobOutputFile.Value().c_str()); // Initialize the lock PIN_InitLock(&lock); // Obtain a key for TLS storage. tls_key = PIN_CreateThreadDataKey(0); // Register ImageLoad to be called when each image is loaded. IMG_AddInstrumentFunction(ImageLoad, 0); // Register Analysis routines to be called when a thread begins/ends PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadFini, 0); // Register Fini to be called when the application exits PIN_AddFiniFunction(Fini, 0); //c calcAvgTimes(); clock_gettime(CLOCK_MONOTONIC, &start); thread_data_t* tdata = new thread_data_t; clock_gettime(CLOCK_MONOTONIC, &tdata->tstart); // Start the program, never returns PIN_StartProgram(); return 0; }
int main(int argc, char * argv[]) { InitLock(&lock); // Initialize pin if (PIN_Init(argc, argv)) return Usage(); //OutFile.open(KnobOutputFile.Value().c_str()); mlog_key = PIN_CreateThreadDataKey(0); //trace = fopen("mem.trace", "w"); // 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); // add callbacks PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadFini, 0); // Start the program, never returns PIN_StartProgram(); return 0; }
/* * initialize thread contexts * * spill a tool register for the thread * contexts and register a thread start callback * * returns: 0 on success, 1 on error */ static inline int thread_ctx_init(void) { /* claim a tool register; optimized branch */ if (unlikely( (thread_ctx_ptr = PIN_ClaimToolRegister()) == REG_INVALID())) { /* error message */ LOG(string(__FUNCTION__) + ": register claim failed\n"); /* failed */ return 1; } /* * thread start/stop hooks; * keep track of the threads and allocate/free space for the * per-thread logistics (i.e., syscall context, VCPU, etc) */ PIN_AddThreadStartFunction(thread_alloc, NULL); PIN_AddThreadFiniFunction(thread_free, NULL); /* success */ return 0; }
int main(int argc, char * argv[]) { PIN_Init(argc, argv); PIN_InitSymbols(); RegThreadInfo = PIN_ClaimToolRegister(); if (RegThreadInfo == REG_INVALID()) { std::cout << "Out of tool registers" << std::endl; PIN_ExitProcess(1); } // Get the test type and initialize the corresponding lock variable. // TestType = GetTestType(KnobTest.Value()); switch (TestType) { case TEST_NONE: std::cout << "Must specify a test to run with the '-test' knob" << std::endl; PIN_ExitProcess(1); break; case TEST_INVALID: std::cout << "Invalid test name: " << KnobTest.Value() << std::endl; PIN_ExitProcess(1); break; case TEST_LOCK_INTEGRITY: case TEST_LOCK_STRESS: PIN_InitLock(&Lock); break; case TEST_MUTEX_INTEGRITY: case TEST_MUTEX_STRESS: case TEST_MUTEX_TRYSTRESS: PIN_MutexInit(&Mutex); break; case TEST_WRITER_INTEGRITY: case TEST_WRITER_STRESS: case TEST_WRITER_TRYSTRESS: case TEST_READER_STRESS: case TEST_READER_TRYSTRESS: case TEST_RW_INTEGRITY: case TEST_RW_STRESS: case TEST_RW_TRYSTRESS: PIN_RWMutexInit(&RWMutex); break; case TEST_SEMAPHORE: PIN_SemaphoreInit(&Sem1); PIN_SemaphoreInit(&Sem2); PIN_SemaphoreSet(&Sem1); PIN_MutexInit(&Mutex); break; case TEST_TRYLOCKS: PIN_MutexInit(&Mutex); PIN_RWMutexInit(&RWMutex); PIN_SemaphoreInit(&Sem1); break; default: ASSERTX(0); } PIN_AddThreadStartFunction(OnThreadStart, 0); PIN_AddThreadFiniFunction(OnThreadFini, 0); RTN_AddInstrumentFunction(InstrumentRtn, 0); PIN_AddFiniFunction(OnExit, 0); PIN_StartProgram(); return 0; }
int main(int argc, CHAR *argv[]) { PIN_InitSymbols(); pagesize = getpagesize(); if( PIN_Init(argc,argv) ) { return Usage(); } //Initialize char *buf = (char*)malloc(sizeof(char)*200); char *buf2 = (char*)malloc(sizeof(char)*200); assert(buf); assert(buf2); int len = readlink("/proc/self/exe", buf, 200); buf[len] = '\0'; int i; for(i=0; i<len; i++) { if(buf[i] == '/') buf[i] = '_'; } /* * Output log file path * Some proccesses change working directory, so output file name should be absolute path */ sprintf(buf2, "/home/jungjae/pin-2.13-61206-gcc.4.4.7-linux/source/tools/MyPinTool/obj-intel64/log"); strcat(buf2, buf); pid = getpid(); sprintf(buf, "_%x", pid); strcat(buf2, buf); trace = fopen(buf2, "a"); assert(trace); free(buf); free(buf2); buf = NULL; buf2 = NULL; readid = 0; PIN_RWMutexInit(&malloc_lock); PIN_RWMutexInit(&thread_lock); PIN_RWMutexInit(&data_lock); PIN_MutexInit(&readid_lock); //Add Instrumentation Functions IMG_AddInstrumentFunction(ImageLoad, 0); INS_AddInstrumentFunction(Instruction, 0); PIN_AddSyscallEntryFunction(SyscallEntry, 0); PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadFini, 0); PIN_AddFiniFunction(Fini, 0); //Program Start. Never Returns PIN_StartProgram(); return 0; }