Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db8fd07a authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo
Browse files

perf annotate: Pass evsel instead of evidx on annotation functions



Pass evsel instead of evidx.  This is a preparation for supporting event
group view in annotation and no functional change is intended.

Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1362462812-30885-2-git-send-email-namhyung@kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent acf28922
Loading
Loading
Loading
Loading
+9 −7
Original line number Original line Diff line number Diff line
@@ -109,14 +109,16 @@ static int process_sample_event(struct perf_tool *tool,
	return 0;
	return 0;
}
}


static int hist_entry__tty_annotate(struct hist_entry *he, int evidx,
static int hist_entry__tty_annotate(struct hist_entry *he,
				    struct perf_evsel *evsel,
				    struct perf_annotate *ann)
				    struct perf_annotate *ann)
{
{
	return symbol__tty_annotate(he->ms.sym, he->ms.map, evidx,
	return symbol__tty_annotate(he->ms.sym, he->ms.map, evsel,
				    ann->print_line, ann->full_paths, 0, 0);
				    ann->print_line, ann->full_paths, 0, 0);
}
}


static void hists__find_annotations(struct hists *self, int evidx,
static void hists__find_annotations(struct hists *self,
				    struct perf_evsel *evsel,
				    struct perf_annotate *ann)
				    struct perf_annotate *ann)
{
{
	struct rb_node *nd = rb_first(&self->entries), *next;
	struct rb_node *nd = rb_first(&self->entries), *next;
@@ -142,14 +144,14 @@ static void hists__find_annotations(struct hists *self, int evidx,
		if (use_browser == 2) {
		if (use_browser == 2) {
			int ret;
			int ret;


			ret = hist_entry__gtk_annotate(he, evidx, NULL);
			ret = hist_entry__gtk_annotate(he, evsel, NULL);
			if (!ret || !ann->skip_missing)
			if (!ret || !ann->skip_missing)
				return;
				return;


			/* skip missing symbols */
			/* skip missing symbols */
			nd = rb_next(nd);
			nd = rb_next(nd);
		} else if (use_browser == 1) {
		} else if (use_browser == 1) {
			key = hist_entry__tui_annotate(he, evidx, NULL);
			key = hist_entry__tui_annotate(he, evsel, NULL);
			switch (key) {
			switch (key) {
			case -1:
			case -1:
				if (!ann->skip_missing)
				if (!ann->skip_missing)
@@ -168,7 +170,7 @@ static void hists__find_annotations(struct hists *self, int evidx,
			if (next != NULL)
			if (next != NULL)
				nd = next;
				nd = next;
		} else {
		} else {
			hist_entry__tty_annotate(he, evidx, ann);
			hist_entry__tty_annotate(he, evsel, ann);
			nd = rb_next(nd);
			nd = rb_next(nd);
			/*
			/*
			 * Since we have a hist_entry per IP for the same
			 * Since we have a hist_entry per IP for the same
@@ -230,7 +232,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
			total_nr_samples += nr_samples;
			total_nr_samples += nr_samples;
			hists__collapse_resort(hists);
			hists__collapse_resort(hists);
			hists__output_resort(hists);
			hists__output_resort(hists);
			hists__find_annotations(hists, pos->idx, ann);
			hists__find_annotations(hists, pos, ann);
		}
		}
	}
	}


+1 −1
Original line number Original line Diff line number Diff line
@@ -231,7 +231,7 @@ static void perf_top__show_details(struct perf_top *top)
	printf("Showing %s for %s\n", perf_evsel__name(top->sym_evsel), symbol->name);
	printf("Showing %s for %s\n", perf_evsel__name(top->sym_evsel), symbol->name);
	printf("  Events  Pcnt (>=%d%%)\n", top->sym_pcnt_filter);
	printf("  Events  Pcnt (>=%d%%)\n", top->sym_pcnt_filter);


	more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel->idx,
	more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel,
				       0, top->sym_pcnt_filter, top->print_entries, 4);
				       0, top->sym_pcnt_filter, top->print_entries, 4);
	if (top->zero)
	if (top->zero)
		symbol__annotate_zero_histogram(symbol, top->sym_evsel->idx);
		symbol__annotate_zero_histogram(symbol, top->sym_evsel->idx);
+17 −13
Original line number Original line Diff line number Diff line
@@ -8,6 +8,7 @@
#include "../../util/hist.h"
#include "../../util/hist.h"
#include "../../util/sort.h"
#include "../../util/sort.h"
#include "../../util/symbol.h"
#include "../../util/symbol.h"
#include "../../util/evsel.h"
#include <pthread.h>
#include <pthread.h>
#include <newt.h>
#include <newt.h>


@@ -331,7 +332,7 @@ static void annotate_browser__set_rb_top(struct annotate_browser *browser,
}
}


static void annotate_browser__calc_percent(struct annotate_browser *browser,
static void annotate_browser__calc_percent(struct annotate_browser *browser,
					   int evidx)
					   struct perf_evsel *evsel)
{
{
	struct map_symbol *ms = browser->b.priv;
	struct map_symbol *ms = browser->b.priv;
	struct symbol *sym = ms->sym;
	struct symbol *sym = ms->sym;
@@ -344,7 +345,7 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,


	list_for_each_entry(pos, &notes->src->source, node) {
	list_for_each_entry(pos, &notes->src->source, node) {
		struct browser_disasm_line *bpos = disasm_line__browser(pos);
		struct browser_disasm_line *bpos = disasm_line__browser(pos);
		bpos->percent = disasm_line__calc_percent(pos, sym, evidx);
		bpos->percent = disasm_line__calc_percent(pos, sym, evsel->idx);
		if (bpos->percent < 0.01) {
		if (bpos->percent < 0.01) {
			RB_CLEAR_NODE(&bpos->rb_node);
			RB_CLEAR_NODE(&bpos->rb_node);
			continue;
			continue;
@@ -401,7 +402,8 @@ static void annotate_browser__init_asm_mode(struct annotate_browser *browser)
	browser->b.nr_entries = browser->nr_asm_entries;
	browser->b.nr_entries = browser->nr_asm_entries;
}
}


static bool annotate_browser__callq(struct annotate_browser *browser, int evidx,
static bool annotate_browser__callq(struct annotate_browser *browser,
				    struct perf_evsel *evsel,
				    struct hist_browser_timer *hbt)
				    struct hist_browser_timer *hbt)
{
{
	struct map_symbol *ms = browser->b.priv;
	struct map_symbol *ms = browser->b.priv;
@@ -432,7 +434,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser, int evidx,
	}
	}


	pthread_mutex_unlock(&notes->lock);
	pthread_mutex_unlock(&notes->lock);
	symbol__tui_annotate(target, ms->map, evidx, hbt);
	symbol__tui_annotate(target, ms->map, evsel, hbt);
	ui_browser__show_title(&browser->b, sym->name);
	ui_browser__show_title(&browser->b, sym->name);
	return true;
	return true;
}
}
@@ -615,7 +617,8 @@ static void annotate_browser__update_addr_width(struct annotate_browser *browser
		browser->addr_width += browser->jumps_width + 1;
		browser->addr_width += browser->jumps_width + 1;
}
}


static int annotate_browser__run(struct annotate_browser *browser, int evidx,
static int annotate_browser__run(struct annotate_browser *browser,
				 struct perf_evsel *evsel,
				 struct hist_browser_timer *hbt)
				 struct hist_browser_timer *hbt)
{
{
	struct rb_node *nd = NULL;
	struct rb_node *nd = NULL;
@@ -628,7 +631,7 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx,
	if (ui_browser__show(&browser->b, sym->name, help) < 0)
	if (ui_browser__show(&browser->b, sym->name, help) < 0)
		return -1;
		return -1;


	annotate_browser__calc_percent(browser, evidx);
	annotate_browser__calc_percent(browser, evsel);


	if (browser->curr_hot) {
	if (browser->curr_hot) {
		annotate_browser__set_rb_top(browser, browser->curr_hot);
		annotate_browser__set_rb_top(browser, browser->curr_hot);
@@ -641,7 +644,7 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx,
		key = ui_browser__run(&browser->b, delay_secs);
		key = ui_browser__run(&browser->b, delay_secs);


		if (delay_secs != 0) {
		if (delay_secs != 0) {
			annotate_browser__calc_percent(browser, evidx);
			annotate_browser__calc_percent(browser, evsel);
			/*
			/*
			 * Current line focus got out of the list of most active
			 * Current line focus got out of the list of most active
			 * lines, NULL it so that if TAB|UNTAB is pressed, we
			 * lines, NULL it so that if TAB|UNTAB is pressed, we
@@ -657,7 +660,7 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx,
				hbt->timer(hbt->arg);
				hbt->timer(hbt->arg);


			if (delay_secs != 0)
			if (delay_secs != 0)
				symbol__annotate_decay_histogram(sym, evidx);
				symbol__annotate_decay_histogram(sym, evsel->idx);
			continue;
			continue;
		case K_TAB:
		case K_TAB:
			if (nd != NULL) {
			if (nd != NULL) {
@@ -754,7 +757,7 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx,
					goto show_sup_ins;
					goto show_sup_ins;
				goto out;
				goto out;
			} else if (!(annotate_browser__jump(browser) ||
			} else if (!(annotate_browser__jump(browser) ||
				     annotate_browser__callq(browser, evidx, hbt))) {
				     annotate_browser__callq(browser, evsel, hbt))) {
show_sup_ins:
show_sup_ins:
				ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions.");
				ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions.");
			}
			}
@@ -776,10 +779,10 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx,
	return key;
	return key;
}
}


int hist_entry__tui_annotate(struct hist_entry *he, int evidx,
int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,
			     struct hist_browser_timer *hbt)
			     struct hist_browser_timer *hbt)
{
{
	return symbol__tui_annotate(he->ms.sym, he->ms.map, evidx, hbt);
	return symbol__tui_annotate(he->ms.sym, he->ms.map, evsel, hbt);
}
}


static void annotate_browser__mark_jump_targets(struct annotate_browser *browser,
static void annotate_browser__mark_jump_targets(struct annotate_browser *browser,
@@ -826,7 +829,8 @@ static inline int width_jumps(int n)
	return 1;
	return 1;
}
}


int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
int symbol__tui_annotate(struct symbol *sym, struct map *map,
			 struct perf_evsel *evsel,
			 struct hist_browser_timer *hbt)
			 struct hist_browser_timer *hbt)
{
{
	struct disasm_line *pos, *n;
	struct disasm_line *pos, *n;
@@ -909,7 +913,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,


	annotate_browser__update_addr_width(&browser);
	annotate_browser__update_addr_width(&browser);


	ret = annotate_browser__run(&browser, evidx, hbt);
	ret = annotate_browser__run(&browser, evsel, hbt);
	list_for_each_entry_safe(pos, n, &notes->src->source, node) {
	list_for_each_entry_safe(pos, n, &notes->src->source, node) {
		list_del(&pos->node);
		list_del(&pos->node);
		disasm_line__free(pos);
		disasm_line__free(pos);
+1 −1
Original line number Original line Diff line number Diff line
@@ -1599,7 +1599,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
			 * Don't let this be freed, say, by hists__decay_entry.
			 * Don't let this be freed, say, by hists__decay_entry.
			 */
			 */
			he->used = true;
			he->used = true;
			err = hist_entry__tui_annotate(he, evsel->idx, hbt);
			err = hist_entry__tui_annotate(he, evsel, hbt);
			he->used = false;
			he->used = false;
			/*
			/*
			 * offer option to annotate the other branch source or target
			 * offer option to annotate the other branch source or target
+6 −4
Original line number Original line Diff line number Diff line
#include "gtk.h"
#include "gtk.h"
#include "util/debug.h"
#include "util/debug.h"
#include "util/annotate.h"
#include "util/annotate.h"
#include "util/evsel.h"
#include "ui/helpline.h"
#include "ui/helpline.h"




@@ -85,7 +86,7 @@ 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,
static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
				struct map *map, int evidx,
				struct map *map, struct perf_evsel *evsel,
				struct hist_browser_timer *hbt __maybe_unused)
				struct hist_browser_timer *hbt __maybe_unused)
{
{
	struct disasm_line *pos, *n;
	struct disasm_line *pos, *n;
@@ -121,7 +122,7 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,


		gtk_list_store_append(store, &iter);
		gtk_list_store_append(store, &iter);


		if (perf_gtk__get_percent(s, sizeof(s), sym, pos, evidx))
		if (perf_gtk__get_percent(s, sizeof(s), sym, pos, evsel->idx))
			gtk_list_store_set(store, &iter, ANN_COL__PERCENT, s, -1);
			gtk_list_store_set(store, &iter, ANN_COL__PERCENT, s, -1);
		if (perf_gtk__get_offset(s, sizeof(s), sym, map, pos))
		if (perf_gtk__get_offset(s, sizeof(s), sym, map, pos))
			gtk_list_store_set(store, &iter, ANN_COL__OFFSET, s, -1);
			gtk_list_store_set(store, &iter, ANN_COL__OFFSET, s, -1);
@@ -139,7 +140,8 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
	return 0;
	return 0;
}
}


int symbol__gtk_annotate(struct symbol *sym, struct map *map, int evidx,
int symbol__gtk_annotate(struct symbol *sym, struct map *map,
			 struct perf_evsel *evsel,
			 struct hist_browser_timer *hbt)
			 struct hist_browser_timer *hbt)
{
{
	GtkWidget *window;
	GtkWidget *window;
@@ -206,7 +208,7 @@ int symbol__gtk_annotate(struct symbol *sym, struct map *map, int evidx,
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled_window,
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled_window,
				 tab_label);
				 tab_label);


	perf_gtk__annotate_symbol(scrolled_window, sym, map, evidx, hbt);
	perf_gtk__annotate_symbol(scrolled_window, sym, map, evsel, hbt);
	return 0;
	return 0;
}
}


Loading