From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id EC9943857C4C for ; Tue, 28 Sep 2021 19:51:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EC9943857C4C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 18SJoNIQ020670; Tue, 28 Sep 2021 14:50:28 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 18SJoHxF020658; Tue, 28 Sep 2021 14:50:17 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Tue, 28 Sep 2021 14:50:12 -0500 From: Segher Boessenkool To: Raphael Moreira Zinsly Cc: gcc-patches@gcc.gnu.org, dje.gcc@gmail.com, amodra@gmail.com, wschmidt@linux.ibm.com, tuliom@linux.ibm.com Subject: Re: [PATCH v2] libgcc: Add a backchain fallback to _Unwind_Backtrace() on PowerPC Message-ID: <20210928195012.GD22689@gate.crashing.org> References: <20210826145324.19505-1-rzinsly@linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210826145324.19505-1-rzinsly@linux.ibm.com> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Sep 2021 19:51:30 -0000 Hi! On Thu, Aug 26, 2021 at 11:53:24AM -0300, Raphael Moreira Zinsly wrote: > Without dwarf2 unwind tables available _Unwind_Backtrace() is not > able to return the full backtrace. > This patch adds a fallback function on powerpc to get the backtrace > by doing a backchain, this code was originally at glibc. Okay, the backchain as fallback if other (better!) methods cannot work. > * config/rs6000/linux-unwind.h (struct rt_sigframe): Move it to > outside of get_regs() in order to use it in another function, > this is done twice: for __powerpc64__ and for !__powerpc64__. > (struct trace_arg): New struct. > (struct layout): New struct. > (ppc_backchain_fallback): New function. > * unwind.inc (_Unwind_Backtrace): Look for _URC_NORMAL_STOP > code state and call MD_BACKCHAIN_FALLBACK. Changelog lines wrap at 80 chars, not 70 or so. The emails from commits (to bugzilla) are a bit malformed (it counts the number of columns for leading tabs wrong it seems), but the actual commits are just fine. > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/unwind-backchain.c > @@ -0,0 +1,22 @@ > +/* { dg-do run { target { powerpc*-*-linux* } } } */ Don't say such targets in gcc.target/powerpc/ tests please. Everything in gcc.target is for powerpc*-*-* already, so if you really want to limit to powerpc*-*-linux* just write *-*-linux*. But there are better ways to get what you want, like, testing for the actual feature you want (which is if backtrace() works?) But such an improvement can be done later (and needs more testing etc). But please write some simple comment saying why you need -linux* in the test. > +void > +test_backtrace() > +{ > + int addresses; > + void *buffer[10]; > + > + addresses = backtrace(buffer, 10); > + if(addresses != 4) > + __builtin_abort(); > +} Does that work?! Has this been tested on all powerpc*-linux configs? Importantly also BE and 32-bit. Okay for trunk with the testcase fix, if all testing works out. Thanks! Segher