From: vries Date: Fri, 8 Feb 2019 09:49:06 +0000 (+0000) Subject: [libbacktrace] Declare external backtrace fns noinline X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=216ad75036c1f972aee252ae0a22c4004c75e76d;p=thirdparty%2Fgcc.git [libbacktrace] Declare external backtrace fns noinline The backtrace functions backtrace_full, backtrace_print and backtrace_simple walk the call stack, but make sure to skip the first entry, in order to skip over the functions themselves, and start the backtrace at the caller of the functions. When compiling with -flto, the functions may be inlined, causing them to skip over the caller instead. Fix this by declaring the functions with __attribute__((noinline)). 2019-02-08 Tom de Vries * backtrace.c (backtrace_full): Declare with __attribute__((noinline)). * print.c (backtrace_print): Same. * simple.c (backtrace_simple): Same. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268668 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog index 06fa109a675f..e1f20074f22b 100644 --- a/libbacktrace/ChangeLog +++ b/libbacktrace/ChangeLog @@ -1,3 +1,9 @@ +2019-02-08 Tom de Vries + + * backtrace.c (backtrace_full): Declare with __attribute__((noinline)). + * print.c (backtrace_print): Same. + * simple.c (backtrace_simple): Same. + 2019-02-08 Tom de Vries PR libbacktrace/78063 diff --git a/libbacktrace/backtrace.c b/libbacktrace/backtrace.c index 29204c633137..c579e8038252 100644 --- a/libbacktrace/backtrace.c +++ b/libbacktrace/backtrace.c @@ -98,7 +98,7 @@ unwind (struct _Unwind_Context *context, void *vdata) /* Get a stack backtrace. */ -int +int __attribute__((noinline)) backtrace_full (struct backtrace_state *state, int skip, backtrace_full_callback callback, backtrace_error_callback error_callback, void *data) diff --git a/libbacktrace/print.c b/libbacktrace/print.c index b2f454464435..0767facecaec 100644 --- a/libbacktrace/print.c +++ b/libbacktrace/print.c @@ -80,7 +80,7 @@ error_callback (void *data, const char *msg, int errnum) /* Print a backtrace. */ -void +void __attribute__((noinline)) backtrace_print (struct backtrace_state *state, int skip, FILE *f) { struct print_data data; diff --git a/libbacktrace/simple.c b/libbacktrace/simple.c index d439fcee8e29..118936397da2 100644 --- a/libbacktrace/simple.c +++ b/libbacktrace/simple.c @@ -90,7 +90,7 @@ simple_unwind (struct _Unwind_Context *context, void *vdata) /* Get a simple stack backtrace. */ -int +int __attribute__((noinline)) backtrace_simple (struct backtrace_state *state, int skip, backtrace_simple_callback callback, backtrace_error_callback error_callback, void *data)