1
0
mirror of https://https.git.savannah.gnu.org/git/gnulib.git synced 2026-05-13 15:13:36 +00:00

abort-debug: Export the print_stack_trace function.

* lib/stdlib.in.h (print_stack_trace): Renamed from _gl_pre_abort.
* lib/abort-debug.c (print_stack_trace_to): Renamed from
print_stack_trace.
(print_stack_trace): Renamed from _gl_pre_abort.
(rpl_abort): Update.
* tests/macros.h (ASSERT, ASSERT_NO_STDIO): Update.
This commit is contained in:
Bruno Haible
2024-07-18 03:07:30 +02:00
parent e29a548fd7
commit 5e21153328
4 changed files with 22 additions and 12 deletions

View File

@@ -1,3 +1,13 @@
2024-07-17 Bruno Haible <bruno@clisp.org>
abort-debug: Export the print_stack_trace function.
* lib/stdlib.in.h (print_stack_trace): Renamed from _gl_pre_abort.
* lib/abort-debug.c (print_stack_trace_to): Renamed from
print_stack_trace.
(print_stack_trace): Renamed from _gl_pre_abort.
(rpl_abort): Update.
* tests/macros.h (ASSERT, ASSERT_NO_STDIO): Update.
2024-07-17 Bruno Haible <bruno@clisp.org>
doc: List library dependencies.

View File

@@ -31,7 +31,7 @@ static inline void
# if (__GNUC__ >= 3) || (__clang_major__ >= 4)
__attribute__ ((always_inline))
# endif
print_stack_trace (FILE *stream)
print_stack_trace_to (FILE *stream)
{
if (state == NULL)
state = backtrace_create_state (NULL, 0, NULL, NULL);
@@ -50,7 +50,7 @@ static inline void
# if (__GNUC__ >= 3) || (__clang_major__ >= 4)
__attribute__ ((always_inline))
# endif
print_stack_trace (FILE *stream)
print_stack_trace_to (FILE *stream)
{
void *buffer[100];
int max_size = sizeof (buffer) / sizeof (buffer[0]);
@@ -75,23 +75,23 @@ print_stack_trace (FILE *stream)
#endif
void
_gl_pre_abort (void)
print_stack_trace (void)
{
#if HAVE_LIBBACKTRACE || HAVE_EXECINFO_H
print_stack_trace (stderr);
print_stack_trace_to (stderr);
#endif
}
/* rpl_abort ();
is equivalent to
_gl_pre_abort ();
print_stack_trace ();
original abort (); // i.e. raise (SIGABRT);
*/
void
rpl_abort (void)
{
#if HAVE_LIBBACKTRACE || HAVE_EXECINFO_H
print_stack_trace (stderr);
print_stack_trace_to (stderr);
#endif
raise (SIGABRT);
}

View File

@@ -256,11 +256,11 @@ _GL_CXXALIASWARN (abort);
# endif
#endif
#if @GNULIB_ABORT_DEBUG@ && @REPLACE_ABORT@
_GL_EXTERN_C void _gl_pre_abort (void);
_GL_EXTERN_C void print_stack_trace (void);
#else
# if !GNULIB_defined_gl_pre_abort
# define _gl_pre_abort() /* nothing */
# define GNULIB_defined_gl_pre_abort 1
# if !GNULIB_defined_print_stack_trace
# define print_stack_trace() /* nothing */
# define GNULIB_defined_print_stack_trace 1
# endif
#endif

View File

@@ -82,7 +82,7 @@ int volatile test_exit_status = EXIT_SUCCESS;
fflush (ASSERT_STREAM); \
if (CONTINUE_AFTER_ASSERT) \
{ \
_gl_pre_abort (); \
print_stack_trace (); \
test_exit_status = EXIT_FAILURE; \
} \
else \
@@ -106,7 +106,7 @@ int volatile test_exit_status = EXIT_SUCCESS;
WRITE_TO_STDERR ("' failed\n"); \
if (CONTINUE_AFTER_ASSERT) \
{ \
_gl_pre_abort (); \
print_stack_trace (); \
test_exit_status = EXIT_FAILURE; \
} \
else \