From 4604f73f46cee99988fb8ba0083599b835066ff9 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 23 Jan 2008 09:35:30 +0000 Subject: added mutex debug instrumentation --- debug.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'debug.h') diff --git a/debug.h b/debug.h index ecc599e1..ec689bf4 100644 --- a/debug.h +++ b/debug.h @@ -25,13 +25,21 @@ #ifndef DEBUG_H_INCLUDED #define DEBUG_H_INCLUDED +#include + /* external static data elements (some time to be replaced) */ extern int Debug; /* debug flag - read-only after startup */ extern int debugging_on; /* read-only, except on sig USR1 */ /* prototypes */ rsRetVal dbgClassInit(void); +rsRetVal dbgClassExit(void); void sigsegvHdlr(int signum); +int dbgCondTimedWait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime, + const char *file, const char* func, int line); +int dbgCondWait(pthread_cond_t *cond, pthread_mutex_t *mutex, const char *file, const char* func, int line); +int dbgMutexUnlock(pthread_mutex_t *pmut, const char *file, const char* func, int line); +int dbgMutexLock(pthread_mutex_t *pmut, const char *file, const char* func, int line); void dbgprintf(char *fmt, ...) __attribute__((format(printf,1, 2))); void dbgEntrFunc(char* file, int line, const char* func); void dbgExitFunc(char* file, int line, const char* func); @@ -52,4 +60,22 @@ void dbgExitFunc(char* file, int line, const char* func); # define RUNLOG_VAR(x) #endif +/* mutex operations */ +#define MUTOP_LOCKWAIT 1 +#define MUTOP_LOCK 2 +#define MUTOP_UNLOCK 3 + + +/* debug aides */ +#if 1 +#define d_pthread_mutex_lock(x) dbgMutexLock(x, __FILE__, __func__, __LINE__) +#define d_pthread_mutex_unlock(x) dbgMutexLock(x, __FILE__, __func__, __LINE__) +#define d_pthread_cond_wait(cond, mut) dbgCondWait(cond, mut, __FILE__, __func__, __LINE__) +#define d_pthread_cond_timedwait(cond, mut, to) dbgCondTimedWait(cond, mut, to, __FILE__, __func__, __LINE__) +#else +#define d_pthread_mutex_lock(x) pthread_mutex_lock(x) +#define d_pthread_mutex_unlock(x) pthread_mutex_unlock(x) +#define d_pthread_cond_wait(cond, mut) pthread_cond_wait(cond, mut) +#define d_pthread_cond_timedwait(cond, mut, to) pthread_cond_timedwait(cond, mut, to) +#endif #endif /* #ifndef DEBUG_H_INCLUDED */ -- cgit