• Martin Pitt's avatar
    Support storing assertion messages into core dump · da668979
    Martin Pitt authored
    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
    glibc recently got a patch which stores the message of assert() into the
    __abort_msg global variable.
    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
      $ 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)"
assert-msg-test.c 71 Bytes