From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757721Ab2I1Jlh (ORCPT ); Fri, 28 Sep 2012 05:41:37 -0400 Received: from LGEMRELSE7Q.lge.com ([156.147.1.151]:60959 "EHLO LGEMRELSE7Q.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757510Ab2I1JkX (ORCPT ); Fri, 28 Sep 2012 05:40:23 -0400 X-AuditID: 9c930197-b7b6dae000000e70-75-50657083a6b1 From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra , Paul Mackerras , Ingo Molnar , LKML , Namhyung Kim , Markus Trippelsdorf , Mike Frysinger Subject: [PATCH 10/12] perf tools: Convert to DEMANGLE_SUPPORT Date: Fri, 28 Sep 2012 18:32:06 +0900 Message-Id: <1348824728-14025-11-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1348824728-14025-1-git-send-email-namhyung@kernel.org> References: <1348824728-14025-1-git-send-email-namhyung@kernel.org> X-Brightmail-Tracker: AAAAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Namhyung Kim For building perf without name demangling, we can set NO_DEMANGLE=1 as a argument of make. It then defines NO_DEMANGLE macro for C code to do the proper handling. However it usually used in a negative semantics - e.g. #ifndef - so we saw double negations which can be misleading. Convert it to a positive form to make it more readable. Also add _SUPPORT suffix for consistency and make PACKAGE variable has a string value "perf". Cc: Markus Trippelsdorf Cc: Mike Frysinger Signed-off-by: Namhyung Kim --- tools/perf/Makefile | 12 +++++++----- tools/perf/util/symbol.h | 19 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 45f8920bab2b..dd5b9a0507c7 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -696,36 +696,38 @@ else endif endif -ifdef NO_DEMANGLE - BASIC_CFLAGS += -DNO_DEMANGLE -else +ifndef NO_DEMANGLE ifdef HAVE_CPLUS_DEMANGLE EXTLIBS += -liberty + BASIC_CFLAGS += -DDEMANGLE_SUPPORT BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE else - FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd + FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -DPACKAGE='"perf"' -lbfd has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD)) ifeq ($(has_bfd),y) EXTLIBS += -lbfd + BASIC_CFLAGS += -DDEMANGLE_SUPPORT else FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY)) ifeq ($(has_bfd_iberty),y) EXTLIBS += -lbfd -liberty + BASIC_CFLAGS += -DDEMANGLE_SUPPORT else FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z)) ifeq ($(has_bfd_iberty_z),y) EXTLIBS += -lbfd -liberty -lz + BASIC_CFLAGS += -DDEMANGLE_SUPPORT else FLAGS_CPLUS_DEMANGLE=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE)) ifeq ($(has_cplus_demangle),y) EXTLIBS += -liberty + BASIC_CFLAGS += -DDEMANGLE_SUPPORT BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE else msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) - BASIC_CFLAGS += -DNO_DEMANGLE endif endif endif diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 8b6ef7fac745..e1484bb080e6 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -18,26 +18,29 @@ #include #endif -#ifdef HAVE_CPLUS_DEMANGLE +#ifdef DEMANGLE_SUPPORT + +# ifdef HAVE_CPLUS_DEMANGLE extern char *cplus_demangle(const char *, int); static inline char *bfd_demangle(void __maybe_unused *v, const char *c, int i) { return cplus_demangle(c, i); } -#else -#ifdef NO_DEMANGLE +# else /* HAVE_CPLUS_DEMANGLE */ +# define PACKAGE "perf" +# include +# endif /* HAVE_CPLUS_DEMANGLE */ + +#else /* DEMANGLE_SUPPORT */ + static inline char *bfd_demangle(void __maybe_unused *v, const char __maybe_unused *c, int __maybe_unused i) { return NULL; } -#else -#define PACKAGE 'perf' -#include -#endif -#endif +#endif /* DEMANGLE_SUPPORT */ int hex2u64(const char *ptr, u64 *val); char *strxfrchar(char *s, char from, char to); -- 1.7.11.4