| 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef __PERF_LIBBFD_H |
| 3 | #define __PERF_LIBBFD_H |
| 4 | |
| 5 | #include <linux/compiler.h> |
| 6 | #include <linux/types.h> |
| 7 | #include <stdbool.h> |
| 8 | #include <stddef.h> |
| 9 | |
| 10 | struct annotate_args; |
| 11 | struct build_id; |
| 12 | struct dso; |
| 13 | struct inline_node; |
| 14 | struct symbol; |
| 15 | |
| 16 | #ifdef HAVE_LIBBFD_SUPPORT |
| 17 | int libbfd__addr2line(const char *dso_name, u64 addr, |
| 18 | char **file, unsigned int *line, struct dso *dso, |
| 19 | bool unwind_inlines, struct inline_node *node, |
| 20 | struct symbol *sym); |
| 21 | |
| 22 | |
| 23 | void dso__free_a2l_libbfd(struct dso *dso); |
| 24 | |
| 25 | int symbol__disassemble_libbfd(const char *filename, struct symbol *sym, |
| 26 | struct annotate_args *args); |
| 27 | |
| 28 | int libbfd__read_build_id(const char *filename, struct build_id *bid); |
| 29 | |
| 30 | int libbfd_filename__read_debuglink(const char *filename, char *debuglink, size_t size); |
| 31 | |
| 32 | int symbol__disassemble_bpf_libbfd(struct symbol *sym, struct annotate_args *args); |
| 33 | |
| 34 | #else // !defined(HAVE_LIBBFD_SUPPORT) |
| 35 | #include "annotate.h" |
| 36 | |
| 37 | static inline int libbfd__addr2line(const char *dso_name __always_unused, |
| 38 | u64 addr __always_unused, |
| 39 | char **file __always_unused, |
| 40 | unsigned int *line __always_unused, |
| 41 | struct dso *dso __always_unused, |
| 42 | bool unwind_inlines __always_unused, |
| 43 | struct inline_node *node __always_unused, |
| 44 | struct symbol *sym __always_unused) |
| 45 | { |
| 46 | return -1; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | static inline void dso__free_a2l_libbfd(struct dso *dso __always_unused) |
| 51 | { |
| 52 | } |
| 53 | |
| 54 | static inline int symbol__disassemble_libbfd(const char *filename __always_unused, |
| 55 | struct symbol *sym __always_unused, |
| 56 | struct annotate_args *args __always_unused) |
| 57 | { |
| 58 | return -1; |
| 59 | } |
| 60 | |
| 61 | static inline int libbfd__read_build_id(const char *filename __always_unused, |
| 62 | struct build_id *bid __always_unused) |
| 63 | { |
| 64 | return -1; |
| 65 | } |
| 66 | |
| 67 | static inline int libbfd_filename__read_debuglink(const char *filename __always_unused, |
| 68 | char *debuglink __always_unused, |
| 69 | size_t size __always_unused) |
| 70 | { |
| 71 | return -1; |
| 72 | } |
| 73 | |
| 74 | static inline int symbol__disassemble_bpf_libbfd(struct symbol *sym __always_unused, |
| 75 | struct annotate_args *args __always_unused) |
| 76 | { |
| 77 | return SYMBOL_ANNOTATE_ERRNO__NO_LIBOPCODES_FOR_BPF; |
| 78 | } |
| 79 | |
| 80 | #endif // defined(HAVE_LIBBFD_SUPPORT) |
| 81 | |
| 82 | #endif /* __PERF_LIBBFD_H */ |
| 83 | |