aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-11-17 10:05:37 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-11-23 16:30:10 -0500
commitb26b218a1e9c5815cb8964e180b7fba3cd9bd509 (patch)
treea2e9524ec191918c842501a7398d33c08eb45390 /tools/perf
parentb7883a1c4f75edb62fc49da6000c59fb881e3c7b (diff)
perf callchain: Move initial entry call into get_entries function
Moving initial entry call into get_entries function so all entries processing is on one place. It will be useful for next change that adds ordering logic. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Tested-by: Milian Wolff <milian.wolff@kdab.com> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1447772739-18471-2-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/unwind-libunwind.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index c83832b555e5..0ae8844fe7a6 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -614,10 +614,22 @@ void unwind__finish_access(struct thread *thread)
614static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb, 614static 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 unw_addr_space_t addr_space; 618 unw_addr_space_t addr_space;
618 unw_cursor_t c; 619 unw_cursor_t c;
619 int ret; 620 int ret;
620 621
622 ret = perf_reg_value(&val, &ui->sample->user_regs, PERF_REG_IP);
623 if (ret)
624 return ret;
625
626 ret = entry(val, ui->thread, cb, arg);
627 if (ret)
628 return -ENOMEM;
629
630 if (--max_stack == 0)
631 return 0;
632
621 addr_space = thread__priv(ui->thread); 633 addr_space = thread__priv(ui->thread);
622 if (addr_space == NULL) 634 if (addr_space == NULL)
623 return -1; 635 return -1;
@@ -640,24 +652,17 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
640 struct thread *thread, 652 struct thread *thread,
641 struct perf_sample *data, int max_stack) 653 struct perf_sample *data, int max_stack)
642{ 654{
643 u64 ip;
644 struct unwind_info ui = { 655 struct unwind_info ui = {
645 .sample = data, 656 .sample = data,
646 .thread = thread, 657 .thread = thread,
647 .machine = thread->mg->machine, 658 .machine = thread->mg->machine,
648 }; 659 };
649 int ret;
650 660
651 if (!data->user_regs.regs) 661 if (!data->user_regs.regs)
652 return -EINVAL; 662 return -EINVAL;
653 663
654 ret = perf_reg_value(&ip, &data->user_regs, PERF_REG_IP); 664 if (max_stack <= 0)
655 if (ret) 665 return -EINVAL;
656 return ret;
657
658 ret = entry(ip, thread, cb, arg);
659 if (ret)
660 return -ENOMEM;
661 666
662 return --max_stack > 0 ? get_entries(&ui, cb, arg, max_stack) : 0; 667 return get_entries(&ui, cb, arg, max_stack);
663} 668}