lockdebug - be able to find mutexes that lock for a while... but.. i

found what was blocking.. and it wasnt a mutex! well.. put this in for
further debugging later.



SVN revision: 55544
This commit is contained in:
Carsten Haitzler 2010-12-14 05:41:32 +00:00
parent 60458017fb
commit d3cd14c805
2 changed files with 53 additions and 9 deletions

View File

@ -2,6 +2,11 @@
#include "evas_private.h" #include "evas_private.h"
#include "evas_cs.h" #include "evas_cs.h"
#ifdef LKDEBUG
EAPI Eina_Bool lockdebug = EINA_FALSE;
EAPI int lockmax = 0;
#endif
static int _evas_init_count = 0; static int _evas_init_count = 0;
int _evas_log_dom_global = -1; int _evas_log_dom_global = -1;
/** /**
@ -22,6 +27,14 @@ evas_init(void)
if (++_evas_init_count != 1) if (++_evas_init_count != 1)
return _evas_init_count; return _evas_init_count;
#ifdef LKDEBUG
if (getenv("EVAS_LOCK_DEBUG"))
{
lockdebug = EINA_TRUE;
lockmax = atoi(getenv("EVAS_LOCK_DEBUG"));
}
#endif
#ifdef HAVE_EVIL #ifdef HAVE_EVIL
if (!evil_init()) if (!evil_init())
return --_evas_init_count; return --_evas_init_count;

View File

@ -135,19 +135,50 @@ extern EAPI int _evas_log_dom_global;
# include <errno.h> # include <errno.h>
#endif #endif
//#define LKDEBUG 1
#ifdef LKDEBUG
EAPI Eina_Bool lockdebug;
EAPI int lockmax;
#endif
#define LK(x) pthread_mutex_t x #define LK(x) pthread_mutex_t x
#ifndef EVAS_FRAME_QUEUING #ifndef EVAS_FRAME_QUEUING
# define LKI(x) pthread_mutex_init(&(x), NULL); # define LKI(x) pthread_mutex_init(&(x), NULL)
#else #else
# define LKI(x) {pthread_mutexattr_t attr;\ # define LKI(x) do {pthread_mutexattr_t __attr;\
pthread_mutexattr_init(&attr); \ pthread_mutexattr_init(&__attr); \
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \ pthread_mutexattr_settype(&__attr, PTHREAD_MUTEX_RECURSIVE); \
pthread_mutex_init(&(x), &attr);} pthread_mutex_init(&(x), &__attr);} while (0)
#endif #endif
# define LKD(x) pthread_mutex_destroy(&(x)); # define LKD(x) pthread_mutex_destroy(&(x))
# define LKL(x) pthread_mutex_lock(&(x)); # ifdef LKDEBUG
# define LKT(x) pthread_mutex_trylock(&(x)); # define LKL(x) \
# define LKU(x) pthread_mutex_unlock(&(x)); do { \
if (lockdebug) { \
struct timeval t0, t1; \
int dt; \
gettimeofday(&t0, NULL); \
pthread_mutex_lock(&(x)); \
gettimeofday(&t1, NULL); \
dt = (t1.tv_sec - t0.tv_sec) * 1000000; \
if (t1.tv_usec > t0.tv_usec) dt += (t1.tv_usec - t0.tv_usec); \
else dt -= t0.tv_usec - t1.tv_usec; \
dt /= 1000; \
if (dt > lockmax) { \
fprintf(stderr, "HANG %ims - %s:%i - %s()\n", \
dt, __FILE__, __LINE__, __FUNCTION__); \
} \
} \
else { \
pthread_mutex_lock(&(x)); \
} \
} while (0)
# else
# define LKL(x) pthread_mutex_lock(&(x))
# endif
# define LKT(x) pthread_mutex_trylock(&(x))
# define LKU(x) pthread_mutex_unlock(&(x))
# define TH(x) pthread_t x # define TH(x) pthread_t x
# define THI(x) int x # define THI(x) int x
# define TH_MAX 8 # define TH_MAX 8