From patchwork Fri Feb 8 09:41:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 1038536 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-495488-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="A5Pb/nuR"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43wqvH2DXLz9sN6 for ; Fri, 8 Feb 2019 20:41:27 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=DMCBv+nwBliPFNAm6VWN0KpZu16wYENUbCrRqsh0j9fQwtQPW+ CtkGtDdL7DtKh9covSYGsF6wBpn2AM63N5xw2j1h1X54ayUpXxCeT5VPsYNdxVFy jiwAZ4m9t0ga95zmMkkFbEZxDBIFmcVlOOQ12Z20iqTcl2uFHrKZWHzo8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=c45JHvDnkll+eY0WSj5KjXF8WJQ=; b=A5Pb/nuRrEN+ZgIAkxkb cRH6pxkq3xd8AlDZNq113hiPi0voCpygWcDBrYNpFK9vT2ZusIFIiphtfAPM2S/3 z+37VvZka0kHAKGA4hx+tY0TRQy/PUVoLiJpOghfhSvGaFt1Id5WSE/e7yFYb44e 7/LyP+ivIxhVImKyX5EAMcs= Received: (qmail 7636 invoked by alias); 8 Feb 2019 09:41:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 7375 invoked by uid 89); 8 Feb 2019 09:41:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Feb 2019 09:41:18 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8354EAE06; Fri, 8 Feb 2019 09:41:16 +0000 (UTC) Date: Fri, 8 Feb 2019 10:41:47 +0100 From: Tom de Vries To: gcc-patches@gcc.gnu.org Cc: Ian Lance Taylor Subject: [PATCH][libbacktrace] Declare external backtrace fns noinline Message-ID: <20190208094145.GA31267@delia.microfocus.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes Hi, 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)). OK for trunk? Thanks, - Tom [libbacktrace] Declare external backtrace fns 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. --- libbacktrace/backtrace.c | 2 +- libbacktrace/print.c | 2 +- libbacktrace/simple.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libbacktrace/backtrace.c b/libbacktrace/backtrace.c index 29204c63313..c579e803825 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 b2f45446443..0767facecae 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 d439fcee8e2..118936397da 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)