perf util: Move block TUI function to ui browsers
It would be nice if we could jump to the assembler/source view (like the normal perf report) from total cycles view. This patch moves the block_hists_tui_browse from block-info.c to ui/browsers/hists.c in order to reuse some browser codes (i.e do_annotate) for implementing new annotation view. v2: --- Fix the 'make NO_SLANG=1' error. (Change 'int block_hists_tui_browse()' to 'static inline int block_hists_tui_browse()') Signed-off-by: Jin Yao <yao.jin@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jin Yao <yao.jin@intel.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lore.kernel.org/lkml/20191118140849.20714-1-yao.jin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
bb1835a3b8
commit
5cb456af99
@@ -3444,3 +3444,58 @@ 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 hists *hists = &bh->block_hists;
|
||||
struct hist_browser *browser;
|
||||
int key = -1;
|
||||
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;
|
||||
|
||||
/* reset abort key so that it can get Ctrl-C as a key */
|
||||
SLang_reset_tty();
|
||||
SLang_init_tty(0, 0, 0);
|
||||
|
||||
while (1) {
|
||||
key = hist_browser__run(browser, "? - help", true);
|
||||
|
||||
switch (key) {
|
||||
case 'q':
|
||||
goto out;
|
||||
case '?':
|
||||
ui_browser__help_window(&browser->b, help);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
hist_browser__delete(browser);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user