1 /* SPDX-License-Identifier: GPL-2.0-or-later * 1 2 #ifndef _DWARF_AUX_H 3 #define _DWARF_AUX_H 4 /* 5 * dwarf-aux.h : libdw auxiliary interfaces 6 */ 7 8 #include <dwarf.h> 9 #include <elfutils/libdw.h> 10 #include <elfutils/libdwfl.h> 11 #include <elfutils/version.h> 12 #include <errno.h> 13 14 struct strbuf; 15 16 /* Find the realpath of the target file */ 17 const char *cu_find_realpath(Dwarf_Die *cu_die 18 19 /* Get DW_AT_comp_dir (should be NULL with old 20 const char *cu_get_comp_dir(Dwarf_Die *cu_die) 21 22 /* Get a line number and file name for given a 23 int cu_find_lineinfo(Dwarf_Die *cudie, Dwarf_A 24 const char **fname, int * 25 26 /* Walk on functions at given address */ 27 int cu_walk_functions_at(Dwarf_Die *cu_die, Dw 28 int (*callback)(Dwarf 29 30 /* Get DW_AT_linkage_name (should be NULL for 31 const char *die_get_linkage_name(Dwarf_Die *dw 32 33 /* Get the lowest PC in DIE (including range l 34 int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr 35 36 /* Ensure that this DIE is a subprogram and de 37 bool die_is_func_def(Dwarf_Die *dw_die); 38 39 /* Ensure that this DIE is an instance of a su 40 bool die_is_func_instance(Dwarf_Die *dw_die); 41 42 /* Compare diename and tname */ 43 bool die_compare_name(Dwarf_Die *dw_die, const 44 45 /* Matching diename with glob pattern */ 46 bool die_match_name(Dwarf_Die *dw_die, const c 47 48 /* Get callsite line number of inline-function 49 int die_get_call_lineno(Dwarf_Die *in_die); 50 51 /* Get callsite file name of inlined function 52 const char *die_get_call_file(Dwarf_Die *in_di 53 54 /* Get declared file name of a DIE */ 55 const char *die_get_decl_file(Dwarf_Die *dw_di 56 57 /* Get type die */ 58 Dwarf_Die *die_get_type(Dwarf_Die *vr_die, Dwa 59 60 /* Get a type die, but skip qualifiers */ 61 Dwarf_Die *__die_get_real_type(Dwarf_Die *vr_d 62 /* Get a type die, but skip qualifiers and typ 63 Dwarf_Die *die_get_real_type(Dwarf_Die *vr_die 64 65 /* Check whether the DIE is signed or not */ 66 bool die_is_signed_type(Dwarf_Die *tp_die); 67 68 /* Get data_member_location offset */ 69 int die_get_data_member_location(Dwarf_Die *mb 70 71 /* Return values for die_find_child() callback 72 enum { 73 DIE_FIND_CB_END = 0, /* End 74 DIE_FIND_CB_CHILD = 1, /* Sea 75 DIE_FIND_CB_SIBLING = 2, /* Sea 76 DIE_FIND_CB_CONTINUE = 3, /* Sea 77 }; 78 79 /* Search child DIEs */ 80 Dwarf_Die *die_find_child(Dwarf_Die *rt_die, 81 int (*callback)(Dwarf 82 void *data, Dwarf_Die 83 84 /* Search a non-inlined function including giv 85 Dwarf_Die *die_find_realfunc(Dwarf_Die *cu_die 86 Dwarf_Die *die_me 87 88 /* Search a non-inlined function with tail cal 89 Dwarf_Die *die_find_tailfunc(Dwarf_Die *cu_die 90 Dwarf_Die 91 92 /* Search the top inlined function including g 93 Dwarf_Die *die_find_top_inlinefunc(Dwarf_Die * 94 Dwarf_Die * 95 96 /* Search the deepest inlined function includi 97 Dwarf_Die *die_find_inlinefunc(Dwarf_Die *sp_d 98 Dwarf_Die *die_ 99 100 /* Search a non-inlined function by name and r 101 Dwarf_Die *die_find_func_rettype(Dwarf_Die *sp 102 Dwarf_Die *di 103 104 /* Walk on the instances of given DIE */ 105 int die_walk_instances(Dwarf_Die *in_die, 106 int (*callback)(Dwarf_D 107 108 /* Walker on lines (Note: line number will not 109 typedef int (* line_walk_callback_t) (const ch 110 Dwarf_Ad 111 112 /* 113 * Walk on lines inside given DIE. If the DIE 114 * the lines inside the subprogram, otherwise 115 */ 116 int die_walk_lines(Dwarf_Die *rt_die, line_wal 117 118 /* Find a variable called 'name' at given addr 119 Dwarf_Die *die_find_variable_at(Dwarf_Die *sp_ 120 Dwarf_Addr add 121 122 /* Find a member called 'name' */ 123 Dwarf_Die *die_find_member(Dwarf_Die *st_die, 124 Dwarf_Die *die_mem) 125 126 /* Get the name of given type DIE */ 127 int die_get_typename_from_type(Dwarf_Die *type 128 129 /* Get the name of given variable DIE */ 130 int die_get_typename(Dwarf_Die *vr_die, struct 131 132 /* Get the name and type of given variable DIE 133 int die_get_varname(Dwarf_Die *vr_die, struct 134 135 /* Check if target program is compiled with op 136 bool die_is_optimized_target(Dwarf_Die *cu_die 137 138 /* Use next address after prologue as probe lo 139 void die_skip_prologue(Dwarf_Die *sp_die, Dwar 140 Dwarf_Addr *entrypc); 141 142 /* Get the list of including scopes */ 143 int die_get_scopes(Dwarf_Die *cu_die, Dwarf_Ad 144 145 /* Variable type information */ 146 struct die_var_type { 147 struct die_var_type *next; 148 u64 die_off; 149 u64 addr; 150 int reg; 151 int offset; 152 }; 153 154 /* Return type info of a member at offset */ 155 Dwarf_Die *die_get_member_type(Dwarf_Die *type 156 157 /* Return type info where the pointer and offs 158 Dwarf_Die *die_deref_ptr_type(Dwarf_Die *ptr_d 159 160 #ifdef HAVE_DWARF_GETLOCATIONS_SUPPORT 161 162 /* Get byte offset range of given variable DIE 163 int die_get_var_range(Dwarf_Die *sp_die, Dwarf 164 165 /* Find a variable saved in the 'reg' at given 166 Dwarf_Die *die_find_variable_by_reg(Dwarf_Die 167 int *poffs 168 Dwarf_Die 169 170 /* Find a (global) variable located in the 'ad 171 Dwarf_Die *die_find_variable_by_addr(Dwarf_Die 172 Dwarf_Die 173 174 /* Save all variables and parameters in this s 175 void die_collect_vars(Dwarf_Die *sc_die, struc 176 177 /* Save all global variables in this CU */ 178 void die_collect_global_vars(Dwarf_Die *cu_die 179 180 #else /* HAVE_DWARF_GETLOCATIONS_SUPPORT */ 181 182 static inline int die_get_var_range(Dwarf_Die 183 Dwarf_Die 184 struct str 185 { 186 return -ENOTSUP; 187 } 188 189 static inline Dwarf_Die *die_find_variable_by_ 190 191 192 193 194 195 { 196 return NULL; 197 } 198 199 static inline Dwarf_Die *die_find_variable_by_ 200 201 202 203 { 204 return NULL; 205 } 206 207 static inline void die_collect_vars(Dwarf_Die 208 struct die 209 { 210 } 211 212 static inline void die_collect_global_vars(Dwa 213 str 214 { 215 } 216 217 #endif /* HAVE_DWARF_GETLOCATIONS_SUPPORT */ 218 219 #ifdef HAVE_DWARF_CFI_SUPPORT 220 221 /* Get the frame base information from CFA */ 222 int die_get_cfa(Dwarf *dwarf, u64 pc, int *pre 223 224 #else /* HAVE_DWARF_CFI_SUPPORT */ 225 226 static inline int die_get_cfa(Dwarf *dwarf __m 227 int *preg __mayb 228 { 229 return -1; 230 } 231 232 #endif /* HAVE_DWARF_CFI_SUPPORT */ 233 234 #endif /* _DWARF_AUX_H */ 235
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.