From a04efe6afb63d54e12ff8f329cbaf458a2e31b26 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 26 Apr 2011 13:04:25 -0400 Subject: [PATCH] Use SIGTRAP (via G_BREAKPOINT()) if G_DEBUG=fatal-warnings On Linux with gdb, it's much more convenient to debug programs using G_DEBUG=fatal-warnings if we send SIGTRAP instead of abort() by default. The default handler for both is to terminate the process. In particular this makes it more easily possible to debug a warning that's not the first in a program; you can skip past it and go to the warning you care about. The "aborting..." message is removed since it's no longer accurate, and anyways was never very useful; crashes should show up in ABRT/apport type crash catching systems. https://bugzilla.gnome.org/show_bug.cgi?id=648423 --- glib/gmessages.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/glib/gmessages.c b/glib/gmessages.c index 60330d4..337d19a 100644 --- a/glib/gmessages.c +++ b/glib/gmessages.c @@ -548,14 +548,10 @@ g_logv (const gchar *log_domain, else abort (); #else -#if defined (G_ENABLE_DEBUG) && defined (SIGTRAP) if (!(test_level & G_LOG_FLAG_RECURSION)) G_BREAKPOINT (); else abort (); -#else /* !G_ENABLE_DEBUG || !SIGTRAP */ - abort (); -#endif /* !G_ENABLE_DEBUG || !SIGTRAP */ #endif /* !G_OS_WIN32 */ } @@ -818,7 +814,6 @@ _g_log_fallback_handler (const gchar *log_domain, #ifndef G_OS_WIN32 gchar pid_string[FORMAT_UNSIGNED_BUFSIZE]; #endif - gboolean is_fatal = (log_level & G_LOG_FLAG_FATAL) != 0; int fd; /* we cannot call _any_ GLib functions in this fallback handler, @@ -855,10 +850,6 @@ _g_log_fallback_handler (const gchar *log_domain, write_string (fd, level_prefix); write_string (fd, ": "); write_string (fd, message); - if (is_fatal) - write_string (fd, "\naborting...\n"); - else - write_string (fd, "\n"); } static void @@ -927,7 +918,6 @@ g_log_default_handler (const gchar *log_domain, const gchar *message, gpointer unused_data) { - gboolean is_fatal = (log_level & G_LOG_FLAG_FATAL) != 0; gchar level_prefix[STRING_BUFFER_SIZE], *string; GString *gstring; int fd; @@ -988,10 +978,7 @@ g_log_default_handler (const gchar *log_domain, g_string_free (msg, TRUE); } - if (is_fatal) - g_string_append (gstring, "\naborting...\n"); - else - g_string_append (gstring, "\n"); + g_string_append (gstring, "\n"); string = g_string_free (gstring, FALSE); -- 2.7.4