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 maps *maps, struct unwind_libunwind_ops *ops)
17 RC_CHK_ACCESS(maps)->unwind_libunwind_ops = ops;
20 int unwind__prepare_access(struct maps *maps, struct map *map, bool *initialized)
23 enum dso_type dso_type;
24 struct unwind_libunwind_ops *ops = local_unwind_libunwind_ops;
25 struct dso *dso = map__dso(map);
26 struct machine *machine;
29 if (!dwarf_callchain_users)
32 if (maps__addr_space(maps)) {
33 pr_debug("unwind: thread map already set, dso=%s\n", dso->name);
39 machine = maps__machine(maps);
40 /* env->arch is NULL for live-mode (i.e. perf top) */
41 if (!machine->env || !machine->env->arch)
44 dso_type = dso__type(dso, machine);
45 if (dso_type == DSO__TYPE_UNKNOWN)
48 arch = perf_env__arch(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_warning_once("unwind: target platform=%s is not supported\n", arch);
63 unwind__register_ops(maps, ops);
65 err = maps__unwind_libunwind_ops(maps)->prepare_access(maps);
67 *initialized = err ? false : true;
71 void unwind__flush_access(struct maps *maps)
73 const struct unwind_libunwind_ops *ops = maps__unwind_libunwind_ops(maps);
76 ops->flush_access(maps);
79 void unwind__finish_access(struct maps *maps)
81 const struct unwind_libunwind_ops *ops = maps__unwind_libunwind_ops(maps);
84 ops->finish_access(maps);
87 int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
88 struct thread *thread,
89 struct perf_sample *data, int max_stack,
92 const struct unwind_libunwind_ops *ops = maps__unwind_libunwind_ops(thread__maps(thread));
95 return ops->get_entries(cb, arg, thread, data, max_stack, best_effort);