5 #include "arch/common.h"
7 struct unwind_libunwind_ops __weak *local_unwind_libunwind_ops;
8 struct unwind_libunwind_ops __weak *x86_32_unwind_libunwind_ops;
9 struct unwind_libunwind_ops __weak *arm64_unwind_libunwind_ops;
11 static void unwind__register_ops(struct thread *thread,
12 struct unwind_libunwind_ops *ops)
14 thread->unwind_libunwind_ops = ops;
17 int unwind__prepare_access(struct thread *thread, struct map *map)
20 enum dso_type dso_type;
21 struct unwind_libunwind_ops *ops = local_unwind_libunwind_ops;
23 if (thread->addr_space) {
24 pr_debug("unwind: thread map already set, dso=%s\n",
29 /* env->arch is NULL for live-mode (i.e. perf top) */
30 if (!thread->mg->machine->env || !thread->mg->machine->env->arch)
33 dso_type = dso__type(map->dso, thread->mg->machine);
34 if (dso_type == DSO__TYPE_UNKNOWN)
37 arch = normalize_arch(thread->mg->machine->env->arch);
39 if (!strcmp(arch, "x86")) {
40 if (dso_type != DSO__TYPE_64BIT)
41 ops = x86_32_unwind_libunwind_ops;
42 } else if (!strcmp(arch, "arm64") || !strcmp(arch, "arm")) {
43 if (dso_type == DSO__TYPE_64BIT)
44 ops = arm64_unwind_libunwind_ops;
48 pr_err("unwind: target platform=%s is not supported\n", arch);
52 unwind__register_ops(thread, ops);
54 return thread->unwind_libunwind_ops->prepare_access(thread);
57 void unwind__flush_access(struct thread *thread)
59 if (thread->unwind_libunwind_ops)
60 thread->unwind_libunwind_ops->flush_access(thread);
63 void unwind__finish_access(struct thread *thread)
65 if (thread->unwind_libunwind_ops)
66 thread->unwind_libunwind_ops->finish_access(thread);
69 int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
70 struct thread *thread,
71 struct perf_sample *data, int max_stack)
73 if (thread->unwind_libunwind_ops)
74 return thread->unwind_libunwind_ops->get_entries(cb, arg, thread, data, max_stack);