int main(int argc, char * argv[]) { // Initialize pin PIN_InitSymbols(); if (PIN_Init(argc, argv)) return Usage(); // Initialize the lock InitLock(&lock); // Obtain a key for TLS storage. tls_key = PIN_CreateThreadDataKey(0); // Register ThreadStart to be called when a thread starts. PIN_AddThreadStartFunction(ThreadStart, 0); // Register Instruction to be called to instrument instructions. 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; }
int main(INT32 argc, CHAR **argv) { // Initialize the pin lock 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; }
TSemaphoreSet::TLock::TLock(ulong msgMask, const TSemaphoreSet& set, TWaitWhat wait, ulong timeOut) { TAPointer<THandle> handles(newHandles(set)); if (InitLock(set.Count, wait, ::MsgWaitForMultipleObjects(set.Count, handles, wait, timeOut, msgMask))) Set = &set; }
int main() { pthread_t t1, t2; InitLock(l); InitLock(data_l); data_init(); global_script.compile = Dummy; pthread_create(&t1, 0, thread_routine1, &global_script); pthread_create(&t2, 0, thread_routine2, 0); pthread_join(t1, 0); pthread_join(t2, 0); return 0; }
TSemaphoreSet::TLock::TLock(const TSemaphoreSet& set, TWaitWhat wait, ulong timeOut, bool alertable) : Set(0) { TAPointer<THandle> handles(newHandles(set)); if (InitLock(set.Count, wait, ::WaitForMultipleObjectsEx(set.Count, handles, wait, timeOut, alertable))) Set = &set; }
CSerialCommHelper::CSerialCommHelper() { InvalidateHandle( ThreadTerm ); InvalidateHandle( Thread ); InvalidateHandle( ThreadStarted ); InvalidateHandle( CommPort ); InvalidateHandle( DataRx ); InitLock(); state = SS_UnInit; }
int main(int argc, char * argv[]) { PIN_Init(argc, argv); PIN_InitSymbols(); InitLock(&Lock); IMG_AddInstrumentFunction(OnImage, 0); RTN_AddInstrumentFunction(InstrumentRtn, 0); PIN_InterceptDebuggingEvent(DEBUGGING_EVENT_BREAKPOINT, Intercept, 0); PIN_InterceptDebuggingEvent(DEBUGGING_EVENT_ASYNC_BREAK, Intercept, 0); PIN_AddFiniFunction(OnExit, 0); PIN_StartProgram(); return 0; }
int main(INT32 argc, CHAR **argv) { InitLock(&lock); PIN_InitSymbols(); PIN_Init(argc, argv); PIN_AddThreadStartFunction(ThreadStart, 0); // Never returns PIN_StartProgram(); return 0; }
CDll_RS232::CDll_RS232( void ):m_bIsConnection( FALSE ) , m_SignalDataReceive( NULL ) { InvalidateHandle( m_hThread ) ; InvalidateHandle( m_hCommPort ) ; InvalidateHandle( m_hTerminate ) ; InvalidateHandle( m_hThreadStarted ) ; InitLock() ; char szPath[ MAX_PATH ] ; ZeroMemory( szPath , MAX_PATH ) ; GetModuleFileName( NULL , szPath , MAX_PATH ) ; char *p = strrchr( szPath , '.' ) ; strcpy( p + 1 , "log" ) ; stream = fopen( szPath, "w" ); }
void logInit(int logType, const char* lpszPath) { #if !defined(ENABLE_DMLOG) return; #else if(g_logInited) return; g_logLevel = logDebugLevel; if(logType < LOG_DRIVER_MAX) g_logType = logType; InitLock(&g_LockLog); g_hLogFile = NULL; g_logInited = 1; if(g_logType == LOG_DRIVER_FILE) { g_hLogFile = fopen(lpszPath, "w+t"); } else if(g_logType == LOG_DRIVER_MMAP) { g_mmap_log.event = eventNew(NAMED_EVENT_PATH); g_mmap_log.mutex = mutexNew(NAMED_MUTEX_PATH); g_mmap_log.handle = mmapOpen(NAMED_MMAP_PATH, MMAP_LOG_FILE_SIZE); do{ MMAP_FILE_HEADER *hd; mutexLock(g_mmap_log.mutex, -1); g_mmap_log.readpos = sizeof(MMAP_FILE_HEADER); hd = (MMAP_FILE_HEADER*)g_mmap_log.handle->data; if(hd->magic_code != LOG_MMAP_MAGIC_CODE){ printf("It is the first process to create the memory map!\r\n"); hd->magic_code = LOG_MMAP_MAGIC_CODE; hd->writepos = sizeof(MMAP_FILE_HEADER); hd->endpos = sizeof(MMAP_FILE_HEADER); } mutexUnLock(g_mmap_log.mutex); }while(0); } else if(g_logType == LOG_DRIVER_SYSLOG) { #ifdef LINUX openlog(NULL, LOG_CONS|LOG_PID, LOG_USER); #endif } #endif }
int main(INT32 argc, CHAR **argv) { 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("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; }
/* * currentVectorClock => threads vector clock * currentReaderLocksetId, currentWriterLocksetId => lockset ids * next* => these values are utilized when for instance a lock,mallock,barrier * function calls are executed, which are explained in pthreadcallinstrumentation.cpp * * */ ThreadLocalData::ThreadLocalData(THREADID tid) { currentVectorClock = new VectorClock(tid); currentReaderLocksetId = 0; currentWriterLocksetId = 0; nextWaitCondVariableAddr = 0; nextBarrierAddr = 0; currentSegment = NULL; totalSegmentCount = 0; InitLock(&threadLock); createNewSegment = false; isAlive = true; nextMallocSize = 0; nextReallocAddr = 0; nextReallocSize = 0; nextSemaphoreAddr = 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 __cdecl main(int argc, char *argv[]){ PIN_InitSymbols(); if (PIN_Init(argc, argv)) return 1; InitLock(&lock); pcounter = (unsigned char *)log_init(); TRACE_AddInstrumentFunction(Trace, 0); IMG_AddInstrumentFunction(Image, 0); IMG_AddUnloadFunction(ImageUnload, 0); PIN_AddContextChangeFunction(ContextChange, 0); PIN_AddFiniFunction(ExitFunction, 0); PIN_StartProgram(); return 0; }
/*! * The main procedure of the tool. * This function is called when the application image is loaded but not yet started. * @param[in] argc total number of elements in the argv array * @param[in] argv array of command line arguments, * including pin -t <toolname> -- ... */ int main(int argc, char *argv[]) { // 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(); } // Initialize the memory reference buffer bufId1 = PIN_DefineTraceBuffer(sizeof(struct MEMREF), NUM_BUF_PAGES, BufferFull1, 0); if(bufId1 == BUFFER_ID_INVALID){ cerr << "Error allocating initial buffer 1" << endl; return 1; } // Initialize the memory reference buffer bufId2 = PIN_DefineTraceBuffer(sizeof(struct MEMREF), NUM_BUF_PAGES, BufferFull2, 0); if(bufId2 == BUFFER_ID_INVALID){ cerr << "Error allocating initial buffer 2" << endl; return 1; } outfile = fopen("two_buffers.out", "w"); if(!outfile){ cerr << "Couldn't open two_buffers.out" << endl; return 1; } InitLock(&fileLock); // add an instrumentation function TRACE_AddInstrumentFunction(Trace, 0); // Register function to be called when the application exits PIN_AddFiniFunction(Fini, 0); // Start the program, never returns PIN_StartProgram(); return 0; }
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[]) { 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; }
struct flashDev * fifo_flashOpen( char * devName, flash_settings_t *flash_settings_in, int flags ) { int i; int rc; struct flashDev * pdev; plat_log_msg(21691, PLAT_LOG_CAT_SDF_APP_MEMCACHED, PLAT_LOG_LEVEL_DEBUG, "ENTERING, devName=%s", devName ); /* Global settings for aio and flash subsystems */ flash_settings = *flash_settings_in; pdev = plat_alloc( sizeof(struct flashDev) ); if ( NULL == pdev ) { plat_log_msg(21692, PLAT_LOG_CAT_FLASH, PLAT_LOG_LEVEL_ERROR, "failed to alloc dev"); return NULL; } for ( i = 0; i < FTH_MAX_SCHEDS; i++ ) { pdev->stats[i].flashOpCount = 0; pdev->stats[i].flashReadOpCount = 0; pdev->stats[i].flashBytesTransferred = 0; } pdev->shardList = NULL; InitLock( pdev->lock ); /* * initialize the aio subsystem */ pdev->paio_state = plat_alloc( sizeof(struct ssdaio_state) ); if ( NULL == pdev->paio_state ) { plat_log_msg(21693, PLAT_LOG_CAT_FLASH, PLAT_LOG_LEVEL_ERROR, "failed to alloc aio state"); plat_free(pdev); return NULL; } rc = ssdaio_init( pdev->paio_state, devName ); if ( 0 != rc ) { plat_log_msg(21694, PLAT_LOG_CAT_FLASH, PLAT_LOG_LEVEL_ERROR, "failed to init aio"); plat_free(pdev->paio_state); plat_free(pdev); return NULL; } pdev->size = pdev->paio_state->size; pdev->used = 0; plat_log_msg(21695, PLAT_LOG_CAT_SDF_APP_MEMCACHED, PLAT_LOG_LEVEL_DEBUG, "dev size is %lu", pdev->size ); if ( NULL == Ssd_fifo_ops.flashOpen ) { plat_log_msg(21696, PLAT_LOG_CAT_SDF_APP_MEMCACHED, PLAT_LOG_LEVEL_FATAL, "fifo_flashOpen not implemented!" ); plat_abort(); } Ssd_fifo_ops.flashOpen( devName, flash_settings_in, flags ); return pdev; }
/************ * MAIN * ************/ int main(int argc, char* argv[]){ int i; setup_mica_log(&log); MODE mode; read_config(&log,&mode, &_ilp_win_size, &_block_size, &_page_size, &_itypes_spec_file); for(i=0; i < MAX_MEM_TABLE_ENTRIES; i++){ ins_buffer[i] = (ins_buffer_entry*)NULL; } switch(mode){ /* case MODE_ALL: init_all(); PIN_Init(argc, argv); INS_AddInstrumentFunction(Instruction_all, 0); PIN_AddFiniFunction(Fini_all, 0); break; case MODE_ILP: init_ilp_all(); PIN_InitSymbols(); PIN_Init(argc, argv); InitLock(&lock); // Obtain a key for TLS storage. tls_key = PIN_CreateThreadDataKey(0); // Register ThreadStart to be called when a thread starts. PIN_AddThreadStartFunction(ThreadStart, 0); INS_AddInstrumentFunction(Instruction_ilp_all_only, 0); PIN_AddFiniFunction(Fini_ilp_all_only, 0); break;*/ case MODE_ILP_ONE: //init_ilp_one(); PIN_InitSymbols(); PIN_Init(argc, argv); InitLock(&lock); // Obtain a key for TLS storage. tls_key = PIN_CreateThreadDataKey(0); // Register ThreadStart to be called when a thread starts. PIN_AddThreadStartFunction(ThreadStart, 0); INS_AddInstrumentFunction(Instruction_ilp_one_only, 0); PIN_AddFiniFunction(Fini_ilp_one_only, 0); break; /* case MODE_ITYPES: init_itypes(); PIN_Init(argc, argv); INS_AddInstrumentFunction(Instruction_itypes_only, 0); PIN_AddFiniFunction(Fini_itypes_only, 0); break; case MODE_PPM: init_ppm(); PIN_Init(argc, argv); INS_AddInstrumentFunction(Instruction_ppm_only, 0); PIN_AddFiniFunction(Fini_ppm_only, 0); break; case MODE_REG: init_reg(); PIN_Init(argc, argv); INS_AddInstrumentFunction(Instruction_reg_only, 0); PIN_AddFiniFunction(Fini_reg_only, 0); break; case MODE_STRIDE: init_stride(); PIN_Init(argc, argv); INS_AddInstrumentFunction(Instruction_stride_only, 0); PIN_AddFiniFunction(Fini_stride_only, 0); break; case MODE_MEMFOOTPRINT: init_memfootprint(); PIN_Init(argc, argv); INS_AddInstrumentFunction(Instruction_memfootprint_only, 0); PIN_AddFiniFunction(Fini_memfootprint_only, 0); break; case MODE_MEMREUSEDIST: init_memreusedist(); PIN_Init(argc, argv); INS_AddInstrumentFunction(Instruction_memreusedist_only, 0); PIN_AddFiniFunction(Fini_memreusedist_only, 0); break; case MODE_CUSTOM: init_custom(); PIN_Init(argc, argv); INS_AddInstrumentFunction(Instruction_custom, 0); PIN_AddFiniFunction(Fini_custom, 0); break;*/ default: cerr << "FATAL ERROR: Unknown mode while trying to allocate memory for Pin tool!" << endl; log << "FATAL ERROR: Unknown mode while trying to allocate memory for Pin tool!" << endl; exit(1); } // starts program, never returns PIN_StartProgram(); }
AllocList::AllocList(void) { m_head = NULL; memset(&m_lock, 0, sizeof(m_lock)); InitLock(); }