From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753699AbdHPCWm (ORCPT ); Tue, 15 Aug 2017 22:22:42 -0400 Received: from mga01.intel.com ([192.55.52.88]:49608 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753604AbdHPCWN (ORCPT ); Tue, 15 Aug 2017 22:22:13 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,380,1498546800"; d="scan'208";a="119442561" From: Jin Yao To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com, Jin Yao Subject: [PATCH v1 4/4] perf annotate: Display multiple events for gtk mode Date: Wed, 16 Aug 2017 18:18:36 +0800 Message-Id: <1502878716-30817-5-git-send-email-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502878716-30817-1-git-send-email-yao.jin@linux.intel.com> References: <1502878716-30817-1-git-send-email-yao.jin@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For example: perf record -e cycles,branches ./div perf annotate main --gtk Both the cycles and branches are displayed at the left column in gtk window. Signed-off-by: Jin Yao --- tools/perf/ui/gtk/annotate.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c index 0217619..f314654 100644 --- a/tools/perf/ui/gtk/annotate.c +++ b/tools/perf/ui/gtk/annotate.c @@ -88,7 +88,8 @@ static int perf_gtk__get_line(char *buf, size_t size, struct disasm_line *dl) static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym, struct map *map, struct perf_evsel *evsel, - struct hist_browser_timer *hbt __maybe_unused) + struct hist_browser_timer *hbt __maybe_unused, + struct hist_entry *he) { struct disasm_line *pos, *n; struct annotation *notes; @@ -98,6 +99,7 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym, GtkWidget *view; int i; char s[512]; + struct hist_event *hevt; notes = symbol__annotation(sym); @@ -124,17 +126,18 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym, gtk_list_store_append(store, &iter); - if (perf_evsel__is_group_event(evsel)) { - for (i = 0; i < evsel->nr_members; i++) { + if (evsel) { + ret = perf_gtk__get_percent(s, sizeof(s), sym, pos, + evsel->idx); + } else if (he) { + for (i = 0; i < he->event_nr; i++) { + hevt = &he->events[i]; ret += perf_gtk__get_percent(s + ret, sizeof(s) - ret, - sym, pos, - evsel->idx + i); + hevt->ms.sym, pos, + hevt->idx); ret += scnprintf(s + ret, sizeof(s) - ret, " "); } - } else { - ret = perf_gtk__get_percent(s, sizeof(s), sym, pos, - evsel->idx); } if (ret) @@ -157,19 +160,25 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym, static int symbol__gtk_annotate(struct symbol *sym, struct map *map, struct perf_evsel *evsel, - struct hist_browser_timer *hbt) + struct hist_browser_timer *hbt, + struct hist_entry *he) { GtkWidget *window; GtkWidget *notebook; GtkWidget *scrolled_window; GtkWidget *tab_label; int err; + char *arch; + + if (!evsel) + arch = perf_evsel__env_arch(he->events[0].evsel); + else + arch = perf_evsel__env_arch(evsel); if (map->dso->annotate_warned) return -1; - err = symbol__disassemble(sym, map, perf_evsel__env_arch(evsel), - 0, NULL, NULL); + err = symbol__disassemble(sym, map, arch, 0, NULL, NULL); if (err) { char msg[BUFSIZ]; symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg)); @@ -228,7 +237,7 @@ static int symbol__gtk_annotate(struct symbol *sym, struct map *map, gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled_window, tab_label); - perf_gtk__annotate_symbol(scrolled_window, sym, map, evsel, hbt); + perf_gtk__annotate_symbol(scrolled_window, sym, map, evsel, hbt, he); return 0; } @@ -236,7 +245,7 @@ int hist_entry__gtk_annotate(struct hist_entry *he, struct perf_evsel *evsel, struct hist_browser_timer *hbt) { - return symbol__gtk_annotate(he->ms.sym, he->ms.map, evsel, hbt); + return symbol__gtk_annotate(he->ms.sym, he->ms.map, evsel, hbt, he); } void perf_gtk__show_annotations(void) -- 2.7.4