1 // SPDX-License-Identifier: GPL-2.0
8 struct unwind_libunwind_ops __weak
*local_unwind_libunwind_ops
;
9 struct unwind_libunwind_ops __weak
*x86_32_unwind_libunwind_ops
;
10 struct unwind_libunwind_ops __weak
*arm64_unwind_libunwind_ops
;
12 static void unwind__register_ops(struct thread
*thread
,
13 struct unwind_libunwind_ops
*ops
)
15 thread
->unwind_libunwind_ops
= ops
;
18 int unwind__prepare_access(struct thread
*thread
, struct map
*map
,
22 enum dso_type dso_type
;
23 struct unwind_libunwind_ops
*ops
= local_unwind_libunwind_ops
;
26 if (thread
->addr_space
) {
27 pr_debug("unwind: thread map already set, dso=%s\n",
34 /* env->arch is NULL for live-mode (i.e. perf top) */
35 if (!thread
->mg
->machine
->env
|| !thread
->mg
->machine
->env
->arch
)
38 dso_type
= dso__type(map
->dso
, thread
->mg
->machine
);
39 if (dso_type
== DSO__TYPE_UNKNOWN
)
42 arch
= perf_env__arch(thread
->mg
->machine
->env
);
44 if (!strcmp(arch
, "x86")) {
45 if (dso_type
!= DSO__TYPE_64BIT
)
46 ops
= x86_32_unwind_libunwind_ops
;
47 } else if (!strcmp(arch
, "arm64") || !strcmp(arch
, "arm")) {
48 if (dso_type
== DSO__TYPE_64BIT
)
49 ops
= arm64_unwind_libunwind_ops
;
53 pr_err("unwind: target platform=%s is not supported\n", arch
);
57 unwind__register_ops(thread
, ops
);
59 err
= thread
->unwind_libunwind_ops
->prepare_access(thread
);
61 *initialized
= err
? false : true;
65 void unwind__flush_access(struct thread
*thread
)
67 if (thread
->unwind_libunwind_ops
)
68 thread
->unwind_libunwind_ops
->flush_access(thread
);
71 void unwind__finish_access(struct thread
*thread
)
73 if (thread
->unwind_libunwind_ops
)
74 thread
->unwind_libunwind_ops
->finish_access(thread
);
77 int unwind__get_entries(unwind_entry_cb_t cb
, void *arg
,
78 struct thread
*thread
,
79 struct perf_sample
*data
, int max_stack
)
81 if (thread
->unwind_libunwind_ops
)
82 return thread
->unwind_libunwind_ops
->get_entries(cb
, arg
, thread
, data
, max_stack
);