Trying to use helgrind with Qt5, I found out that it has special wrappers for
Qt4 QMutex, which
assume that the library is called libQtCore.so.*, but in Qt5 it's called
libQt5Core.so.*, so new
wrappers are needed.
I made the attached simple patch, to add simple wrappers that call the Qt4
code. It works,
mutexes are detected as such, but the backtraces end up with duplicated lines:
==9070== Lock at 0xD81F6F8 was first observed
==9070== at 0x4C3077F: QMutex::QMutex(QMutex::RecursionMode)
(hg_intercepts.c:2186)
==9070== by 0x4C307A4: QMutex::QMutex(QMutex::RecursionMode)
(hg_intercepts.c:2192)
==9070== by 0x585A9CE: QPostEventList::QPostEventList() (qthread_p.h:110)
[...]
Should I just duplicate the code of the wrappers instead?
Or is there a more clever solution I'm missing?
What I don't know is whether some implementations might should differ from the
Qt4 implementation...
--
David Faure, [email protected], http://www.davidfaure.fr
Working on KDE, in particular KDE Frameworks 5
Index: hg_intercepts.c
===================================================================
--- hg_intercepts.c (revision 13107)
+++ hg_intercepts.c (working copy)
@@ -2033,6 +2033,14 @@
ret_ty I_WRAP_SONAME_FNNAME_ZU(libQtCoreZdsoZa,f)(args); \
ret_ty I_WRAP_SONAME_FNNAME_ZU(libQtCoreZdsoZa,f)(args)
+// soname is libQt5Core.so.4 ; match against libQt5Core.so*
+#define QT5_FUNC(ret_ty, f, args...) \
+ ret_ty I_WRAP_SONAME_FNNAME_ZU(libQt5CoreZdsoZa,f)(args); \
+ ret_ty I_WRAP_SONAME_FNNAME_ZU(libQt5CoreZdsoZa,f)(args)
+
+#define CALL_QT4_FUNC(f, args...) \
+ I_WRAP_SONAME_FNNAME_ZU(libQtCoreZdsoZa,f)(args)
+
//-----------------------------------------------------------
// QMutex::lock()
QT4_FUNC(void, _ZN6QMutex4lockEv, void* self)
@@ -2056,6 +2064,10 @@
}
}
+QT5_FUNC(void, _ZN6QMutex4lockEv, void* self) {
+ CALL_QT4_FUNC(_ZN6QMutex4lockEv, self);
+}
+
//-----------------------------------------------------------
// QMutex::unlock()
QT4_FUNC(void, _ZN6QMutex6unlockEv, void* self)
@@ -2080,6 +2092,10 @@
}
}
+QT5_FUNC(void, _ZN6QMutex6unlockEv, void* self) {
+ CALL_QT4_FUNC(_ZN6QMutex6unlockEv, self);
+}
+
//-----------------------------------------------------------
// bool QMutex::tryLock()
// using 'long' to mimic C++ 'bool'
@@ -2110,6 +2126,10 @@
return ret;
}
+QT5_FUNC(long, _ZN6QMutex7tryLockEv, void* self) {
+ return CALL_QT4_FUNC(_ZN6QMutex7tryLockEv, self);
+}
+
//-----------------------------------------------------------
// bool QMutex::tryLock(int)
// using 'long' to mimic C++ 'bool'
@@ -2141,6 +2161,9 @@
return ret;
}
+QT5_FUNC(long, _ZN6QMutex7tryLockEi, void* self, long arg2) {
+ return CALL_QT4_FUNC(_ZN6QMutex7tryLockEi, self, arg2);
+}
//-----------------------------------------------------------
// It's not really very clear what the args are here. But from
@@ -2165,6 +2188,10 @@
return (void*)ret;
}
+QT5_FUNC(void*, _ZN6QMutexC1ENS_13RecursionModeE, void* self, long recmode) {
+ return CALL_QT4_FUNC(_ZN6QMutexC1ENS_13RecursionModeE, self, recmode);
+}
+
//-----------------------------------------------------------
// QMutex::~QMutex() ("D1Ev" variant)
QT4_FUNC(void*, _ZN6QMutexD1Ev, void* mutex)
@@ -2178,6 +2205,9 @@
return (void*)ret;
}
+QT5_FUNC(void*, _ZN6QMutexD1Ev, void* self) {
+ return CALL_QT4_FUNC(_ZN6QMutexD1Ev, self);
+}
//-----------------------------------------------------------
// QMutex::QMutex(QMutex::RecursionMode) ("C2ENS" variant)
@@ -2192,6 +2222,9 @@
return NULL;
}
+QT5_FUNC(void*, _ZN6QMutexC2ENS_13RecursionModeE, void* self, long recmode) {
+ return CALL_QT4_FUNC(_ZN6QMutexC2ENS_13RecursionModeE, self, recmode);
+}
//-----------------------------------------------------------
// QMutex::~QMutex() ("D2Ev" variant)
@@ -2203,6 +2236,9 @@
return NULL;
}
+QT5_FUNC(void*, _ZN6QMutexD2Ev, void* self) {
+ return CALL_QT4_FUNC(_ZN6QMutexD2Ev, self);
+}
// QReadWriteLock is not intercepted directly. See comments
// above.
------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users