示例#1
0
static void OnExit(INT32, VOID *)
{
    if (!FoundTestFunc || !FoundThreadCountFunc)
    {
        std::cout << "Couldn't find instrumentation routine(s)" << std::endl;
        PIN_ExitProcess(1);
    }

    // Destroy the lock variable.
    //
    switch (TestType)
    {
    case TEST_LOCK_INTEGRITY:
    case TEST_LOCK_STRESS:
        /* nothing to do */
        break;
    case TEST_MUTEX_INTEGRITY:
    case TEST_MUTEX_STRESS:
    case TEST_MUTEX_TRYSTRESS:
        PIN_MutexFini(&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_RWMutexFini(&RWMutex);
        break;
    case TEST_SEMAPHORE:
        PIN_SemaphoreFini(&Sem1);
        PIN_SemaphoreFini(&Sem2);
        PIN_MutexFini(&Mutex);
        break;
    case TEST_TRYLOCKS:
        PIN_MutexFini(&Mutex);
        PIN_RWMutexFini(&RWMutex);
        PIN_SemaphoreFini(&Sem1);
        break;
    default:
        ASSERTX(0);
    }
}
示例#2
0
/*
 * Fini
 * Called when process ends
 * Clean up mems & locks
 */
VOID Fini(INT32 code, VOID *v)
{
	PIN_RWMutexWriteLock(&malloc_lock);
	while(malloc_root != NULL)
		malloc_root = DeleteAddress(malloc_root, malloc_root->address);
	PIN_RWMutexUnlock(&malloc_lock);

	PIN_RWMutexWriteLock(&data_lock);
	while(data_root != NULL)
		data_root = DeleteAddress(data_root, data_root->address);
	PIN_RWMutexUnlock(&data_lock);

	PIN_RWMutexWriteLock(&thread_lock);
	while(root_thread != NULL)
		root_thread = DeleteThread(root_thread->tid, root_thread);
	PIN_RWMutexUnlock(&thread_lock);

	PIN_RWMutexFini(&thread_lock);
	PIN_RWMutexFini(&data_lock);
	PIN_RWMutexFini(&malloc_lock);
	PIN_MutexFini(&readid_lock);

	fclose(trace);
}