aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorFeng Tang <feng.tang@intel.com>2012-10-29 23:56:06 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-10-29 09:56:19 -0400
commitcdbab7c201ab38f7b8d248ebf289025381166526 (patch)
tree04b4f1bab030e2f73b477c8e07a45ede826cf221 /tools
parent79ee47faa77706f568f0329b7475c123b67a3b4a (diff)
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 <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: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/ui/browsers/hists.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index ef2f93ca7496..fe622845872e 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1141,6 +1141,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
1141 int nr_options = 0; 1141 int nr_options = 0;
1142 int key = -1; 1142 int key = -1;
1143 char buf[64]; 1143 char buf[64];
1144 char script_opt[64];
1144 1145
1145 if (browser == NULL) 1146 if (browser == NULL)
1146 return -1; 1147 return -1;
@@ -1159,6 +1160,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
1159 int choice = 0, 1160 int choice = 0,
1160 annotate = -2, zoom_dso = -2, zoom_thread = -2, 1161 annotate = -2, zoom_dso = -2, zoom_thread = -2,
1161 annotate_f = -2, annotate_t = -2, browse_map = -2; 1162 annotate_f = -2, annotate_t = -2, browse_map = -2;
1163 int scripts_comm = -2, scripts_symbol = -2, scripts_all = -2;
1162 1164
1163 nr_options = 0; 1165 nr_options = 0;
1164 1166
@@ -1211,6 +1213,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
1211 hist_browser__reset(browser); 1213 hist_browser__reset(browser);
1212 } 1214 }
1213 continue; 1215 continue;
1216 case 'r':
1217 goto do_scripts;
1214 case K_F1: 1218 case K_F1:
1215 case 'h': 1219 case 'h':
1216 case '?': 1220 case '?':
@@ -1229,6 +1233,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
1229 "E Expand all callchains\n" 1233 "E Expand all callchains\n"
1230 "d Zoom into current DSO\n" 1234 "d Zoom into current DSO\n"
1231 "t Zoom into current Thread\n" 1235 "t Zoom into current Thread\n"
1236 "r Run available scripts\n"
1232 "P Print histograms to perf.hist.N\n" 1237 "P Print histograms to perf.hist.N\n"
1233 "V Verbose (DSO names in callchains, etc)\n" 1238 "V Verbose (DSO names in callchains, etc)\n"
1234 "/ Filter symbol by name"); 1239 "/ Filter symbol by name");
@@ -1317,6 +1322,25 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
1317 browser->selection->map != NULL && 1322 browser->selection->map != NULL &&
1318 asprintf(&options[nr_options], "Browse map details") > 0) 1323 asprintf(&options[nr_options], "Browse map details") > 0)
1319 browse_map = nr_options++; 1324 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
1320add_exit_option: 1344add_exit_option:
1321 options[nr_options++] = (char *)"Exit"; 1345 options[nr_options++] = (char *)"Exit";
1322retry_popup_menu: 1346retry_popup_menu:
@@ -1411,6 +1435,20 @@ zoom_out_thread:
1411 hists__filter_by_thread(hists); 1435 hists__filter_by_thread(hists);
1412 hist_browser__reset(browser); 1436 hist_browser__reset(browser);
1413 } 1437 }
1438 /* perf scripts support */
1439 else if (choice == scripts_all || choice == scripts_comm ||
1440 choice == scripts_symbol) {
1441do_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 }
1414 } 1452 }
1415out_free_stack: 1453out_free_stack:
1416 pstack__delete(fstack); 1454 pstack__delete(fstack);