1 // SPDX-License-Identifier: GPL-2.0
11 struct unwind_libunwind_ops __weak *local_unwind_libunwind_ops;
12 struct unwind_libunwind_ops __weak *x86_32_unwind_libunwind_ops;
13 struct unwind_libunwind_ops __weak *arm64_unwind_libunwind_ops;
15 static void unwind__register_ops(struct map_groups *mg,
16 struct unwind_libunwind_ops *ops)
18 mg->unwind_libunwind_ops = ops;
21 int unwind__prepare_access(struct map_groups *mg, struct map *map,
25 enum dso_type dso_type;
26 struct unwind_libunwind_ops *ops = local_unwind_libunwind_ops;
29 if (!dwarf_callchain_users)
33 pr_debug("unwind: thread map already set, dso=%s\n",
40 /* env->arch is NULL for live-mode (i.e. perf top) */
41 if (!mg->machine->env || !mg->machine->env->arch)
44 dso_type = dso__type(map->dso, mg->machine);
45 if (dso_type == DSO__TYPE_UNKNOWN)
48 arch = perf_env__arch(mg->machine->env);
50 if (!strcmp(arch, "x86")) {
51 if (dso_type != DSO__TYPE_64BIT)
52 ops = x86_32_unwind_libunwind_ops;
53 } else if (!strcmp(arch, "arm64") || !strcmp(arch, "arm")) {
54 if (dso_type == DSO__TYPE_64BIT)
55 ops = arm64_unwind_libunwind_ops;
59 pr_err("unwind: target platform=%s is not supported\n", arch);
63 unwind__register_ops(mg, ops);
65 err = mg->unwind_libunwind_ops->prepare_access(mg);
67 *initialized = err ? false : true;
71 void unwind__flush_access(struct map_groups *mg)
73 if (mg->unwind_libunwind_ops)
74 mg->unwind_libunwind_ops->flush_access(mg);
77 void unwind__finish_access(struct map_groups *mg)
79 if (mg->unwind_libunwind_ops)
80 mg->unwind_libunwind_ops->finish_access(mg);
83 int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
84 struct thread *thread,
85 struct perf_sample *data, int max_stack)
87 if (thread->mg->unwind_libunwind_ops)
88 return thread->mg->unwind_libunwind_ops->get_entries(cb, arg, thread, data, max_stack);