diff options
Diffstat (limited to 'tools/perf/ui/browsers/hists.c')
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 105 |
1 files changed, 91 insertions, 14 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 7a7187e069b4..d4d3558fdef4 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -26,6 +26,7 @@ #include "../../util/sort.h" #include "../../util/top.h" #include "../../util/thread.h" +#include "../../util/block-info.h" #include "../../arch/common.h" #include "../../perf.h" @@ -1783,7 +1784,11 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser) continue; } - percent = hist_entry__get_percent_limit(h); + if (symbol_conf.report_individual_block) + percent = block_info__total_cycles_percent(h); + else + percent = hist_entry__get_percent_limit(h); + if (percent < hb->min_pcnt) continue; @@ -2380,7 +2385,11 @@ do_annotate(struct hist_browser *browser, struct popup_action *act) if (!notes->src) return 0; - evsel = hists_to_evsel(browser->hists); + if (browser->block_evsel) + evsel = browser->block_evsel; + else + evsel = hists_to_evsel(browser->hists); + err = map_symbol__tui_annotate(&act->ms, evsel, browser->hbt, browser->annotation_opts); he = hist_browser__selected_entry(browser); @@ -2400,16 +2409,15 @@ do_annotate(struct hist_browser *browser, struct popup_action *act) static int add_annotate_opt(struct hist_browser *browser __maybe_unused, struct popup_action *act, char **optstr, - struct map *map, struct symbol *sym) + struct map_symbol *ms) { - if (sym == NULL || map->dso->annotate_warned) + if (ms->sym == NULL || ms->map->dso->annotate_warned) return 0; - if (asprintf(optstr, "Annotate %s", sym->name) < 0) + if (asprintf(optstr, "Annotate %s", ms->sym->name) < 0) return 0; - act->ms.map = map; - act->ms.sym = sym; + act->ms = *ms; act->fn = do_annotate; return 1; } @@ -3110,20 +3118,17 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events, nr_options += add_annotate_opt(browser, &actions[nr_options], &options[nr_options], - bi->from.map, - bi->from.sym); - if (bi->to.sym != bi->from.sym) + &bi->from.ms); + if (bi->to.ms.sym != bi->from.ms.sym) nr_options += add_annotate_opt(browser, &actions[nr_options], &options[nr_options], - bi->to.map, - bi->to.sym); + &bi->to.ms); } else { nr_options += add_annotate_opt(browser, &actions[nr_options], &options[nr_options], - browser->selection->map, - browser->selection->sym); + browser->selection); } skip_annotation: nr_options += add_thread_opt(browser, &actions[nr_options], @@ -3443,3 +3448,75 @@ single_entry: warn_lost_event, annotation_opts); } + +static int block_hists_browser__title(struct hist_browser *browser, char *bf, + size_t size) +{ + struct hists *hists = evsel__hists(browser->block_evsel); + const char *evname = perf_evsel__name(browser->block_evsel); + unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE]; + int ret; + + ret = scnprintf(bf, size, "# Samples: %lu", nr_samples); + if (evname) + scnprintf(bf + ret, size - ret, " of event '%s'", evname); + + return 0; +} + +int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel, + float min_percent, struct perf_env *env, + struct annotation_options *annotation_opts) +{ + struct hists *hists = &bh->block_hists; + struct hist_browser *browser; + int key = -1; + struct popup_action action; + static const char help[] = + " q Quit \n"; + + browser = hist_browser__new(hists); + if (!browser) + return -1; + + browser->block_evsel = evsel; + browser->title = block_hists_browser__title; + browser->min_pcnt = min_percent; + browser->env = env; + browser->annotation_opts = annotation_opts; + + /* reset abort key so that it can get Ctrl-C as a key */ + SLang_reset_tty(); + SLang_init_tty(0, 0, 0); + + memset(&action, 0, sizeof(action)); + + while (1) { + key = hist_browser__run(browser, "? - help", true); + + switch (key) { + case 'q': + goto out; + case '?': + ui_browser__help_window(&browser->b, help); + break; + case 'a': + case K_ENTER: + if (!browser->selection || + !browser->selection->sym) { + continue; + } + + action.ms.map = browser->selection->map; + action.ms.sym = browser->selection->sym; + do_annotate(browser, &action); + continue; + default: + break; + } + } + +out: + hist_browser__delete(browser); + return 0; +} |