On Sunday 20 May 2012 02:17:53 Olivier Goffart wrote:
> You can see it works by trying the attached wrapper.c
Actually, I realize my implementation of the hook for tryLock was wrong as i
forgot the return value.
Fixed, just in case someone wants to use it.
--
Olivier
Woboq - Qt services and support - http://woboq.com
/*
* Wrapper for helgrind that works with Qt5 mutexes
*
* Compile and run with:
gcc -shared -fPIC -o wrapper.so wrapper.c
LD_PRELOAD=wrapper.so valgrind -tool=helgrind <Qt5 application>
*
* A debug build is required
*
* Olivier Goffart <ogoff...@woboq.com>
*/
#include <stdio.h>
#include <valgrind/valgrind.h>
#include <valgrind/helgrind.h>
void I_WRAP_SONAME_FNNAME_ZU(Za,_ZN11QBasicMutex4lockEv)( void *mutex )
{
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
// printf("LOCK %p \n", mutex);
DO_CREQ_v_WW(_VG_USERREQ__HG_PTHREAD_MUTEX_LOCK_PRE, void*, mutex, long, 0);
CALL_FN_v_W(fn, mutex);
DO_CREQ_v_W(_VG_USERREQ__HG_PTHREAD_MUTEX_LOCK_POST, void*, mutex);
}
void I_WRAP_SONAME_FNNAME_ZU(Za,_ZN11QBasicMutex6unlockEv)( void *mutex )
{
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
// printf("UNLOCK %p \n", mutex);
DO_CREQ_v_W(_VG_USERREQ__HG_PTHREAD_MUTEX_UNLOCK_PRE, void*, mutex);
CALL_FN_v_W(fn, mutex);
DO_CREQ_v_W(_VG_USERREQ__HG_PTHREAD_MUTEX_UNLOCK_POST, void*, mutex);
}
long I_WRAP_SONAME_FNNAME_ZU(Za,_ZN11QBasicMutex7tryLockEi)( void *mutex, int timeout )
{
OrigFn fn;
long ret;
VALGRIND_GET_ORIG_FN(fn);
// printf("TRYLOCK %p %d\n", mutex, timeout);
DO_CREQ_v_WW(_VG_USERREQ__HG_PTHREAD_MUTEX_LOCK_PRE, void*, mutex, long, 1);
CALL_FN_W_WW(ret, fn, mutex, timeout);
if (ret & 0xff)
DO_CREQ_v_W(_VG_USERREQ__HG_PTHREAD_MUTEX_LOCK_POST, void*, mutex);
return ret;
}
_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development