From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e39.co.us.ibm.com (e39.co.us.ibm.com [32.97.110.160]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4D81C1A0D2A for ; Wed, 3 Jun 2015 03:13:06 +1000 (AEST) Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 2 Jun 2015 11:13:04 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id A518719D803E for ; Tue, 2 Jun 2015 11:04:02 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t52HCTG942729524 for ; Tue, 2 Jun 2015 10:12:29 -0700 Received: from d03av03.boulder.ibm.com (localhost [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t52HCwvq026208 for ; Tue, 2 Jun 2015 11:13:00 -0600 From: Sukadev Bhattiprolu To: mingo@redhat.com, ak@linux.intel.com, Michael Ellerman , Jiri Olsa , Arnaldo Carvalho de Melo Cc: namhyung@kernel.org, linuxppc-dev@lists.ozlabs.org, Subject: [PATCH v13 09/14] perf, tools: Group alias perf list by section Date: Tue, 2 Jun 2015 10:12:09 -0700 Message-Id: <1433265135-20426-10-git-send-email-sukadev@linux.vnet.ibm.com> In-Reply-To: <1433265135-20426-1-git-send-email-sukadev@linux.vnet.ibm.com> References: <1433265135-20426-1-git-send-email-sukadev@linux.vnet.ibm.com> List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Andi Kleen The first first element in an hardware event name defines the general area, usually the part of the micro architecture it is refering to. Group the perf list output by these sections by adding section headers. Signed-off-by: Andi Kleen Signed-off-by: Sukadev Bhattiprolu --- tools/perf/util/pmu.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 417333b..8d91fa7 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1039,6 +1039,8 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag) struct pair *aliases; int numdesc = 0; int columns = pager_get_columns(); + const char *last_section; + int last_section_len; pmu = NULL; len = 0; @@ -1086,6 +1088,8 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag) } } len = j; + last_section = NULL; + last_section_len = 0; qsort(aliases, len, sizeof(struct pair), cmp_pair); for (j = 0; j < len; j++) { if (name_only) { @@ -1093,8 +1097,21 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag) continue; } if (aliases[j].desc && !quiet_flag) { + char *dot; + char *name = aliases[j].name; + if (numdesc++ == 0) printf("\n"); + dot = strchr(name, '.'); + if (dot && + (!last_section || + strncmp(last_section, name, last_section_len))) { + last_section_len = dot - name; + printf("%s%.*s:\n", + last_section ? "\n" : "", + last_section_len, name); + last_section = name; + } printf(" %-50s\n", aliases[j].name); printf("%*s", 8, "["); wordwrap(aliases[j].desc, 8, columns, 0); -- 1.7.9.5