diff options
Diffstat (limited to 'tools/perf/util/unwind-libunwind.c')
-rw-r--r-- | tools/perf/util/unwind-libunwind.c | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c index 92b56db52471..e060386165c5 100644 --- a/tools/perf/util/unwind-libunwind.c +++ b/tools/perf/util/unwind-libunwind.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/list.h> | 24 | #include <linux/list.h> |
25 | #include <libunwind.h> | 25 | #include <libunwind.h> |
26 | #include <libunwind-ptrace.h> | 26 | #include <libunwind-ptrace.h> |
27 | #include "callchain.h" | ||
27 | #include "thread.h" | 28 | #include "thread.h" |
28 | #include "session.h" | 29 | #include "session.h" |
29 | #include "perf_regs.h" | 30 | #include "perf_regs.h" |
@@ -525,12 +526,12 @@ static unw_accessors_t accessors = { | |||
525 | .get_proc_name = get_proc_name, | 526 | .get_proc_name = get_proc_name, |
526 | }; | 527 | }; |
527 | 528 | ||
528 | static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb, | 529 | int unwind__prepare_access(struct thread *thread) |
529 | void *arg, int max_stack) | ||
530 | { | 530 | { |
531 | unw_addr_space_t addr_space; | 531 | unw_addr_space_t addr_space; |
532 | unw_cursor_t c; | 532 | |
533 | int ret; | 533 | if (callchain_param.record_mode != CALLCHAIN_DWARF) |
534 | return 0; | ||
534 | 535 | ||
535 | addr_space = unw_create_addr_space(&accessors, 0); | 536 | addr_space = unw_create_addr_space(&accessors, 0); |
536 | if (!addr_space) { | 537 | if (!addr_space) { |
@@ -538,6 +539,33 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb, | |||
538 | return -ENOMEM; | 539 | return -ENOMEM; |
539 | } | 540 | } |
540 | 541 | ||
542 | thread__set_priv(thread, addr_space); | ||
543 | |||
544 | return 0; | ||
545 | } | ||
546 | |||
547 | void unwind__finish_access(struct thread *thread) | ||
548 | { | ||
549 | unw_addr_space_t addr_space; | ||
550 | |||
551 | if (callchain_param.record_mode != CALLCHAIN_DWARF) | ||
552 | return; | ||
553 | |||
554 | addr_space = thread__priv(thread); | ||
555 | unw_destroy_addr_space(addr_space); | ||
556 | } | ||
557 | |||
558 | static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb, | ||
559 | void *arg, int max_stack) | ||
560 | { | ||
561 | unw_addr_space_t addr_space; | ||
562 | unw_cursor_t c; | ||
563 | int ret; | ||
564 | |||
565 | addr_space = thread__priv(ui->thread); | ||
566 | if (addr_space == NULL) | ||
567 | return -1; | ||
568 | |||
541 | ret = unw_init_remote(&c, addr_space, ui); | 569 | ret = unw_init_remote(&c, addr_space, ui); |
542 | if (ret) | 570 | if (ret) |
543 | display_error(ret); | 571 | display_error(ret); |
@@ -549,7 +577,6 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb, | |||
549 | ret = ip ? entry(ip, ui->thread, ui->machine, cb, arg) : 0; | 577 | ret = ip ? entry(ip, ui->thread, ui->machine, cb, arg) : 0; |
550 | } | 578 | } |
551 | 579 | ||
552 | unw_destroy_addr_space(addr_space); | ||
553 | return ret; | 580 | return ret; |
554 | } | 581 | } |
555 | 582 | ||