diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-07-30 21:15:57 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-07-30 21:15:57 +0800 |
commit | fc8cf4f93bf59f7669c72e3ae6932edc1fe5fa5f (patch) | |
tree | 812cb95e643f6fdbe2594369d83f41c175f5f9e2 /lib | |
parent | 4f48f200cc0c3bd8515f09db9983828ffea499a2 (diff) | |
download | gsoc2013-epiphany-fc8cf4f93bf59f7669c72e3ae6932edc1fe5fa5f.tar.gz gsoc2013-epiphany-fc8cf4f93bf59f7669c72e3ae6932edc1fe5fa5f.tar.zst gsoc2013-epiphany-fc8cf4f93bf59f7669c72e3ae6932edc1fe5fa5f.zip |
ALlow EPHY_DEBUG_BREAK even in non-debug builds.
2005-07-30 Christian Persch <chpe@cvs.gnome.org>
* lib/ephy-debug.c: (trap_handler), (ephy_debug_init):
ALlow EPHY_DEBUG_BREAK even in non-debug builds.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ephy-debug.c | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/lib/ephy-debug.c b/lib/ephy-debug.c index 6ec0565c2..a00fe1fab 100644 --- a/lib/ephy-debug.c +++ b/lib/ephy-debug.c @@ -22,20 +22,19 @@ #include "ephy-debug.h" -#ifndef DISABLE_PROFILING - -#include <glib/gbacktrace.h> #include <string.h> +#include <execinfo.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> -#include <execinfo.h> +#include <glib/gbacktrace.h> -static GHashTable *ephy_profilers_hash = NULL; -static const char *ephy_profile_modules = NULL; static const char *ephy_debug_break = NULL; -#endif +#ifndef DISABLE_PROFILING +static GHashTable *ephy_profilers_hash = NULL; +static const char *ephy_profile_modules = NULL; +#endif /* !DISABLE_PROFILING */ #ifndef DISABLE_LOGGING @@ -80,6 +79,8 @@ log_module (const gchar *log_domain, } } +#endif /* !DISABLE_LOGGING */ + #define MAX_DEPTH 200 static void @@ -96,7 +97,17 @@ trap_handler (const char *log_domain, G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL))) { - if (strcmp (ephy_debug_break, "stack") == 0) + if (strcmp (ephy_debug_break, "suspend") == 0) + { + /* the suspend case is first because we wanna send the signal before + * other threads have had a chance to get too far from the state that + * caused this assertion (in case they happen to have been involved). + */ + g_print ("Suspending program; attach with the debugger.\n"); + + raise (SIGSTOP); + } + else if (strcmp (ephy_debug_break, "stack") == 0) { void *array[MAX_DEPTH]; size_t size; @@ -106,31 +117,36 @@ trap_handler (const char *log_domain, } else if (strcmp (ephy_debug_break, "trap") == 0) { + /* FIXME: disable the handler for a moment so we + * don't crash if we don't actually run under gdb + */ G_BREAKPOINT (); } - else if (strcmp (ephy_debug_break, "suspend") == 0) + else if (strcmp (ephy_debug_break, "warn") == 0) { - g_print ("Suspending program; attach with the debugger.\n"); - - raise (SIGSTOP); + /* default behaviour only */ + } + else + { + g_print ("Unrecognised value of EPHY_DEBUG_BREAK env var: %s!\n", + ephy_debug_break); } } } -#endif - void ephy_debug_init (void) { #ifndef DISABLE_LOGGING 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 + + ephy_debug_break = g_getenv ("EPHY_DEBUG_BREAK"); + g_log_set_default_handler (trap_handler, NULL); + #ifndef DISABLE_PROFILING ephy_profile_modules = g_getenv ("EPHY_PROFILE_MODULES"); #endif |