Example #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);
    }
}
/* =====================================================================
 * Called upon program finish
 * ===================================================================== */
static void OnExit(INT32, VOID *)
{
    PIN_SemaphoreFini(&SemAllThreadStarted);
    PIN_MutexFini(&MtxVecThreadIds);
    PIN_MutexFini(&MtxActiveThread);

    ASSERT(!PIN_IsThreadStoppedInDebugger(VecThreadIds[0]),
           "Terminated thread with TID " + decstr(VecThreadIds[0]) + " shouldn't be appeared as stopped");

    Out << "Finished" << std::endl;
    Out.close();
}