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 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
;
27 if (!dwarf_callchain_users
)
30 if (maps
->addr_space
) {
31 pr_debug("unwind: thread map already set, dso=%s\n",
38 /* env->arch is NULL for live-mode (i.e. perf top) */
39 if (!maps
->machine
->env
|| !maps
->machine
->env
->arch
)
42 dso_type
= dso__type(map
->dso
, maps
->machine
);
43 if (dso_type
== DSO__TYPE_UNKNOWN
)
46 arch
= perf_env__arch(maps
->machine
->env
);
48 if (!strcmp(arch
, "x86")) {
49 if (dso_type
!= DSO__TYPE_64BIT
)
50 ops
= x86_32_unwind_libunwind_ops
;
51 } else if (!strcmp(arch
, "arm64") || !strcmp(arch
, "arm")) {
52 if (dso_type
== DSO__TYPE_64BIT
)
53 ops
= arm64_unwind_libunwind_ops
;
57 pr_err("unwind: target platform=%s is not supported\n", arch
);
61 unwind__register_ops(maps
, ops
);
63 err
= maps
->unwind_libunwind_ops
->prepare_access(maps
);
65 *initialized
= err
? false : true;
69 void unwind__flush_access(struct maps
*maps
)
71 if (maps
->unwind_libunwind_ops
)
72 maps
->unwind_libunwind_ops
->flush_access(maps
);
75 void unwind__finish_access(struct maps
*maps
)
77 if (maps
->unwind_libunwind_ops
)
78 maps
->unwind_libunwind_ops
->finish_access(maps
);
81 int unwind__get_entries(unwind_entry_cb_t cb
, void *arg
,
82 struct thread
*thread
,
83 struct perf_sample
*data
, int max_stack
)
85 if (thread
->maps
->unwind_libunwind_ops
)
86 return thread
->maps
->unwind_libunwind_ops
->get_entries(cb
, arg
, thread
, data
, max_stack
);