diff --git a/glib/gutils.c b/glib/gutils.c index 43a277629..4d0794157 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -2390,3 +2390,27 @@ g_check_setuid (void) return FALSE; #endif } + +/** + * g_abort: + * + * A wrapper for the POSIX abort() function. + * + * On Windows it is a function that makes extra effort (including a call + * to abort()) to ensure that a debugger-catchable exception is thrown + * before the program terminates. + * + * See your C library manual for more details about abort(). + * + * Since: 2.50 + */ +void +g_abort (void) +{ + /* One call to break the debugger */ + DebugBreak (); + /* One call in case CRT does get saner about abort() behaviour */ + abort (); + /* And one call to bind them all and terminate the program for sure */ + ExitProcess (127); +} diff --git a/glib/gutils.h b/glib/gutils.h index b24bc0b96..f84fbcb0b 100644 --- a/glib/gutils.h +++ b/glib/gutils.h @@ -299,6 +299,16 @@ g_bit_storage_impl (gulong number) #endif } +/* Crashes the program. */ +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_50 +#ifndef G_OS_WIN32 +# define g_abort() abort () +#else +GLIB_AVAILABLE_IN_2_50 +void g_abort (void) G_GNUC_NORETURN G_ANALYZER_NORETURN; +#endif +#endif + #ifndef G_DISABLE_DEPRECATED /*