diff options
Diffstat (limited to 'src/common/nullpo.c')
-rw-r--r-- | src/common/nullpo.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/common/nullpo.c b/src/common/nullpo.c index e61d52257..98faa9f06 100644 --- a/src/common/nullpo.c +++ b/src/common/nullpo.c @@ -6,13 +6,18 @@ #include "nullpo.h" +#include "common/showmsg.h" + #include <stdio.h> #include <stdarg.h> +#include <stdlib.h> #include <string.h> - -#include "../common/showmsg.h" +#ifdef HAVE_EXECINFO +#include <execinfo.h> +#endif // HAVE_EXECINFO struct nullpo_interface nullpo_s; +struct nullpo_interface *nullpo; /** * Reports failed assertions or NULL pointers @@ -24,6 +29,12 @@ struct nullpo_interface nullpo_s; * @param title Message title to display (i.e. failed assertion or nullpo info) */ void assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) { +#ifdef HAVE_EXECINFO + void *array[10]; + int size; + char **strings; + int i; +#endif // HAVE_EXECINFO if (file == NULL) file = "??"; @@ -32,6 +43,13 @@ void assert_report(const char *file, int line, const char *func, const char *tar ShowError("--- %s --------------------------------------------\n", title); ShowError("%s:%d: '%s' in function `%s'\n", file, line, targetname, func); +#ifdef HAVE_EXECINFO + size = (int)backtrace(array, 10); + strings = backtrace_symbols(array, size); + for (i = 0; i < size; i++) + ShowError("%s\n", strings[i]); + free(strings); +#endif // HAVE_EXECINFO ShowError("--- end %s ----------------------------------------\n", title); } @@ -40,6 +58,5 @@ void assert_report(const char *file, int line, const char *func, const char *tar **/ void nullpo_defaults(void) { nullpo = &nullpo_s; - nullpo->assert_report = assert_report; } |