From 3e80f82a1bacc75753dbb4df1e4089ae5f5eb134 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 20 Apr 2006 16:26:13 +0000 Subject: execinfo - backtrace() and backtrace_symbols() where available git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3887 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/helperfuncs.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 6412175b1..354e16bc9 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -25,6 +25,9 @@ #include #include #include +#ifdef HAS_EXECINFO +#include +#endif #include "connection.h" #include "users.h" #include "ctables.h" @@ -1426,6 +1429,10 @@ void send_error(char *s) void Error(int status) { + void *array[300]; + size_t size; + char **strings; + signal(SIGALRM, SIG_IGN); signal(SIGPIPE, SIG_IGN); signal(SIGTERM, SIG_IGN); @@ -1434,7 +1441,19 @@ void Error(int status) signal(SIGURG, SIG_IGN); signal(SIGKILL, SIG_IGN); log(DEFAULT,"*** fell down a pothole in the road to perfection ***"); - send_error("Error! Segmentation fault! save meeeeeeeeeeeeee *splat!*"); +#ifdef HAS_EXECINFO + log(DEFAULT,"Please report the backtrace lines shown below with any bugreport to the bugtracker at http://www.inspircd.org/bugtrack/"); + size = backtrace(array, 30); + strings = backtrace_symbols(array, size); + for (int i = 0; i < size; i++) { + log(DEFAULT,"[%d] %s", i, strings[i]); + } + free(strings); + WriteOpers("*** SIGSEGV: Please see the ircd.log for backtrace and report the error to http://www.inspircd.org/bugtrack/"); +#else + log(DEFAULT,"You do not have execinfo.h so i could not backtrace -- on FreeBSD, please install the libexecinfo port."); +#endif + send_error("Somebody screwed up... Whoops. IRC Server terminating."); Exit(status); } -- cgit v1.2.3