1 // SPDX-License-Identifier: GPL-2.0
10 struct unwind_libunwind_ops __weak
*local_unwind_libunwind_ops
;
11 struct unwind_libunwind_ops __weak
*x86_32_unwind_libunwind_ops
;
12 struct unwind_libunwind_ops __weak
*arm64_unwind_libunwind_ops
;
14 static void unwind__register_ops(struct thread
*thread
,
15 struct unwind_libunwind_ops
*ops
)
17 thread
->unwind_libunwind_ops
= ops
;
20 int unwind__prepare_access(struct thread
*thread
, struct map
*map
,
24 enum dso_type dso_type
;
25 struct unwind_libunwind_ops
*ops
= local_unwind_libunwind_ops
;
28 if (!dwarf_callchain_users
)
31 if (thread
->addr_space
) {
32 pr_debug("unwind: thread map already set, dso=%s\n",
39 /* env->arch is NULL for live-mode (i.e. perf top) */
40 if (!thread
->mg
->machine
->env
|| !thread
->mg
->machine
->env
->arch
)
43 dso_type
= dso__type(map
->dso
, thread
->mg
->machine
);
44 if (dso_type
== DSO__TYPE_UNKNOWN
)
47 arch
= perf_env__arch(thread
->mg
->machine
->env
);
49 if (!strcmp(arch
, "x86")) {
50 if (dso_type
!= DSO__TYPE_64BIT
)
51 ops
= x86_32_unwind_libunwind_ops
;
52 } else if (!strcmp(arch
, "arm64") || !strcmp(arch
, "arm")) {
53 if (dso_type
== DSO__TYPE_64BIT
)
54 ops
= arm64_unwind_libunwind_ops
;
58 pr_err("unwind: target platform=%s is not supported\n", arch
);
62 unwind__register_ops(thread
, ops
);
64 err
= thread
->unwind_libunwind_ops
->prepare_access(thread
);
66 *initialized
= err
? false : true;
70 void unwind__flush_access(struct thread
*thread
)
72 if (!dwarf_callchain_users
)
75 if (thread
->unwind_libunwind_ops
)
76 thread
->unwind_libunwind_ops
->flush_access(thread
);
79 void unwind__finish_access(struct thread
*thread
)
81 if (!dwarf_callchain_users
)
84 if (thread
->unwind_libunwind_ops
)
85 thread
->unwind_libunwind_ops
->finish_access(thread
);
88 int unwind__get_entries(unwind_entry_cb_t cb
, void *arg
,
89 struct thread
*thread
,
90 struct perf_sample
*data
, int max_stack
)
92 if (thread
->unwind_libunwind_ops
)
93 return thread
->unwind_libunwind_ops
->get_entries(cb
, arg
, thread
, data
, max_stack
);