[asterisk-commits] mmichelson: branch mmichelson/lock_backtraces r115323 - /team/mmichelson/lock...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 5 16:57:53 CDT 2008


Author: mmichelson
Date: Mon May  5 16:57:53 2008
New Revision: 115323

URL: http://svn.digium.com/view/asterisk?view=rev&rev=115323
Log:
Print backtrace information when the "core show locks" command is
issued.

Next step. Add in a crapload of #ifdef HAVE_BKTR stuff so that this
backtrace information is only where it should be


Modified:
    team/mmichelson/lock_backtraces/main/utils.c

Modified: team/mmichelson/lock_backtraces/main/utils.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/lock_backtraces/main/utils.c?view=diff&rev=115323&r1=115322&r2=115323
==============================================================================
--- team/mmichelson/lock_backtraces/main/utils.c (original)
+++ team/mmichelson/lock_backtraces/main/utils.c Mon May  5 16:57:53 2008
@@ -718,6 +718,28 @@
 	return "UNKNOWN";
 }
 
+static void append_backtrace_information(struct ast_str **str, struct ast_bt *bt)
+{
+	char **symbols;
+
+	if (!bt) {
+		ast_str_append(str, 0, "\tNo backtrace to print\n");
+		return;
+	}
+
+	if ((symbols = backtrace_symbols(bt->addresses, bt->num_frames))) {
+		int frame_iterator;
+		
+		for (frame_iterator = 0; frame_iterator < bt->num_frames; ++frame_iterator) {
+			ast_str_append(str, 0, "\t%s\n", symbols[frame_iterator]);
+		}
+
+		free(symbols);
+	} else {
+		ast_str_append(str, 0, "\tCouldn't retrieve backtrace symbols\n");
+	}
+}
+
 static void append_lock_information(struct ast_str **str, struct thr_lock_info *lock_info, int i)
 {
 	int j;
@@ -732,6 +754,8 @@
 				   lock_info->locks[i].func, lock_info->locks[i].lock_name,
 				   lock_info->locks[i].lock_addr, 
 				   lock_info->locks[i].times_locked);
+
+	append_backtrace_information(str, lock_info->locks[i].backtrace);
 	
 	if (!lock_info->locks[i].pending || lock_info->locks[i].pending == -1)
 		return;
@@ -746,6 +770,7 @@
 	for (j = 0; *str && j < lock->reentrancy; j++) {
 		ast_str_append(str, 0, "=== --- ---> Locked Here: %s line %d (%s)\n",
 					   lock->file[j], lock->lineno[j], lock->func[j]);
+		append_backtrace_information(str, lock_info->locks[i].backtrace);
 	}
 	ast_reentrancy_unlock(lock);	
 }




More information about the asterisk-commits mailing list