From: Bruno Haible Date: Thu, 18 Jul 2024 01:07:30 +0000 (+0200) Subject: abort-debug: Export the print_stack_trace function. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=5e2115332873c8b802afa5d67a3bff1b5fbba2cd;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index b80ca078d5..7b39f40541 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2024-07-17 Bruno Haible + + 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 doc: List library dependencies. diff --git a/lib/abort-debug.c b/lib/abort-debug.c index 8252b66def..641fceee2d 100644 --- a/lib/abort-debug.c +++ b/lib/abort-debug.c @@ -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); } diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index e42368eef2..82e8dcd258 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -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 diff --git a/tests/macros.h b/tests/macros.h index 144905e031..3121b21820 100644 --- a/tests/macros.h +++ b/tests/macros.h @@ -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 \