Skip to content
Snippets Groups Projects
Commit cdbab7c2 authored by Feng Tang's avatar Feng Tang Committed by Arnaldo Carvalho de Melo
Browse files

perf hists browser: Integrate script browser into main hists browser


Integrate the script browser into "perf report" framework, users can use
function key 'r' or the drop down menu to list all perf scripts and
select one of them, just like they did for the annotation.

Signed-off-by: default avatarFeng Tang <feng.tang@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1351569369-26732-6-git-send-email-feng.tang@intel.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 79ee47fa
No related branches found
No related tags found
No related merge requests found
...@@ -1141,6 +1141,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, ...@@ -1141,6 +1141,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
int nr_options = 0; int nr_options = 0;
int key = -1; int key = -1;
char buf[64]; char buf[64];
char script_opt[64];
if (browser == NULL) if (browser == NULL)
return -1; return -1;
...@@ -1159,6 +1160,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, ...@@ -1159,6 +1160,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
int choice = 0, int choice = 0,
annotate = -2, zoom_dso = -2, zoom_thread = -2, annotate = -2, zoom_dso = -2, zoom_thread = -2,
annotate_f = -2, annotate_t = -2, browse_map = -2; annotate_f = -2, annotate_t = -2, browse_map = -2;
int scripts_comm = -2, scripts_symbol = -2, scripts_all = -2;
nr_options = 0; nr_options = 0;
...@@ -1211,6 +1213,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, ...@@ -1211,6 +1213,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
hist_browser__reset(browser); hist_browser__reset(browser);
} }
continue; continue;
case 'r':
goto do_scripts;
case K_F1: case K_F1:
case 'h': case 'h':
case '?': case '?':
...@@ -1229,6 +1233,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, ...@@ -1229,6 +1233,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
"E Expand all callchains\n" "E Expand all callchains\n"
"d Zoom into current DSO\n" "d Zoom into current DSO\n"
"t Zoom into current Thread\n" "t Zoom into current Thread\n"
"r Run available scripts\n"
"P Print histograms to perf.hist.N\n" "P Print histograms to perf.hist.N\n"
"V Verbose (DSO names in callchains, etc)\n" "V Verbose (DSO names in callchains, etc)\n"
"/ Filter symbol by name"); "/ Filter symbol by name");
...@@ -1317,6 +1322,25 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, ...@@ -1317,6 +1322,25 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
browser->selection->map != NULL && browser->selection->map != NULL &&
asprintf(&options[nr_options], "Browse map details") > 0) asprintf(&options[nr_options], "Browse map details") > 0)
browse_map = nr_options++; browse_map = nr_options++;
/* perf script support */
if (browser->he_selection) {
struct symbol *sym;
if (asprintf(&options[nr_options], "Run scripts for samples of thread [%s]",
browser->he_selection->thread->comm) > 0)
scripts_comm = nr_options++;
sym = browser->he_selection->ms.sym;
if (sym && sym->namelen &&
asprintf(&options[nr_options], "Run scripts for samples of symbol [%s]",
sym->name) > 0)
scripts_symbol = nr_options++;
}
if (asprintf(&options[nr_options], "Run scripts for all samples") > 0)
scripts_all = nr_options++;
add_exit_option: add_exit_option:
options[nr_options++] = (char *)"Exit"; options[nr_options++] = (char *)"Exit";
retry_popup_menu: retry_popup_menu:
...@@ -1411,6 +1435,20 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, ...@@ -1411,6 +1435,20 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
hists__filter_by_thread(hists); hists__filter_by_thread(hists);
hist_browser__reset(browser); hist_browser__reset(browser);
} }
/* perf scripts support */
else if (choice == scripts_all || choice == scripts_comm ||
choice == scripts_symbol) {
do_scripts:
memset(script_opt, 0, 64);
if (choice == scripts_comm)
sprintf(script_opt, " -c %s ", browser->he_selection->thread->comm);
if (choice == scripts_symbol)
sprintf(script_opt, " -S %s ", browser->he_selection->ms.sym->name);
script_browse(script_opt);
}
} }
out_free_stack: out_free_stack:
pstack__delete(fstack); pstack__delete(fstack);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment