Skip to content

Commit cdbab7c

Browse files
ftang1acmel
authored andcommitted
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: Feng Tang <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 79ee47f commit cdbab7c

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tools/perf/ui/browsers/hists.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
11411141
int nr_options = 0;
11421142
int key = -1;
11431143
char buf[64];
1144+
char script_opt[64];
11441145

11451146
if (browser == NULL)
11461147
return -1;
@@ -1159,6 +1160,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
11591160
int choice = 0,
11601161
annotate = -2, zoom_dso = -2, zoom_thread = -2,
11611162
annotate_f = -2, annotate_t = -2, browse_map = -2;
1163+
int scripts_comm = -2, scripts_symbol = -2, scripts_all = -2;
11621164

11631165
nr_options = 0;
11641166

@@ -1211,6 +1213,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
12111213
hist_browser__reset(browser);
12121214
}
12131215
continue;
1216+
case 'r':
1217+
goto do_scripts;
12141218
case K_F1:
12151219
case 'h':
12161220
case '?':
@@ -1229,6 +1233,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
12291233
"E Expand all callchains\n"
12301234
"d Zoom into current DSO\n"
12311235
"t Zoom into current Thread\n"
1236+
"r Run available scripts\n"
12321237
"P Print histograms to perf.hist.N\n"
12331238
"V Verbose (DSO names in callchains, etc)\n"
12341239
"/ Filter symbol by name");
@@ -1317,6 +1322,25 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
13171322
browser->selection->map != NULL &&
13181323
asprintf(&options[nr_options], "Browse map details") > 0)
13191324
browse_map = nr_options++;
1325+
1326+
/* perf script support */
1327+
if (browser->he_selection) {
1328+
struct symbol *sym;
1329+
1330+
if (asprintf(&options[nr_options], "Run scripts for samples of thread [%s]",
1331+
browser->he_selection->thread->comm) > 0)
1332+
scripts_comm = nr_options++;
1333+
1334+
sym = browser->he_selection->ms.sym;
1335+
if (sym && sym->namelen &&
1336+
asprintf(&options[nr_options], "Run scripts for samples of symbol [%s]",
1337+
sym->name) > 0)
1338+
scripts_symbol = nr_options++;
1339+
}
1340+
1341+
if (asprintf(&options[nr_options], "Run scripts for all samples") > 0)
1342+
scripts_all = nr_options++;
1343+
13201344
add_exit_option:
13211345
options[nr_options++] = (char *)"Exit";
13221346
retry_popup_menu:
@@ -1411,6 +1435,20 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
14111435
hists__filter_by_thread(hists);
14121436
hist_browser__reset(browser);
14131437
}
1438+
/* perf scripts support */
1439+
else if (choice == scripts_all || choice == scripts_comm ||
1440+
choice == scripts_symbol) {
1441+
do_scripts:
1442+
memset(script_opt, 0, 64);
1443+
1444+
if (choice == scripts_comm)
1445+
sprintf(script_opt, " -c %s ", browser->he_selection->thread->comm);
1446+
1447+
if (choice == scripts_symbol)
1448+
sprintf(script_opt, " -S %s ", browser->he_selection->ms.sym->name);
1449+
1450+
script_browse(script_opt);
1451+
}
14141452
}
14151453
out_free_stack:
14161454
pstack__delete(fstack);

0 commit comments

Comments
 (0)