Index: logger.c =================================================================== RCS file: /usr/cvsroot/asterisk/logger.c,v retrieving revision 1.80 diff -u -r1.80 logger.c --- logger.c 31 Aug 2005 02:43:44 -0000 1.80 +++ logger.c 10 Sep 2005 19:34:49 -0000 @@ -20,6 +20,7 @@ #include #include #include +#include #define SYSLOG_NAMES /* so we can map syslog facilities names to their numeric values, from which is included by logger.h */ @@ -797,6 +798,31 @@ ast_log(LOG_EVENT,"Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n"); if (option_verbose) ast_verbose("Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n"); + } +} + +void ast_backtrace(int levels) +{ + int count=0, i=0; + void **addresses; + char **strings; + + addresses = calloc(levels, sizeof(void *)); + if (addresses) { + count = backtrace(addresses, levels); + strings = backtrace_symbols(addresses, count); + if (strings) { + ast_log(LOG_WARNING, "Got %d backtrace record%c\n", count, count != 1 ? 's' : ' '); + for (i=0; i < count ; i++) { + ast_log(LOG_WARNING, "#%d: [%08X] %s\n", i, (unsigned int)addresses[i], strings[i]); + } + free(strings); + } else { + ast_log(LOG_WARNING, "Could not allocate memory for backtrace\n"); + } + free(addresses); + } else { + ast_log(LOG_WARNING, "Could not allocate memory for backtrace\n"); } } Index: Makefile =================================================================== RCS file: /usr/cvsroot/asterisk/Makefile,v retrieving revision 1.201 diff -u -r1.201 Makefile --- Makefile 31 Aug 2005 18:48:21 -0000 1.201 +++ Makefile 10 Sep 2005 19:34:49 -0000 @@ -42,7 +42,7 @@ OVERWRITE=y #Tell gcc to optimize the code -OPTIMIZE+=-O6 +#OPTIMIZE+=-O6 #Include debug symbols in the executables (-g) and profiling info (-pg) DEBUG=-g #-pg @@ -308,7 +308,7 @@ else #These are used for all but Darwin ASTLINK=-Wl,-E - SOLINK=-shared -Xlinker -x + SOLINK=-shared -Xlinker -x -Wl,-E endif ifeq (${OSARCH},FreeBSD) Index: pbx.c =================================================================== RCS file: /usr/cvsroot/asterisk/pbx.c,v retrieving revision 1.271 diff -u -r1.271 pbx.c --- pbx.c 2 Sep 2005 18:07:26 -0000 1.271 +++ pbx.c 10 Sep 2005 19:34:49 -0000 @@ -1678,6 +1816,7 @@ case STATUS_NO_CONTEXT: if ((action != HELPER_EXISTS) && (action != HELPER_MATCHMORE)) ast_log(LOG_NOTICE, "Cannot find extension context '%s'\n", context); + ast_backtrace(20); break; case STATUS_NO_EXTENSION: if ((action != HELPER_EXISTS) && (action != HELPER_CANMATCH) && (action != HELPER_MATCHMORE)) @@ -2295,6 +2434,7 @@ } else { ast_log(LOG_WARNING, "Channel '%s' sent into invalid extension '%s' in context '%s', but no invalid handler\n", c->name, c->exten, c->context); + ast_backtrace(20); goto out; } } else if (c->_softhangup == AST_SOFTHANGUP_TIMEOUT) { Index: include/asterisk/logger.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/logger.h,v retrieving revision 1.14 diff -u -r1.14 logger.h --- include/asterisk/logger.h 30 Aug 2005 18:32:09 -0000 1.14 +++ include/asterisk/logger.h 10 Sep 2005 19:34:49 -0000 @@ -58,6 +58,8 @@ extern void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__ ((format (printf, 5, 6))); +extern void ast_backtrace(int levels); + extern void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...) __attribute__ ((format (printf, 5, 6)));