aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--configure.ac14
-rw-r--r--lib/ephy-debug.c58
3 files changed, 77 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f7191a20c..cc71645e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2004-09-27 Christian Persch <chpe@cvs.gnome.org>
+ * configure.ac:
+ * lib/ephy-debug.c: (trap_handler), (ephy_debug_init):
+
+ Improved debugging support. Fixes bug #153805.
+
+2004-09-27 Christian Persch <chpe@cvs.gnome.org>
+
* data/ui/epiphany-ui.xml:
Install a placeholder for the view toggles group. Fixes bug #153767.
diff --git a/configure.ac b/configure.ac
index 56b3c2d28..c392c3044 100644
--- a/configure.ac
+++ b/configure.ac
@@ -364,6 +364,20 @@ AC_DEFINE([GTKMOZEMBED_BROKEN_RELOAD],[1],[Define if GtkMozEmbed has broken relo
AC_MSG_RESULT([couldn't autodetect, assuming yes])
+dnl check if mozilla's stack walker is accessible
+
+AC_MSG_CHECKING([for DumpStackToFile])
+
+AC_LINK_IFELSE(
+ AC_LANG_PROGRAM(
+ [[#include <stdio.h>]],
+ [[extern void _Z15DumpStackToFileP8_IO_FILE (FILE *f);]]),
+ [AC_DEFINE([HAVE_DUMPSTACKTOFILE], [1], [Define if DumpStackToFile is found]) result=yes],
+ [result=no])
+
+AC_MSG_RESULT([$result])
+
+dnl restore flags
CXXFLAGS=$_SAVE_CXXFLAGS
AC_LANG_POP(C++)
diff --git a/lib/ephy-debug.c b/lib/ephy-debug.c
index a0f2929af..b9f8386b6 100644
--- a/lib/ephy-debug.c
+++ b/lib/ephy-debug.c
@@ -24,12 +24,21 @@
#include "ephy-debug.h"
-#include <string.h>
-
#ifndef DISABLE_PROFILING
+#include <glib/gbacktrace.h>
+#include <string.h>
+#include <stdio.h>
+#include <signal.h>
+
static GHashTable *ephy_profilers_hash = NULL;
static const char *ephy_profile_modules = NULL;
+static const char *ephy_debug_break = NULL;
+
+#ifdef HAVE_DUMPSTACKTOFILE
+#define DumpStackToFile(f) _Z15DumpStackToFileP8_IO_FILE(f)
+extern void _Z15DumpStackToFileP8_IO_FILE (FILE *f);
+#endif
#endif
@@ -76,15 +85,60 @@ log_module (const gchar *log_domain,
}
}
+static void
+trap_handler (const char *log_domain,
+ GLogLevelFlags log_level,
+ const char *message,
+ gpointer user_data)
+{
+ g_log_default_handler (log_domain, log_level, message, user_data);
+
+ if (ephy_debug_break != NULL &&
+ (log_level & (G_LOG_LEVEL_WARNING |
+ G_LOG_LEVEL_ERROR |
+ G_LOG_LEVEL_CRITICAL |
+ G_LOG_FLAG_FATAL)))
+ {
+ if (strcmp (ephy_debug_break, "stack") == 0)
+ {
+#ifdef HAVE_DUMPSTACKTOFILE
+ DumpStackToFile (stderr);
+#else
+ g_on_error_stack_trace (g_get_prgname ());
+#endif
+ }
+ else if (strcmp (ephy_debug_break, "trap") == 0)
+ {
+ G_BREAKPOINT ();
+ }
+ else if (strcmp (ephy_debug_break, "suspend") == 0)
+ {
+ g_print ("Suspending program; attach with the debugger.\n");
+
+ raise (SIGSTOP);
+ }
+ else if (strcmp (ephy_debug_break, "abort") == 0)
+ {
+ raise (SIGABRT);
+ }
+ }
+}
+
#endif
void
ephy_debug_init (void)
{
#ifndef DISABLE_LOGGING
+ const char *debug_break;
+
ephy_log_modules = g_getenv ("EPHY_LOG_MODULES");
+ ephy_debug_break = g_getenv ("EPHY_DEBUG_BREAK");
+
+ g_log_set_default_handler (trap_handler, NULL);
g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, log_module, NULL);
+
#endif
#ifndef DISABLE_PROFILING
ephy_profile_modules = g_getenv ("EPHY_PROFILE_MODULES");