From patchwork Tue Sep 24 17:43:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 2934831 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EB48D9F288 for ; Tue, 24 Sep 2013 17:44:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AEA1B20374 for ; Tue, 24 Sep 2013 17:44:11 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 51FC820336 for ; Tue, 24 Sep 2013 17:44:10 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VOWed-0001Ry-Dz; Tue, 24 Sep 2013 17:44:07 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VOWeb-0007eN-0X; Tue, 24 Sep 2013 17:44:05 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VOWeW-0007ao-0P for linux-arm-kernel@lists.infradead.org; Tue, 24 Sep 2013 17:44:02 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8OHhLCW020645 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 24 Sep 2013 13:43:22 -0400 Received: from krava.brq.redhat.com (dhcp-1-243.brq.redhat.com [10.34.1.243]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id r8OHhIeg007297; Tue, 24 Sep 2013 13:43:19 -0400 Date: Tue, 24 Sep 2013 19:43:18 +0200 From: Jiri Olsa To: Jean Pihet Subject: Re: [PATCH 3/4] perf tools: Check libunwind for availability of dwarf parsing feature Message-ID: <20130924174318.GE3080@krava.brq.redhat.com> References: <1379323053-11458-1-git-send-email-jean.pihet@linaro.org> <1379323053-11458-4-git-send-email-jean.pihet@linaro.org> <20130917102904.GA27258@mudshark.cambridge.arm.com> <20130924093450.GB1008@krava.brq.redhat.com> <20130924100620.GG15119@mudshark.cambridge.arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130924_134400_191852_124577EA X-CRM114-Status: GOOD ( 28.61 ) X-Spam-Score: -9.2 (---------) Cc: "linaro-kernel@lists.linaro.org" , "patches@linaro.org" , Will Deacon , "linux-kernel@vger.kernel.org" , Arnaldo Carvalho de Melo , Ingo Molnar , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Sep 24, 2013 at 02:03:47PM +0200, Jean Pihet wrote: > Hi Jiri, Will, > > On 24 September 2013 12:06, Will Deacon wrote: > > On Tue, Sep 24, 2013 at 10:34:50AM +0100, Jiri Olsa wrote: > >> On Tue, Sep 24, 2013 at 10:55:32AM +0200, Jean Pihet wrote: > >> > Ping on the series. The two patches above (3/4 and 4/4) are generic > >> > while the two others are impacting ARM only. > >> > Is it possible to get an Ack for the generic ones? > >> > >> I'm fine with those changes.. still I'm sort of worried about > >> current DWARF unwind users (but not sure if there're any), > >> who depends on packaged libunwind compiled without > >> --enable-debug-frame option. > > > > Since x86 is the only architecture using libunwind with perf at the moment, > > and I'd expect it to use .eh_frame for unwinding, I'm also not sure there > > are any existing users to worry about. > Right > > > > >> I've seen your libunwind patch to make it default, but > >> not sure if it was accepted.. if not, maybe we should > >> detect this and build that code conditionaly. > > > > It certainly defaults to "on" for ARM, but other architectures have to > > enable it explicitly afaict. > Yes that is correct. > This patch (3/4) detects if the debug frame code is enabled in > libunwind and uses the lib only if it is the case. My concern is about users (again, not sure if there are any ;-) ) that use this with packaged libunwind compiled without --enable-debug-frame option. For them perf will consider libunwind as 'not available' with your changes: ... CHK libunwind config/Makefile:223: No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 1.1 ... and they'll need to compile their own libunwind (thats the case on Fedora). This could be solved by detecting this and make your code conditional as attached below (not much tested). thanks, jirka diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 134b36e..d40cf0a 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -223,6 +223,10 @@ ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y) msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 1.1); NO_LIBUNWIND := 1 endif # Libunwind support +ifneq ($(call try-cc,$(SOURCE_LIBUNWIND_DEBUG_FRAME),$(FLAGS_UNWIND),libunwind debug_frame),y) + msg := $(warning No debug_frame support found in libunwind); +CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME +endif endif # NO_LIBUNWIND ifndef NO_LIBUNWIND diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak index 87124d0..645141c 100644 --- a/tools/perf/config/feature-tests.mak +++ b/tools/perf/config/feature-tests.mak @@ -178,6 +178,28 @@ extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as, #define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table) +int main(void) +{ + unw_addr_space_t addr_space; + addr_space = unw_create_addr_space(NULL, 0); + unw_init_remote(NULL, addr_space, NULL); + dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL); + return 0; +} +endef + +define SOURCE_LIBUNWIND_DEBUG_FRAME +#include +#include + +extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as, + unw_word_t ip, + unw_dyn_info_t *di, + unw_proc_info_t *pi, + int need_unwind_info, void *arg); + +#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table) + extern int UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug, unw_word_t ip, @@ -189,11 +211,7 @@ UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug, int main(void) { - unw_addr_space_t addr_space; - addr_space = unw_create_addr_space(NULL, 0); - unw_init_remote(NULL, addr_space, NULL); dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0); - dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL); return 0; } endef diff --git a/tools/perf/util/unwind.c b/tools/perf/util/unwind.c index 429a99c..231c941 100644 --- a/tools/perf/util/unwind.c +++ b/tools/perf/util/unwind.c @@ -277,6 +277,7 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine, return ret; } +#ifndef NO_LIBUNWIND_DEBUG_FRAME static int read_unwind_spec_debug_frame(struct dso *dso, struct machine *machine, u64 *offset) { @@ -294,6 +295,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso, return -EINVAL; } +#endif static struct map *find_map(unw_word_t ip, struct unwind_info *ui) { @@ -334,6 +336,7 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, need_unwind_info, arg); } +#ifndef NO_LIBUNWIND_DEBUG_FRAME /* Check the .debug_frame section for unwinding info */ if (!read_unwind_spec_debug_frame(map->dso, ui->machine, &segbase)) { memset(&di, 0, sizeof(di)); @@ -342,7 +345,7 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, return dwarf_search_unwind_table(as, ip, &di, pi, need_unwind_info, arg); } - +#endif return -EINVAL; }