From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932184AbbE1Rts (ORCPT ); Thu, 28 May 2015 13:49:48 -0400 Received: from mga11.intel.com ([192.55.52.93]:31331 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753895AbbE1Rt3 (ORCPT ); Thu, 28 May 2015 13:49:29 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,513,1427785200"; d="scan'208";a="733254913" From: Andi Kleen To: sukadev@linux.vnet.ibm.com Cc: jolsa@redhat.com, mingo@kernel.org, acme@kernel.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: [PATCH 1/2] perf, tools: Group alias perf list by section Date: Thu, 28 May 2015 10:49:20 -0700 Message-Id: <1432835361-16964-2-git-send-email-andi@firstfloor.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1432835361-16964-1-git-send-email-andi@firstfloor.org> References: <1432835361-16964-1-git-send-email-andi@firstfloor.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 578a537..ba50300 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -982,6 +982,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; @@ -1029,6 +1031,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) { @@ -1036,8 +1040,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); -- 2.1.0