1 // SPDX-License-Identifier: GPL-2.0
9 struct unwind_libunwind_ops __weak
*local_unwind_libunwind_ops
;
10 struct unwind_libunwind_ops __weak
*x86_32_unwind_libunwind_ops
;
11 struct unwind_libunwind_ops __weak
*arm64_unwind_libunwind_ops
;
13 static void unwind__register_ops(struct thread
*thread
,
14 struct unwind_libunwind_ops
*ops
)
16 thread
->unwind_libunwind_ops
= ops
;
19 int unwind__prepare_access(struct thread
*thread
, struct map
*map
,
23 enum dso_type dso_type
;
24 struct unwind_libunwind_ops
*ops
= local_unwind_libunwind_ops
;
27 if (thread
->addr_space
) {
28 pr_debug("unwind: thread map already set, dso=%s\n",
35 /* env->arch is NULL for live-mode (i.e. perf top) */
36 if (!thread
->mg
->machine
->env
|| !thread
->mg
->machine
->env
->arch
)
39 dso_type
= dso__type(map
->dso
, thread
->mg
->machine
);
40 if (dso_type
== DSO__TYPE_UNKNOWN
)
43 arch
= perf_env__arch(thread
->mg
->machine
->env
);
45 if (!strcmp(arch
, "x86")) {
46 if (dso_type
!= DSO__TYPE_64BIT
)
47 ops
= x86_32_unwind_libunwind_ops
;
48 } else if (!strcmp(arch
, "arm64") || !strcmp(arch
, "arm")) {
49 if (dso_type
== DSO__TYPE_64BIT
)
50 ops
= arm64_unwind_libunwind_ops
;
54 pr_err("unwind: target platform=%s is not supported\n", arch
);
58 unwind__register_ops(thread
, ops
);
60 err
= thread
->unwind_libunwind_ops
->prepare_access(thread
);
62 *initialized
= err
? false : true;
66 void unwind__flush_access(struct thread
*thread
)
68 if (thread
->unwind_libunwind_ops
)
69 thread
->unwind_libunwind_ops
->flush_access(thread
);
72 void unwind__finish_access(struct thread
*thread
)
74 if (thread
->unwind_libunwind_ops
)
75 thread
->unwind_libunwind_ops
->finish_access(thread
);
78 int unwind__get_entries(unwind_entry_cb_t cb
, void *arg
,
79 struct thread
*thread
,
80 struct perf_sample
*data
, int max_stack
)
82 if (thread
->unwind_libunwind_ops
)
83 return thread
->unwind_libunwind_ops
->get_entries(cb
, arg
, thread
, data
, max_stack
);