Thread Debugging: Add LWP to core show locks output
This patch adds the LWP to core show locks output if it is available. Review: https://reviewboard.asterisk.org/r/3142/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@406416 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
a9911f027e
commit
2a9d15b400
5
CHANGES
5
CHANGES
|
@ -73,6 +73,11 @@ MixMonitor
|
||||||
* A new function, MIXMONITOR, has been added to allow access to individual
|
* A new function, MIXMONITOR, has been added to allow access to individual
|
||||||
instances of MixMonitor on a channel.
|
instances of MixMonitor on a channel.
|
||||||
|
|
||||||
|
Debugging
|
||||||
|
-------------------------
|
||||||
|
* Core Show Locks output now includes Thread/LWP ID if the platform
|
||||||
|
supports this feature.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
--- Functionality changes from Asterisk 12.0.0 to Asterisk 12.1.0 ------------
|
--- Functionality changes from Asterisk 12.0.0 to Asterisk 12.1.0 ------------
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
14
main/utils.c
14
main/utils.c
|
@ -589,11 +589,11 @@ struct thr_lock_info {
|
||||||
/*! This is the actual container of info for what locks this thread holds */
|
/*! This is the actual container of info for what locks this thread holds */
|
||||||
struct {
|
struct {
|
||||||
const char *file;
|
const char *file;
|
||||||
int line_num;
|
|
||||||
const char *func;
|
const char *func;
|
||||||
const char *lock_name;
|
const char *lock_name;
|
||||||
void *lock_addr;
|
void *lock_addr;
|
||||||
int times_locked;
|
int times_locked;
|
||||||
|
int line_num;
|
||||||
enum ast_lock_type type;
|
enum ast_lock_type type;
|
||||||
/*! This thread is waiting on this lock */
|
/*! This thread is waiting on this lock */
|
||||||
int pending:2;
|
int pending:2;
|
||||||
|
@ -607,6 +607,8 @@ struct thr_lock_info {
|
||||||
* The index (num_locks - 1) has the info on the last one in the
|
* The index (num_locks - 1) has the info on the last one in the
|
||||||
* locks member */
|
* locks member */
|
||||||
unsigned int num_locks;
|
unsigned int num_locks;
|
||||||
|
/*! The LWP id (which GDB prints) */
|
||||||
|
int lwp;
|
||||||
/*! Protects the contents of the locks member
|
/*! Protects the contents of the locks member
|
||||||
* Intentionally not ast_mutex_t */
|
* Intentionally not ast_mutex_t */
|
||||||
pthread_mutex_t lock;
|
pthread_mutex_t lock;
|
||||||
|
@ -1049,8 +1051,13 @@ struct ast_str *ast_dump_locks(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!header_printed) {
|
if (!header_printed) {
|
||||||
ast_str_append(&str, 0, "=== Thread ID: 0x%lx (%s)\n", (long) lock_info->thread_id,
|
if (lock_info->lwp != -1) {
|
||||||
lock_info->thread_name);
|
ast_str_append(&str, 0, "=== Thread ID: 0x%lx LWP:%d (%s)\n",
|
||||||
|
(long) lock_info->thread_id, lock_info->lwp, lock_info->thread_name);
|
||||||
|
} else {
|
||||||
|
ast_str_append(&str, 0, "=== Thread ID: 0x%lx (%s)\n",
|
||||||
|
(long) lock_info->thread_id, lock_info->thread_name);
|
||||||
|
}
|
||||||
header_printed = 1;
|
header_printed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1145,6 +1152,7 @@ static void *dummy_start(void *data)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
lock_info->thread_id = pthread_self();
|
lock_info->thread_id = pthread_self();
|
||||||
|
lock_info->lwp = ast_get_tid();
|
||||||
lock_info->thread_name = strdup(a.name);
|
lock_info->thread_name = strdup(a.name);
|
||||||
|
|
||||||
pthread_mutexattr_init(&mutex_attr);
|
pthread_mutexattr_init(&mutex_attr);
|
||||||
|
|
Loading…
Reference in New Issue