A new feature thanks to the fine folks at Switchvox!

If a deadlock is detected, then the typical lock information will be
printed along with a backtrace of the stack for the offending threads.
Use of this requires compiling with DETECT_DEADLOCKS and having glibc
installed.

Furthermore, issuing the "core show locks" CLI command will print the
normal lock information as well as a backtraces for each lock. This
requires that DEBUG_THREADS is enabled and that glibc is installed.

All the backtrace features may be disabled by running the configure
script with --without-execinfo as an argument



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@118173 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Michelson
2008-05-23 22:35:50 +00:00
parent 1457c99ea8
commit 975a848b67
11 changed files with 737 additions and 308 deletions

View File

@@ -578,7 +578,16 @@ unsigned int ast_hashtab_hash_contexts(const void *obj)
void ast_mark_lock_acquired(void *lock_addr)
{
}
#ifdef HAVE_BKTR
void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt)
{
}
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt)
{
}
#else
void ast_remove_lock_info(void *lock_addr)
{
}
@@ -587,5 +596,6 @@ void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr)
{
}
#endif
#endif
#endif /* HAVE_BKTR */
#endif /* !defined(LOW_MEMORY) */
#endif /* DEBUG_THREADS */

View File

@@ -86,6 +86,21 @@ enum ast_lock_type {
};
#endif
#if !defined(LOW_MEMORY)
#ifdef HAVE_BKTR
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt);
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt)
{
/* not a lot to do in a standalone w/o threading! */
}
void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt);
void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt)
{
/* not a lot to do in a standalone w/o threading! */
}
#else
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr);
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
@@ -94,14 +109,15 @@ void ast_store_lock_info(enum ast_lock_type type, const char *filename,
/* not a lot to do in a standalone w/o threading! */
}
void ast_mark_lock_acquired(void *);
void ast_mark_lock_acquired(void *foo)
void ast_remove_lock_info(void *lock_addr);
void ast_remove_lock_info(void *lock_addr)
{
/* not a lot to do in a standalone w/o threading! */
}
#endif /* HAVE_BKTR */
void ast_remove_lock_info(void *lock_addr);
void ast_remove_lock_info(void *lock_addr)
void ast_mark_lock_acquired(void *);
void ast_mark_lock_acquired(void *foo)
{
/* not a lot to do in a standalone w/o threading! */
}

View File

@@ -705,7 +705,16 @@ unsigned int ast_hashtab_hash_contexts(const void *obj)
void ast_mark_lock_acquired(void *lock_addr)
{
}
#ifdef HAVE_BKTR
void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt)
{
}
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt)
{
}
#else
void ast_remove_lock_info(void *lock_addr)
{
}
@@ -714,5 +723,6 @@ void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr)
{
}
#endif
#endif
#endif /* HAVE_BKTR */
#endif /* !defined(LOW_MEMORY) */
#endif /* DEBUG_THREADS */

View File

@@ -366,3 +366,23 @@ void ast_register_thread(char *name)
void ast_unregister_thread(void *id)
{
}
#ifdef HAVE_BKTR
struct ast_bt *ast_bt_create(void);
struct ast_bt *ast_bt_create(void)
{
return NULL;
}
int ast_bt_get_addresses(struct ast_bt *bt);
int ast_bt_get_addresses(struct ast_bt *bt)
{
return 0;
}
void *ast_bt_destroy(struct ast_bt *bt);
void *ast_bt_destroy(struct ast_bt *bt)
{
return NULL;
}
#endif

View File

@@ -378,3 +378,20 @@ void ast_register_thread(char *name)
void ast_unregister_thread(void *id)
{
}
#ifdef HAVE_BKTR
struct ast_bt* ast_bt_create(void)
{
return NULL;
}
int ast_bt_get_addresses(struct ast_bt *bt)
{
return -1;
}
void *ast_bt_destroy(struct ast_bt *bt)
{
return NULL;
}
#endif

View File

@@ -269,3 +269,22 @@ void ast_register_thread(char *name)
void ast_unregister_thread(void *id)
{
}
#ifdef HAVE_BKTR
struct ast_bt *ast_bt_create(void);
struct ast_bt *ast_bt_create(void)
{
return NULL;
}
int ast_bt_get_addresses(struct ast_bt *bt);
int ast_bt_get_addresses(struct ast_bt *bt)
{
return 0;
}
void *ast_bt_destroy(struct ast_bt *bt);
void *ast_bt_destroy(struct ast_bt *bt)
{
return NULL;
}
#endif