changeset 2661:f6c7271df7de trunk

[svn] - use execinfo.h to provide more useful information about crashes
author nenolod
date Sun, 08 Apr 2007 18:05:09 -0700
parents 8d0b89db56e5
children 09b404d61ebd
files ChangeLog configure.ac src/audacious/build_stamp.c src/audacious/signals.c
diffstat 4 files changed, 57 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Apr 07 05:36:05 2007 -0700
+++ b/ChangeLog	Sun Apr 08 18:05:09 2007 -0700
@@ -1,3 +1,10 @@
+2007-04-07 12:36:05 +0000  Giacomo Lozito <james@develia.org>
+  revision [4346]
+  - fixed c++ish declaration in a c file (part 7)
+  trunk/src/audacious/util.c |   21 ++++++++++++++-------
+  1 file changed, 14 insertions(+), 7 deletions(-)
+
+
 2007-04-07 12:29:39 +0000  Giacomo Lozito <james@develia.org>
   revision [4344]
   - fixed c++ish declaration in a c file (part 6)
--- a/configure.ac	Sat Apr 07 05:36:05 2007 -0700
+++ b/configure.ac	Sun Apr 08 18:05:09 2007 -0700
@@ -33,7 +33,6 @@
 AM_GNU_GETTEXT
 AM_GNU_GETTEXT_VERSION([0.12.1])
 
-
 dnl Check for C compiler
 
 AC_PROG_CC
@@ -284,6 +283,7 @@
 AC_CHECK_HEADERS(limits.h)
 AC_CHECK_HEADERS(wchar.h)
 AC_CHECK_HEADERS(fts.h)
+AC_CHECK_HEADERS(execinfo.h)
 
 AC_CHECK_FUNCS([mkdtemp getmntinfo statvfs strtoul lrintf])
 
--- a/src/audacious/build_stamp.c	Sat Apr 07 05:36:05 2007 -0700
+++ b/src/audacious/build_stamp.c	Sun Apr 08 18:05:09 2007 -0700
@@ -1,2 +1,2 @@
 #include <glib.h>
-const gchar *svn_stamp = "20070407-4344";
+const gchar *svn_stamp = "20070407-4346";
--- a/src/audacious/signals.c	Sat Apr 07 05:36:05 2007 -0700
+++ b/src/audacious/signals.c	Sun Apr 08 18:05:09 2007 -0700
@@ -26,9 +26,56 @@
 #include <sys/types.h>
 #include <signal.h>
 
+#ifdef HAVE_EXECINFO_H
+# include <execinfo.h>
+#endif
+
 #include "main.h"
 #include "ui_main.h"
 #include "signals.h"
+#include "build_stamp.h"
+
+static void
+signal_process_segv(void)
+{
+    g_printerr(_("\nAudacious has caught signal 11 (SIGSEGV).\n\n"
+         "We apologize for the inconvenience, but Audacious has crashed.\n"
+         "This is a bug in the program, and should never happen under normal circumstances.\n"
+	 "Your current configuration has been saved and should not be damaged.\n\n"
+	 "You can help improve the quality of Audacious by filing a bug at http://bugs-meta.atheme.org\n"
+         "Please include the entire text of this message and a description of what you were doing when\n"
+         "this crash occured in order to quickly expedite the handling of your bug report:\n\n"));
+
+    g_printerr("Program version: Audacious %s (buildid: %s)\n\n", VERSION, svn_stamp);
+
+#ifdef HAVE_EXECINFO_H
+    {
+        void *stack[20];
+        size_t size;
+        char **strings;
+        size_t i;
+
+        size = backtrace(stack, 20);
+        strings = backtrace_symbols(stack, size);
+
+        g_printerr("Stacktrace (%zd frames):\n", size);
+
+        for (i = 0; i < size; i++)
+           g_printerr("   %d. %s\n", i + 1, strings[i]);
+
+        g_free(strings);
+    }
+#else
+    g_printerr("Stacktrace was unavailable.\n");
+#endif
+
+    g_printerr(_("\nBugs can be reported at http://bugs-meta.atheme.org against the Audacious product.\n"));
+
+    g_critical("Received SIGSEGV -- Audacious has crashed.");
+
+    bmp_config_save();
+    abort();
+}
 
 static void *
 signal_process_signals (void *data)
@@ -53,12 +100,7 @@
             break;
 
         case SIGSEGV:
-            g_printerr(_("\nReceived SIGSEGV\n\n"
-                         "This could be a bug in Audacious. If you don't know why this happened, "
-                         "file a bug at http://bugs-meta.atheme.org/\n\n"));
-            g_critical("Received SIGSEGV");
-            bmp_config_save();
-            abort();
+            signal_process_segv();
             break;
 
         case SIGINT: