aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/Build1
-rw-r--r--tools/perf/util/unwind-libunwind-local.c34
-rw-r--r--tools/perf/util/unwind-libunwind.c38
3 files changed, 39 insertions, 34 deletions
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 5e23d85d2d69..004fb1d1d0ad 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -100,6 +100,7 @@ libperf-$(CONFIG_DWARF) += dwarf-aux.o
100 100
101libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o 101libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
102libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind-local.o 102libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind-local.o
103libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o
103 104
104libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o 105libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
105 106
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
index b0c5db1333f9..9c70486c5c6a 100644
--- a/tools/perf/util/unwind-libunwind-local.c
+++ b/tools/perf/util/unwind-libunwind-local.c
@@ -691,37 +691,3 @@ _unwind_libunwind_ops = {
691 691
692struct unwind_libunwind_ops * 692struct unwind_libunwind_ops *
693local_unwind_libunwind_ops = &_unwind_libunwind_ops; 693local_unwind_libunwind_ops = &_unwind_libunwind_ops;
694
695static void unwind__register_ops(struct thread *thread,
696 struct unwind_libunwind_ops *ops)
697{
698 thread->unwind_libunwind_ops = ops;
699}
700
701int unwind__prepare_access(struct thread *thread)
702{
703 unwind__register_ops(thread, local_unwind_libunwind_ops);
704
705 return thread->unwind_libunwind_ops->prepare_access(thread);
706}
707
708void unwind__flush_access(struct thread *thread)
709{
710 if (thread->unwind_libunwind_ops)
711 thread->unwind_libunwind_ops->flush_access(thread);
712}
713
714void unwind__finish_access(struct thread *thread)
715{
716 if (thread->unwind_libunwind_ops)
717 thread->unwind_libunwind_ops->finish_access(thread);
718}
719
720int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
721 struct thread *thread,
722 struct perf_sample *data, int max_stack)
723{
724 if (thread->unwind_libunwind_ops)
725 return thread->unwind_libunwind_ops->get_entries(cb, arg, thread, data, max_stack);
726 return 0;
727}
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
new file mode 100644
index 000000000000..f86f903ae8a8
--- /dev/null
+++ b/tools/perf/util/unwind-libunwind.c
@@ -0,0 +1,38 @@
1#include "unwind.h"
2#include "thread.h"
3
4struct unwind_libunwind_ops __weak *local_unwind_libunwind_ops;
5
6static void unwind__register_ops(struct thread *thread,
7 struct unwind_libunwind_ops *ops)
8{
9 thread->unwind_libunwind_ops = ops;
10}
11
12int unwind__prepare_access(struct thread *thread)
13{
14 unwind__register_ops(thread, local_unwind_libunwind_ops);
15
16 return thread->unwind_libunwind_ops->prepare_access(thread);
17}
18
19void unwind__flush_access(struct thread *thread)
20{
21 if (thread->unwind_libunwind_ops)
22 thread->unwind_libunwind_ops->flush_access(thread);
23}
24
25void unwind__finish_access(struct thread *thread)
26{
27 if (thread->unwind_libunwind_ops)
28 thread->unwind_libunwind_ops->finish_access(thread);
29}
30
31int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
32 struct thread *thread,
33 struct perf_sample *data, int max_stack)
34{
35 if (thread->unwind_libunwind_ops)
36 return thread->unwind_libunwind_ops->get_entries(cb, arg, thread, data, max_stack);
37 return 0;
38}