This website requires JavaScript.
Explore
Help
Sign In
luc14n0
/
glib
Watch
1
Star
0
Fork
0
You've already forked glib
mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced
2024-11-06 01:16:17 +01:00
Code
Issues
Packages
Projects
Releases
Wiki
Activity
abbb54cdd6
glib
/
tests
/
assert-msg-test.c
9 lines
92 B
C
Raw
Normal View
History
Unescape
Escape
Support storing assertion messages into core dump Crash interception/debugging systems like Apport or ABRT capture core dumps for later crash analysis. However, if a program exits with an assertion failure, the core dump is not useful since the assertion message is only printed to stderr. glibc recently got a patch which stores the message of assert() into the __abort_msg global variable. (http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=48dcd0ba) That works fine for programs which actually use the standard C assert() macro. This patch adds the same functionality for glib's assertion tests. If we are building against a glibc which already has __abort_msg (2.11 and later, or backported above git commit), use that, otherwise put it into our own field __glib_assert_msg. Usage: $ cat test.c #include <glib.h> int main() { g_assert(1 < 0); return 0; } $ ./test **ERROR:test.c:5:main: assertion failed: (1 < 0) Aborted (Core dumped) $ gdb --batch --ex 'print (char*) __abort_msg' ./test core [...] $1 = 0x93bf028 "ERROR:test.c:5:main: assertion failed: (1 < 0)" https://bugzilla.gnome.org/show_bug.cgi?id=594872
2009-12-22 11:09:20 +01:00
#
include
<glib.h>
Use (void) for no parameters, not () This ensures we build with -Werror=missing-parameter-type. https://bugzilla.gnome.org/show_bug.cgi?id=687385
2012-11-02 00:36:52 +01:00
int
main
(
int
argc
,
char
*
*
argv
)
Support storing assertion messages into core dump Crash interception/debugging systems like Apport or ABRT capture core dumps for later crash analysis. However, if a program exits with an assertion failure, the core dump is not useful since the assertion message is only printed to stderr. glibc recently got a patch which stores the message of assert() into the __abort_msg global variable. (http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=48dcd0ba) That works fine for programs which actually use the standard C assert() macro. This patch adds the same functionality for glib's assertion tests. If we are building against a glibc which already has __abort_msg (2.11 and later, or backported above git commit), use that, otherwise put it into our own field __glib_assert_msg. Usage: $ cat test.c #include <glib.h> int main() { g_assert(1 < 0); return 0; } $ ./test **ERROR:test.c:5:main: assertion failed: (1 < 0) Aborted (Core dumped) $ gdb --batch --ex 'print (char*) __abort_msg' ./test core [...] $1 = 0x93bf028 "ERROR:test.c:5:main: assertion failed: (1 < 0)" https://bugzilla.gnome.org/show_bug.cgi?id=594872
2009-12-22 11:09:20 +01:00
{
g_assert
(
42
<
0
)
;
return
0
;
}
Reference in New Issue
Copy Permalink