Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Extract common API out of unwind-libunwind-local.c

This patch extracts common unwind-libunwind APIs out of
unwind-libunwind-local.c, this part will be used by both local and
remote libunwind.

Signed-off-by: He Kuang <hekuang@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1464924803-22214-9-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

He Kuang and committed by
Arnaldo Carvalho de Melo
f6d72532 a597b547

+39 -34
+1
tools/perf/util/Build
··· 100 100 101 101 libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o 102 102 libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind-local.o 103 + libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o 103 104 104 105 libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o 105 106
-34
tools/perf/util/unwind-libunwind-local.c
··· 691 691 692 692 struct unwind_libunwind_ops * 693 693 local_unwind_libunwind_ops = &_unwind_libunwind_ops; 694 - 695 - static void unwind__register_ops(struct thread *thread, 696 - struct unwind_libunwind_ops *ops) 697 - { 698 - thread->unwind_libunwind_ops = ops; 699 - } 700 - 701 - int unwind__prepare_access(struct thread *thread) 702 - { 703 - unwind__register_ops(thread, local_unwind_libunwind_ops); 704 - 705 - return thread->unwind_libunwind_ops->prepare_access(thread); 706 - } 707 - 708 - void unwind__flush_access(struct thread *thread) 709 - { 710 - if (thread->unwind_libunwind_ops) 711 - thread->unwind_libunwind_ops->flush_access(thread); 712 - } 713 - 714 - void unwind__finish_access(struct thread *thread) 715 - { 716 - if (thread->unwind_libunwind_ops) 717 - thread->unwind_libunwind_ops->finish_access(thread); 718 - } 719 - 720 - int unwind__get_entries(unwind_entry_cb_t cb, void *arg, 721 - struct thread *thread, 722 - struct perf_sample *data, int max_stack) 723 - { 724 - if (thread->unwind_libunwind_ops) 725 - return thread->unwind_libunwind_ops->get_entries(cb, arg, thread, data, max_stack); 726 - return 0; 727 - }
+38
tools/perf/util/unwind-libunwind.c
··· 1 + #include "unwind.h" 2 + #include "thread.h" 3 + 4 + struct unwind_libunwind_ops __weak *local_unwind_libunwind_ops; 5 + 6 + static void unwind__register_ops(struct thread *thread, 7 + struct unwind_libunwind_ops *ops) 8 + { 9 + thread->unwind_libunwind_ops = ops; 10 + } 11 + 12 + int 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 + 19 + void unwind__flush_access(struct thread *thread) 20 + { 21 + if (thread->unwind_libunwind_ops) 22 + thread->unwind_libunwind_ops->flush_access(thread); 23 + } 24 + 25 + void unwind__finish_access(struct thread *thread) 26 + { 27 + if (thread->unwind_libunwind_ops) 28 + thread->unwind_libunwind_ops->finish_access(thread); 29 + } 30 + 31 + int 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 + }