#include <locale.h>
#include <errno.h>
-#include "galias.h"
#include "glib.h"
#include "gdebug.h"
#include "gprintfint.h"
-#include "gthreadinit.h"
+#include "gthreadprivate.h"
+#include "galias.h"
#ifdef G_OS_WIN32
+#include <process.h> /* For getpid() */
#include <io.h>
+# define STRICT /* Strict typing, please */
+# define _WIN32_WINDOWS 0x0401 /* to get IsDebuggerPresent */
+# include <windows.h>
+# undef STRICT
#endif
/* --- structures --- */
if (val)
{
- static const GDebugKey keys[] = {
+ const GDebugKey keys[] = {
{ "error", G_LOG_LEVEL_ERROR },
{ "critical", G_LOG_LEVEL_CRITICAL },
{ "warning", G_LOG_LEVEL_WARNING },
#ifdef G_OS_WIN32
gchar *locale_msg = g_locale_from_utf8 (fatal_msg_buf, -1, NULL, NULL, NULL);
+ MessageBox (NULL, locale_msg, NULL,
+ MB_ICONERROR|MB_SETFOREGROUND);
if (IsDebuggerPresent () && !(test_level & G_LOG_FLAG_RECURSION))
- {
- MessageBox (NULL, locale_msg, NULL,
- MB_ICONERROR|MB_SETFOREGROUND);
- G_BREAKPOINT ();
- }
-
- FatalAppExit (0, locale_msg);
- /* In case somebody runs a debug Windows and chooses to
- * continue, don't let her.
- */
- abort ();
+ G_BREAKPOINT ();
+ else
+ abort ();
#else
#if defined (G_ENABLE_DEBUG) && defined (SIGTRAP)
if (!(test_level & G_LOG_FLAG_RECURSION))
}
void
+g_warn_message (const char *domain,
+ const char *file,
+ int line,
+ const char *func,
+ const char *warnexpr)
+{
+ char *s, lstr[32];
+ g_snprintf (lstr, 32, "%d", line);
+ if (warnexpr)
+ s = g_strconcat ("(", file, ":", lstr, "):",
+ func, func[0] ? ":" : "",
+ " runtime check failed: (", warnexpr, ")", NULL);
+ else
+ s = g_strconcat ("(", file, ":", lstr, "):",
+ func, func[0] ? ":" : "",
+ " ", "code should not be reached", NULL);
+ g_log (domain, G_LOG_LEVEL_WARNING, "%s", s);
+ g_free (s);
+}
+
+void
g_assert_warning (const char *log_domain,
const char *file,
const int line,
{
const gchar *prg_name = g_get_prgname ();
-#ifdef G_OS_WIN32
- if (prg_name)
- prg_name = g_strdup (prg_name);
- else
- {
- if (G_WIN32_HAVE_WIDECHAR_API ())
- {
- wchar_t buf[MAX_PATH+1];
- if (GetModuleFileNameW (GetModuleHandle (NULL),
- buf, G_N_ELEMENTS (buf)) > 0)
- {
- gchar *utf8_buf = g_utf16_to_utf8 (buf, -1,
- NULL, NULL, NULL);
- if (utf8_buf)
- {
- prg_name = g_path_get_basename (utf8_buf);
- g_free (utf8_buf);
- }
- }
- }
- else
- {
- gchar buf[MAX_PATH+1];
- if (GetModuleFileNameA (GetModuleHandle (NULL),
- buf, G_N_ELEMENTS (buf)) > 0)
- {
- gchar *locale_buf = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
- if (locale_buf)
- {
- prg_name = g_path_get_basename (locale_buf);
- g_free (locale_buf);
- }
- }
- }
- }
-
- if (prg_name)
- {
- g_string_append_printf (gstring, "(%s): ", prg_name);
- g_free ((gchar *) prg_name);
- }
-#else
if (!prg_name)
g_string_append_printf (gstring, "(process:%lu): ", (gulong)getpid ());
else
g_string_append_printf (gstring, "(%s:%lu): ", prg_name, (gulong)getpid ());
-#endif
}
if (log_domain)
}
void
-_g_messages_thread_init (void)
+_g_messages_thread_init_nomessage (void)
{
g_messages_lock = g_mutex_new ();
+ g_log_depth = g_private_new (NULL);
g_messages_prefixed_init ();
_g_debug_init ();
}
-void
-_g_messages_thread_private_init (void)
-{
- g_assert (g_log_depth == NULL);
- g_log_depth = g_private_new (NULL);
-}
-
gboolean _g_debug_initialized = FALSE;
guint _g_debug_flags = 0;
val = g_getenv ("G_DEBUG");
if (val != NULL)
{
- static const GDebugKey keys[] = {
- {"fatal_warnings", G_DEBUG_FATAL_WARNINGS}
+ const GDebugKey keys[] = {
+ {"fatal_warnings", G_DEBUG_FATAL_WARNINGS},
+ {"fatal_criticals", G_DEBUG_FATAL_CRITICALS}
};
_g_debug_flags = g_parse_debug_string (val, keys, G_N_ELEMENTS (keys));
fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
g_log_set_always_fatal (fatal_mask);
}
+
+ if (_g_debug_flags & G_DEBUG_FATAL_CRITICALS)
+ {
+ GLogLevelFlags fatal_mask;
+
+ fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
+ fatal_mask |= G_LOG_LEVEL_CRITICAL;
+ g_log_set_always_fatal (fatal_mask);
+ }
}
+
+#define __G_MESSAGES_C__
+#include "galiasdef.c"