diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-09-14 20:40:40 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-09-14 20:40:40 +0200 |
commit | dd39b6fd12717957dad02bc84e29286db8497cb4 (patch) | |
tree | 357a3435c7158dd1e2918db00f4dfc823cff8654 | |
parent | 2f14d32ae462ad0aacbc4c10a499ce83c1a5f369 (diff) |
optionally raise trap when encountering inconsistency
-rw-r--r-- | mutrace.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -19,9 +19,16 @@ /* FIXMES: * * - we probably should cover rwlocks, too + * - and conds, too! * */ +#if defined(__i386__) || defined(__x86_64__) +#define DEBUG_TRAP __asm__("int $3") +#else +#define DEBUG_TRAP raise(SIGTRAP) +#endif + typedef void (*fnptr_t)(void); struct mutex_info { @@ -61,6 +68,8 @@ static unsigned show_n_owner_changed_min = 2; static unsigned show_n_contended_min = 0; static unsigned show_n_max = 10; +static bool raise_trap = false; + static int (*real_pthread_mutex_init)(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr) = NULL; static int (*real_pthread_mutex_destroy)(pthread_mutex_t *mutex) = NULL; static int (*real_pthread_mutex_lock)(pthread_mutex_t *mutex) = NULL; @@ -609,6 +618,9 @@ static void mutex_lock(pthread_mutex_t *mutex, bool busy) { if (mi->n_lock_level > 0 && mi->type != PTHREAD_MUTEX_RECURSIVE) { __sync_fetch_and_add(&n_broken, 1); mi->broken = true; + + if (raise_trap) + DEBUG_TRAP; } mi->n_lock_level++; @@ -695,6 +707,9 @@ static void mutex_unlock(pthread_mutex_t *mutex) { if (mi->n_lock_level <= 0) { __sync_fetch_and_add(&n_broken, 1); mi->broken = true; + + if (raise_trap) + DEBUG_TRAP; } mi->n_lock_level--; |