diff options
author | Adam Jackson <ajax@nwnk.net> | 2005-07-02 18:06:05 +0000 |
---|---|---|
committer | Adam Jackson <ajax@nwnk.net> | 2005-07-02 18:06:05 +0000 |
commit | e58c09d31bdf90210e2ec1ef976cea0459cdc02a (patch) | |
tree | 7f10bdc95ce4635737e301b7cd843870c962421b | |
parent | e6602b041fe489d51a1d7fac55cbbb12b1826ba1 (diff) |
Bug #3687: Print backtraces on fatal signal on glibc systems.
-rw-r--r-- | hw/xfree86/common/xf86Events.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 14d653f1a..318d8b0ab 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -1273,6 +1273,29 @@ xf86InterceptSigIll(void (*sigillhandler)(void)) xf86SigIllHandler = sigillhandler; } +#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 1) + +#include <execinfo.h> + +static inline void xorg_backtrace(void) +{ + void *array[32]; /* deeper nesting than this means something's wrong */ + size_t size, i; + char **strings; + ErrorF("\nBacktrace:\n"); + size = backtrace(array, 32); + strings = backtrace_symbols(array, size); + for (i = 0; i < size; i++) + ErrorF("%d: %s\n", i, strings[i]); + free(strings); +} + +#else /* not glibc or glibc < 2.1 */ + +static inline void xorg_backtrace(void) { return; } + +#endif + /* * xf86SigHandler -- * Catch unexpected signals and exit or continue cleanly. @@ -1306,6 +1329,9 @@ xf86SigHandler(int signo) " *** If unresolved symbols were reported above, they might not\n" " *** be the reason for the server aborting.\n"); #endif + + xorg_backtrace(); + FatalError("Caught signal %d. Server aborting\n", signo); } |