Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Hook into glib's logging function so we can get stacks for glib asser…
Browse files Browse the repository at this point in the history
…tions/warnings. b=381133 r=bsmedberg
  • Loading branch information
dbaron committed May 23, 2007
1 parent b68151e commit 87c77a8
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions xpfe/bootstrap/nsSigHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,31 @@ void beos_signal_handler(int signum) {
}
#endif

#ifdef MOZ_WIDGET_GTK2

#include <glib.h>

static GLogFunc orig_log_func = NULL;

extern "C" {
static void
my_glib_log_func(const gchar *log_domain, GLogLevelFlags log_level,
const gchar *message, gpointer user_data);
}

/* static */ void
my_glib_log_func(const gchar *log_domain, GLogLevelFlags log_level,
const gchar *message, gpointer user_data)
{
orig_log_func(log_domain, log_level, message, NULL);

if (log_level & (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING)) {
NS_DebugBreak(NS_DEBUG_ASSERTION, message, "glib assertion", __FILE__, __LINE__);
}
}

#endif

void InstallUnixSignalHandlers(const char *ProgramName)
{
PL_strncpy(_progname,ProgramName, (sizeof(_progname)-1) );
Expand Down Expand Up @@ -228,4 +253,17 @@ void InstallUnixSignalHandlers(const char *ProgramName)
#ifdef XP_BEOS
signal(SIGTERM, beos_signal_handler);
#endif

#ifdef MOZ_WIDGET_GTK2
const char *assertString = PR_GetEnv("XPCOM_DEBUG_BREAK");
if (assertString &&
(!strcmp(assertString, "suspend") ||
!strcmp(assertString, "stack") ||
!strcmp(assertString, "abort") ||
!strcmp(assertString, "trap") ||
!strcmp(assertString, "break"))) {
// Override the default glib logging function so we get stacks for it too.
orig_log_func = g_log_set_default_handler(my_glib_log_func, NULL);
}
#endif
}

0 comments on commit 87c77a8

Please sign in to comment.