aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-annotate.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2018-03-15 22:44:34 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-03-21 11:53:26 -0400
commitbefd2a38a632b1f27ad652fea67c8cf97ce59409 (patch)
tree8389138ba03f646ed5467ef39c1d8b905465cd96 /tools/perf/builtin-annotate.c
parent9b80d1f946ee40923f7bf51c69cb3a6ac6097e4a (diff)
perf annotate: Introduce the --stdio2 output mode
This uses the TUI augmented formatting routines, modulo interactivity. # perf annotate --ignore-vmlinux --stdio2 _raw_spin_lock_irqsave _raw_spin_lock_irqsave() /proc/kcore Event: cycles:ppp Percent Disassembly of section load0: ffffffff9a8734b0 <load0>: nop push %rbx 50.00 pushfq pop %rax nop mov %rax,%rbx cli nop xor %eax,%eax mov $0x1,%edx 50.00 lock cmpxchg %edx,(%rdi) test %eax,%eax ↓ jne 2b mov %rbx,%rax pop %rbx ← retq 2b: mov %eax,%esi → callq queued_spin_lock_slowpath mov %rbx,%rax pop %rbx ← retq Tested-by: Jin Yao <yao.jin@linux.intel.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-6cte5o8z84mbivbvqlg14uh1@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r--tools/perf/builtin-annotate.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index ead6ae4549e5..e03f9bea9303 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -40,7 +40,7 @@
40struct perf_annotate { 40struct perf_annotate {
41 struct perf_tool tool; 41 struct perf_tool tool;
42 struct perf_session *session; 42 struct perf_session *session;
43 bool use_tui, use_stdio, use_gtk; 43 bool use_tui, use_stdio, use_stdio2, use_gtk;
44 bool full_paths; 44 bool full_paths;
45 bool print_line; 45 bool print_line;
46 bool skip_missing; 46 bool skip_missing;
@@ -202,6 +202,11 @@ static int process_branch_callback(struct perf_evsel *evsel,
202 return ret; 202 return ret;
203} 203}
204 204
205static bool has_annotation(struct perf_annotate *ann)
206{
207 return ui__has_annotation() || ann->use_stdio2;
208}
209
205static int perf_evsel__add_sample(struct perf_evsel *evsel, 210static int perf_evsel__add_sample(struct perf_evsel *evsel,
206 struct perf_sample *sample, 211 struct perf_sample *sample,
207 struct addr_location *al, 212 struct addr_location *al,
@@ -212,7 +217,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
212 struct hist_entry *he; 217 struct hist_entry *he;
213 int ret; 218 int ret;
214 219
215 if ((!ann->has_br_stack || !ui__has_annotation()) && 220 if ((!ann->has_br_stack || !has_annotation(ann)) &&
216 ann->sym_hist_filter != NULL && 221 ann->sym_hist_filter != NULL &&
217 (al->sym == NULL || 222 (al->sym == NULL ||
218 strcmp(ann->sym_hist_filter, al->sym->name) != 0)) { 223 strcmp(ann->sym_hist_filter, al->sym->name) != 0)) {
@@ -236,7 +241,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
236 */ 241 */
237 process_branch_stack(sample->branch_stack, al, sample); 242 process_branch_stack(sample->branch_stack, al, sample);
238 243
239 if (ann->has_br_stack && ui__has_annotation()) 244 if (ann->has_br_stack && has_annotation(ann))
240 return process_branch_callback(evsel, sample, al, ann, machine); 245 return process_branch_callback(evsel, sample, al, ann, machine);
241 246
242 he = hists__add_entry(hists, al, NULL, NULL, NULL, sample, true); 247 he = hists__add_entry(hists, al, NULL, NULL, NULL, sample, true);
@@ -282,8 +287,11 @@ static int hist_entry__tty_annotate(struct hist_entry *he,
282 struct perf_evsel *evsel, 287 struct perf_evsel *evsel,
283 struct perf_annotate *ann) 288 struct perf_annotate *ann)
284{ 289{
285 return symbol__tty_annotate(he->ms.sym, he->ms.map, evsel, 290 if (!ann->use_stdio2)
286 ann->print_line, ann->full_paths, 0, 0); 291 return symbol__tty_annotate(he->ms.sym, he->ms.map, evsel,
292 ann->print_line, ann->full_paths, 0, 0);
293 return symbol__tty_annotate2(he->ms.sym, he->ms.map, evsel,
294 ann->print_line, ann->full_paths);
287} 295}
288 296
289static void hists__find_annotations(struct hists *hists, 297static void hists__find_annotations(struct hists *hists,
@@ -487,6 +495,7 @@ int cmd_annotate(int argc, const char **argv)
487 OPT_BOOLEAN(0, "gtk", &annotate.use_gtk, "Use the GTK interface"), 495 OPT_BOOLEAN(0, "gtk", &annotate.use_gtk, "Use the GTK interface"),
488 OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"), 496 OPT_BOOLEAN(0, "tui", &annotate.use_tui, "Use the TUI interface"),
489 OPT_BOOLEAN(0, "stdio", &annotate.use_stdio, "Use the stdio interface"), 497 OPT_BOOLEAN(0, "stdio", &annotate.use_stdio, "Use the stdio interface"),
498 OPT_BOOLEAN(0, "stdio2", &annotate.use_stdio2, "Use the stdio interface"),
490 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, 499 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
491 "file", "vmlinux pathname"), 500 "file", "vmlinux pathname"),
492 OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules, 501 OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
@@ -569,7 +578,7 @@ int cmd_annotate(int argc, const char **argv)
569 if (ret < 0) 578 if (ret < 0)
570 goto out_delete; 579 goto out_delete;
571 580
572 if (annotate.use_stdio) 581 if (annotate.use_stdio || annotate.use_stdio2)
573 use_browser = 0; 582 use_browser = 0;
574 else if (annotate.use_tui) 583 else if (annotate.use_tui)
575 use_browser = 1; 584 use_browser = 1;
@@ -578,7 +587,7 @@ int cmd_annotate(int argc, const char **argv)
578 587
579 setup_browser(true); 588 setup_browser(true);
580 589
581 if (use_browser == 1 && annotate.has_br_stack) { 590 if ((use_browser == 1 || annotate.use_stdio2) && annotate.has_br_stack) {
582 sort__mode = SORT_MODE__BRANCH; 591 sort__mode = SORT_MODE__BRANCH;
583 if (setup_sorting(annotate.session->evlist) < 0) 592 if (setup_sorting(annotate.session->evlist) < 0)
584 usage_with_options(annotate_usage, options); 593 usage_with_options(annotate_usage, options);