Changeset 1074
- Timestamp:
- 04/30/08 08:24:55 (16 years ago)
- Files:
-
- trunk/libffado/config.h.in (modified) (1 diff)
- trunk/libffado/src/debugmodule/debugmodule.cpp (modified) (1 diff)
- trunk/libffado/src/debugmodule/debugmodule.h (modified) (2 diffs)
- trunk/libffado/src/libutil/PosixMutex.cpp (modified) (3 diffs)
- trunk/libffado/src/libutil/PosixMutex.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/config.h.in
r1072 r1074 61 61 // max amount of function pointers to keep track of 62 62 #define DEBUG_MAX_BACKTRACE_FUNCTIONS_SEEN 64 63 64 // lock debugging 65 #define DEBUG_LOCK_COLLISION_TRACING 1 63 66 64 67 // make this zero to disable the most extreme trunk/libffado/src/debugmodule/debugmodule.cpp
r1046 r1074 640 640 pthread_mutex_unlock(&m_backtrace_lock); 641 641 } 642 643 void * 644 DebugModuleManager::getBacktracePtr(int id) 645 { 646 int nptrs; 647 void *retval = NULL; 648 649 if(id >= DEBUG_MAX_BACKTRACE_LENGTH) { 650 return NULL; 651 } 652 653 pthread_mutex_lock(&m_backtrace_lock); 654 nptrs = backtrace(m_backtrace_buffer, id+1); 655 if(id<nptrs) { 656 retval = m_backtrace_buffer[id]; 657 } 658 pthread_mutex_unlock(&m_backtrace_lock); 659 660 return retval; 661 } 642 662 #endif 643 663 trunk/libffado/src/debugmodule/debugmodule.h
r1046 r1074 246 246 * Backtrace support 247 247 */ 248 #if def DEBUG249 # if DEBUG_BACKTRACE_SUPPORT250 #define debugPrintBacktrace( _SIZE_ ) \251 DebugModuleManager::instance()->printBacktrace( _SIZE_ );252 #endif248 #if DEBUG_BACKTRACE_SUPPORT 249 #define debugPrintBacktrace( _SIZE_ ) \ 250 DebugModuleManager::instance()->printBacktrace( _SIZE_ ); 251 #define debugBacktraceGet( _ID_ ) \ 252 DebugModuleManager::instance()->getBacktracePtr( _ID_ ); 253 253 #else 254 254 #define debugPrintBacktrace( _SIZE_ ) 255 #define debugBacktraceGet( _ID_ ) NULL 255 256 #endif 256 257 … … 333 334 #if DEBUG_BACKTRACE_SUPPORT 334 335 void printBacktrace(int len); 336 void *getBacktracePtr(int id); 335 337 #endif 336 338 trunk/libffado/src/libutil/PosixMutex.cpp
r976 r1074 24 24 #include "PosixMutex.h" 25 25 26 // disable collision tracing for non-debug builds 27 #ifndef DEBUG 28 #undef DEBUG_LOCK_COLLISION_TRACING 29 #define DEBUG_LOCK_COLLISION_TRACING 0 30 #endif 31 32 // check whether backtracing is enabled 33 #if DEBUG_LOCK_COLLISION_TRACING 34 #if DEBUG_BACKTRACE_SUPPORT 35 // ok 36 #else 37 #error cannot enable lock tracing without backtrace support 38 #endif 39 #endif 40 26 41 namespace Util 27 42 { … … 38 53 #endif 39 54 pthread_mutex_init(&m_mutex, &attr); 55 56 #if DEBUG_LOCK_COLLISION_TRACING 57 m_locked_by = NULL; 58 #endif 40 59 } 41 60 … … 49 68 { 50 69 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "(%p) lock\n", this); 70 #if DEBUG_LOCK_COLLISION_TRACING 71 if(TryLock()) { 72 // locking succeeded 73 m_locked_by = debugBacktraceGet(1); 74 debugOutput(DEBUG_LEVEL_VERBOSE, 75 "%p has lock\n", 76 m_locked_by); 77 return; 78 } else { 79 void *lock_try_by = debugBacktraceGet(1); 80 debugOutput(DEBUG_LEVEL_VERBOSE, 81 "Lock collision: %p wants lock, %p has lock\n", 82 lock_try_by); 83 pthread_mutex_lock(&m_mutex); 84 } 85 #else 51 86 pthread_mutex_lock(&m_mutex); 87 #endif 52 88 } 53 89 trunk/libffado/src/libutil/PosixMutex.h
r967 r1074 24 24 #ifndef __POSIX_MUTEX__ 25 25 #define __POSIX_MUTEX__ 26 27 #include "config.h" 26 28 27 29 #include "Mutex.h" … … 55 57 private: 56 58 pthread_mutex_t m_mutex; 59 60 #if DEBUG_LOCK_COLLISION_TRACING 61 void *m_locked_by; 62 #endif 57 63 }; 58 64