misc/lock-monitor/lock-monitor.c
int pthread_mutex_lock(pthread_mutex_t *mutex) {
    int ret;
    lock((void*)mutex);
    assert(real_mutex_lock);
    ret = real_mutex_lock(mutex);
    if (ret) unlock((void*)mutex);
    return ret;
}
/* The wrapper functions that trap your binary's calls to the locking/unlocking
 * functions. The general pattern for locking operations is:
 *  1. Assess the lock against the partial ordering (call lock);
 *  2. Lock the variable;
 *  3. If the locking failed, remove it from the thread's lock list;
 *  4. Return the result.
 * The general pattern for unlocking is:
 *  1. Unlock the variable;
 *  2. If this SUCCEEDED, remove it from the thread's lock list;
 *  3. Return the result.
 */
The wrapper functions that trap your binary's calls to the locking/unlocking
functions. The general pattern for locking operations is:
1. Assess the lock against the partial ordering (call lock);
2. Lock the variable;
3. If the locking failed, remove it from the thread's lock list;
4. Return the result.
The general pattern for unlocking is:
1. Unlock the variable;
2. If this SUCCEEDED, remove it from the thread's lock list;
3. Return the result.
The wrapper functions that trap your binary ' s calls to the locking / unlocking functions . The general pattern for locking operations is : 1 . Assess the lock against the partial ordering ( call lock ) ; 2 . Lock the variable ; 3 . If the locking failed remove it from the thread ' s lock list ; 4 . Return the result . The general pattern for unlocking is : 1 . Unlock the variable ; 2 . If this SUCCEEDED remove it from the thread ' s lock list ; 3 . Return the result .
int pthread_mutex_lock(pthread_mutex_t *mutex) {
    int ret;
    lock((void*)mutex);
    assert(real_mutex_lock);
    ret = real_mutex_lock(mutex);
    if (ret) unlock((void*)mutex);
    return ret;
}
int pthread_mutex_lock ( pthread_mutex_t * mutex ) { int ret ; lock ( ( void * ) mutex ) ; assert ( real_mutex_lock ) ; ret = real_mutex_lock ( mutex ) ; if ( ret ) unlock ( ( void * ) mutex ) ; return ret ; }
The wrapper functions that trap your binary's calls to the locking/unlocking
 functions.
The wrapper functions that trap your binary ' s calls to the locking / unlocking functions .