]> Savannah Git Hosting - gnulib.git/commitdiff
abort-debug: Integrate with CONTINUE_AFTER_ASSERT.
authorBruno Haible <bruno@clisp.org>
Sat, 18 May 2024 20:53:28 +0000 (22:53 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 18 May 2024 21:34:23 +0000 (23:34 +0200)
* lib/stdlib.in.h (_gl_pre_abort): New declaration.
* lib/abort-debug.c (_gl_pre_abort): New function.
* tests/macros.h (ASSERT, ASSERT_NO_STDIO): If CONTINUE_AFTER_ASSERT
is 1 and the assertion fails, invoke _gl_pre_abort.

ChangeLog
lib/abort-debug.c
lib/stdlib.in.h
tests/macros.h

index c119e32014b162692e8253acf5c261d468d244a2..7de9b90f6d67f40f37abd01efa645ca81a6ed1aa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-05-18  Bruno Haible  <bruno@clisp.org>
+
+       abort-debug: Integrate with CONTINUE_AFTER_ASSERT.
+       * lib/stdlib.in.h (_gl_pre_abort): New declaration.
+       * lib/abort-debug.c (_gl_pre_abort): New function.
+       * tests/macros.h (ASSERT, ASSERT_NO_STDIO): If CONTINUE_AFTER_ASSERT
+       is 1 and the assertion fails, invoke _gl_pre_abort.
+
 2024-05-18  Bruno Haible  <bruno@clisp.org>
 
        tests: Support showing all assertion failures, not just the first one.
index 2ca8f81169a15d9b53f2e84a786e2f313e2d1bd1..ca4dbc7291c60933de7dee5a81c396ab999d4f31 100644 (file)
@@ -55,6 +55,19 @@ print_stack_trace (FILE *stream)
 
 #endif
 
+void
+_gl_pre_abort (void)
+{
+#if HAVE_EXECINFO_H
+  print_stack_trace (stderr);
+#endif
+}
+
+/*   rpl_abort ();
+   is equivalent to
+     _gl_pre_abort ();
+     original abort (); // i.e. raise (SIGABRT);
+ */
 void
 rpl_abort (void)
 {
index 1888d3ee314e7b79c86348c5431d09998e8efe06..ef9fde30eb2c1db472ec2228f75933b45d3fe2a9 100644 (file)
@@ -231,6 +231,14 @@ _GL_CXXALIAS_SYS (abort, void, (void));
 _GL_CXXALIASWARN (abort);
 # endif
 #endif
+#if @GNULIB_ABORT_DEBUG@ && @REPLACE_ABORT@
+_GL_EXTERN_C void _gl_pre_abort (void);
+#else
+# if !GNULIB_defined_gl_pre_abort
+#  define _gl_pre_abort() /* nothing */
+#  define GNULIB_defined_gl_pre_abort 1
+# endif
+#endif
 
 
 #if @GNULIB_FREE_POSIX@
index d60de6fd3e6cf9993bd0015d68398a192b4028f3..144905e031d3001ab11b2a2ff606d5b27fa0df75 100644 (file)
@@ -81,7 +81,10 @@ int volatile test_exit_status = EXIT_SUCCESS;
                    __FILE__, __LINE__, #expr);                               \
           fflush (ASSERT_STREAM);                                            \
           if (CONTINUE_AFTER_ASSERT)                                         \
-            test_exit_status = EXIT_FAILURE;                                 \
+            {                                                                \
+              _gl_pre_abort ();                                              \
+              test_exit_status = EXIT_FAILURE;                               \
+            }                                                                \
           else                                                               \
             abort ();                                                        \
         }                                                                    \
@@ -102,7 +105,10 @@ int volatile test_exit_status = EXIT_SUCCESS;
           WRITE_TO_STDERR (#expr);                          \
           WRITE_TO_STDERR ("' failed\n");                   \
           if (CONTINUE_AFTER_ASSERT)                        \
-            test_exit_status = EXIT_FAILURE;                \
+            {                                               \
+              _gl_pre_abort ();                             \
+              test_exit_status = EXIT_FAILURE;              \
+            }                                               \
           else                                              \
             abort ();                                       \
         }                                                   \