blob: f86f903ae8a8d44e968f8b344b0d05f25f485d2f [file] [log] [blame]
He Kuangf6d72532016-06-03 03:33:17 +00001#include "unwind.h"
2#include "thread.h"
3
4struct unwind_libunwind_ops __weak *local_unwind_libunwind_ops;
5
6static void unwind__register_ops(struct thread *thread,
7 struct unwind_libunwind_ops *ops)
8{
9 thread->unwind_libunwind_ops = ops;
10}
11
12int unwind__prepare_access(struct thread *thread)
13{
14 unwind__register_ops(thread, local_unwind_libunwind_ops);
15
16 return thread->unwind_libunwind_ops->prepare_access(thread);
17}
18
19void unwind__flush_access(struct thread *thread)
20{
21 if (thread->unwind_libunwind_ops)
22 thread->unwind_libunwind_ops->flush_access(thread);
23}
24
25void unwind__finish_access(struct thread *thread)
26{
27 if (thread->unwind_libunwind_ops)
28 thread->unwind_libunwind_ops->finish_access(thread);
29}
30
31int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
32 struct thread *thread,
33 struct perf_sample *data, int max_stack)
34{
35 if (thread->unwind_libunwind_ops)
36 return thread->unwind_libunwind_ops->get_entries(cb, arg, thread, data, max_stack);
37 return 0;
38}