aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-script.c
diff options
context:
space:
mode:
authorAkihiro Nagai <akihiro.nagai.hw@hitachi.com>2012-01-29 23:43:09 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-01-30 15:08:43 -0500
commit9558259697b827106b464648e850e568e0b0c931 (patch)
tree34d1656764bfcee2d5c931d73f2519c78f7cfd95 /tools/perf/builtin-script.c
parent547a92e0aedb88129e7fbd804697a11949de2e5a (diff)
perf script: Print branch_from and branch_to of BTS events
BTS records branch_from_addr and branch_to_addr in IP and ADDR field in perf_sample. This patch enables to print them in following format, <from_addr> <from_symbol> (<from_dso>) => <to_addr> <to_symbol> (<to_dso>) Sample: ffffffff814675d2 irq_return ([kernel.kallsyms]) => 3f03e016b0 _start (/lib64/ld-2.14.so) ffffffff814675d2 irq_return ([kernel.kallsyms]) => 3f03e016b0 _start (/lib64/ld-2.14.so) 3f03e016b3 _start (/lib64/ld-2.14.so) => 3f03e04b80 _dl_start (/lib64/ld-2.14.so) ffffffff814675d2 irq_return ([kernel.kallsyms]) => 3f03e04b80 _dl_start (/lib64/ld-2.14.so) ffffffff814675d2 irq_return ([kernel.kallsyms]) => 3f03e04ba6 _dl_start (/lib64/ld-2.14.so) ffffffff814675d2 irq_return ([kernel.kallsyms]) => 3f03e04bad _dl_start (/lib64/ld-2.14.so) 3f03e04bfb _dl_start (/lib64/ld-2.14.so) => 3f03e04c1d _dl_start (/lib64/ld-2.14.so) [snip] Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: yrl.pp-manager.tt@hitachi.com Link: http://lkml.kernel.org/r/20120130044309.2384.44252.stgit@linux3 Signed-off-by: Akihiro Nagai <akihiro.nagai.hw@hitachi.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r--tools/perf/builtin-script.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index add13ec15977..414d49ad83de 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -304,6 +304,13 @@ static void print_sample_start(struct perf_sample *sample,
304 } 304 }
305} 305}
306 306
307static bool is_bts_event(struct perf_event_attr *attr)
308{
309 return ((attr->type == PERF_TYPE_HARDWARE) &&
310 (attr->config & PERF_COUNT_HW_BRANCH_INSTRUCTIONS) &&
311 (attr->sample_period == 1));
312}
313
307static bool sample_addr_correlates_sym(struct perf_event_attr *attr) 314static bool sample_addr_correlates_sym(struct perf_event_attr *attr)
308{ 315{
309 if ((attr->type == PERF_TYPE_SOFTWARE) && 316 if ((attr->type == PERF_TYPE_SOFTWARE) &&
@@ -312,6 +319,9 @@ static bool sample_addr_correlates_sym(struct perf_event_attr *attr)
312 (attr->config == PERF_COUNT_SW_PAGE_FAULTS_MAJ))) 319 (attr->config == PERF_COUNT_SW_PAGE_FAULTS_MAJ)))
313 return true; 320 return true;
314 321
322 if (is_bts_event(attr))
323 return true;
324
315 return false; 325 return false;
316} 326}
317 327
@@ -353,6 +363,33 @@ static void print_sample_addr(union perf_event *event,
353 } 363 }
354} 364}
355 365
366static void print_sample_bts(union perf_event *event,
367 struct perf_sample *sample,
368 struct perf_evsel *evsel,
369 struct machine *machine,
370 struct thread *thread)
371{
372 struct perf_event_attr *attr = &evsel->attr;
373
374 /* print branch_from information */
375 if (PRINT_FIELD(IP)) {
376 if (!symbol_conf.use_callchain)
377 printf(" ");
378 else
379 printf("\n");
380 perf_event__print_ip(event, sample, machine, evsel,
381 PRINT_FIELD(SYM), PRINT_FIELD(DSO));
382 }
383
384 printf(" => ");
385
386 /* print branch_to information */
387 if (PRINT_FIELD(ADDR))
388 print_sample_addr(event, sample, machine, thread, attr);
389
390 printf("\n");
391}
392
356static void process_event(union perf_event *event __unused, 393static void process_event(union perf_event *event __unused,
357 struct perf_sample *sample, 394 struct perf_sample *sample,
358 struct perf_evsel *evsel, 395 struct perf_evsel *evsel,
@@ -366,6 +403,11 @@ static void process_event(union perf_event *event __unused,
366 403
367 print_sample_start(sample, thread, attr); 404 print_sample_start(sample, thread, attr);
368 405
406 if (is_bts_event(attr)) {
407 print_sample_bts(event, sample, evsel, machine, thread);
408 return;
409 }
410
369 if (PRINT_FIELD(TRACE)) 411 if (PRINT_FIELD(TRACE))
370 print_trace_event(sample->cpu, sample->raw_data, 412 print_trace_event(sample->cpu, sample->raw_data,
371 sample->raw_size); 413 sample->raw_size);