bug #8076 check option_debug before printing to debug channel.

patch provided in bugnote, with minor changes.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44253 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Matt O'Gorman
2006-10-03 15:53:07 +00:00
parent c9c1613503
commit ae8cc3e18b
67 changed files with 1718 additions and 922 deletions

View File

@@ -840,13 +840,16 @@ void ast_backtrace(void)
if ((addresses = ast_calloc(MAX_BACKTRACE_FRAMES, sizeof(*addresses)))) {
count = backtrace(addresses, MAX_BACKTRACE_FRAMES);
if ((strings = backtrace_symbols(addresses, count))) {
ast_log(LOG_DEBUG, "Got %d backtrace record%c\n", count, count != 1 ? 's' : ' ');
if (option_debug)
ast_log(LOG_DEBUG, "Got %d backtrace record%c\n", count, count != 1 ? 's' : ' ');
for (i=0; i < count ; i++) {
ast_log(LOG_DEBUG, "#%d: [%08X] %s\n", i, (unsigned int)addresses[i], strings[i]);
if (option_debug)
ast_log(LOG_DEBUG, "#%d: [%08X] %s\n", i, (unsigned int)addresses[i], strings[i]);
}
free(strings);
} else {
ast_log(LOG_DEBUG, "Could not allocate memory for backtrace\n");
if (option_debug)
ast_log(LOG_DEBUG, "Could not allocate memory for backtrace\n");
}
free(addresses);
}