1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef PERF_LIBDW_H 3 #define PERF_LIBDW_H 4 5 #include <linux/types.h> 6 7 struct dso; 8 struct inline_node; 9 struct symbol; 10 11 #ifdef HAVE_LIBDW_SUPPORT 12 /* 13 * libdw__addr2line - Convert address to source location using libdw 14 * @dso_name: Name of the DSO 15 * @addr: Address to resolve 16 * @file: Pointer to return filename (caller must free) 17 * @line_nr: Pointer to return line number 18 * @dso: The dso struct 19 * @unwind_inlines: Whether to unwind inline function calls 20 * @node: Inline node list to append to 21 * @sym: The symbol associated with the address 22 * 23 * This function initializes a Dwfl context for the DSO if not already present, 24 * finds the source line information for the given address, and optionally 25 * resolves inline function call chains. 26 * 27 * Returns 1 on success (found), 0 on failure (not found). 28 */ 29 int libdw__addr2line(const char *dso_name, u64 addr, char **file, 30 unsigned int *line_nr, struct dso *dso, 31 bool unwind_inlines, struct inline_node *node, 32 struct symbol *sym); 33 34 /* 35 * dso__free_a2l_libdw - Free libdw resources associated with the DSO 36 * @dso: The dso to free resources for 37 * 38 * This function cleans up the Dwfl context used for addr2line lookups. 39 */ 40 void dso__free_a2l_libdw(struct dso *dso); 41 42 #else /* HAVE_LIBDW_SUPPORT */ 43 44 static inline int libdw__addr2line(const char *dso_name __maybe_unused, 45 u64 addr __maybe_unused, char **file __maybe_unused, 46 unsigned int *line_nr __maybe_unused, 47 struct dso *dso __maybe_unused, 48 bool unwind_inlines __maybe_unused, 49 struct inline_node *node __maybe_unused, 50 struct symbol *sym __maybe_unused) 51 { 52 return 0; 53 } 54 55 static inline void dso__free_a2l_libdw(struct dso *dso __maybe_unused) 56 { 57 } 58 #endif /* HAVE_LIBDW_SUPPORT */ 59 60 #endif /* PERF_LIBDW_H */ 61