aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2015-11-18 02:52:47 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-11-23 16:30:41 -0500
commitcb1dc22dce6e54dbd1eac213c9216e1aa57084da (patch)
tree977a3f7b43d22a9e0173df61bb317de4c399956d
parentb26b218a1e9c5815cb8964e180b7fba3cd9bd509 (diff)
perf callchain: Add order support for libunwind DWARF unwinder
As reported by Milian, currently for DWARF unwind (both libdw and libunwind) we display callchain in callee order only. Adding the support to follow callchain order setup to libunwind DWARF unwinder, so we could get following output for report: $ perf record --call-graph dwarf ls ... $ perf report --no-children --stdio 39.26% ls libc-2.21.so [.] __strcoll_l | ---__strcoll_l mpsort_with_tmp mpsort_with_tmp sort_files main __libc_start_main _start 0 $ perf report -g caller --no-children --stdio ... 39.26% ls libc-2.21.so [.] __strcoll_l | ---0 _start __libc_start_main main sort_files mpsort_with_tmp mpsort_with_tmp __strcoll_l Based-on-patch-by: Milian Wolff <milian.wolff@kdab.com> Reported-and-Tested-by: Milian Wolff <milian.wolff@kdab.com> Signed-off-by: Jiri Olsa <jolsa@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Tested-by: Wang Nan <wangnan0@huawei.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/20151118075247.GA5416@krava.brq.redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/unwind-libunwind.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index 0ae8844fe7a6..3c258a0e4092 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -615,34 +615,47 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
615 void *arg, int max_stack) 615 void *arg, int max_stack)
616{ 616{
617 u64 val; 617 u64 val;
618 unw_word_t ips[max_stack];
618 unw_addr_space_t addr_space; 619 unw_addr_space_t addr_space;
619 unw_cursor_t c; 620 unw_cursor_t c;
620 int ret; 621 int ret, i = 0;
621 622
622 ret = perf_reg_value(&val, &ui->sample->user_regs, PERF_REG_IP); 623 ret = perf_reg_value(&val, &ui->sample->user_regs, PERF_REG_IP);
623 if (ret) 624 if (ret)
624 return ret; 625 return ret;
625 626
626 ret = entry(val, ui->thread, cb, arg); 627 ips[i++] = (unw_word_t) val;
627 if (ret)
628 return -ENOMEM;
629 628
630 if (--max_stack == 0) 629 /*
631 return 0; 630 * If we need more than one entry, do the DWARF
632 631 * unwind itself.
633 addr_space = thread__priv(ui->thread); 632 */
634 if (addr_space == NULL) 633 if (max_stack - 1 > 0) {
635 return -1; 634 addr_space = thread__priv(ui->thread);
635 if (addr_space == NULL)
636 return -1;
637
638 ret = unw_init_remote(&c, addr_space, ui);
639 if (ret)
640 display_error(ret);
641
642 while (!ret && (unw_step(&c) > 0) && i < max_stack) {
643 unw_get_reg(&c, UNW_REG_IP, &ips[i]);
644 ++i;
645 }
636 646
637 ret = unw_init_remote(&c, addr_space, ui); 647 max_stack = i;
638 if (ret) 648 }
639 display_error(ret);
640 649
641 while (!ret && (unw_step(&c) > 0) && max_stack--) { 650 /*
642 unw_word_t ip; 651 * Display what we got based on the order setup.
652 */
653 for (i = 0; i < max_stack && !ret; i++) {
654 int j = i;
643 655
644 unw_get_reg(&c, UNW_REG_IP, &ip); 656 if (callchain_param.order == ORDER_CALLER)
645 ret = ip ? entry(ip, ui->thread, cb, arg) : 0; 657 j = max_stack - i - 1;
658 ret = ips[j] ? entry(ips[j], ui->thread, cb, arg) : 0;
646 } 659 }
647 660
648 return ret; 661 return ret;