Lines Matching +full:on +full:- +full:die
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * dwarf-aux.c : libdw auxiliary interfaces
11 #include "dwarf-aux.h"
16 * cu_find_realpath - Find the realpath of the target file
17 * @cu_die: A DIE(dwarf information entry) of CU(compilation Unit)
47 * cu_get_comp_dir - Get the path of compilation directory
48 * @cu_die: a CU DIE
51 * Since this depends on DW_AT_comp_dir, older gcc will not
76 l = 0; u = nlines - 1; in cu_getsrc_die()
78 n = u - (u - l) / 2; in cu_getsrc_die()
83 u = n - 1; in cu_getsrc_die()
89 line = dwarf_onesrcline(lines, --l); in cu_getsrc_die()
108 * cu_find_lineinfo - Get a line number and file name for given address
109 * @cu_die: a CU DIE
140 return (*lineno && *fname) ? *lineno : -ENOENT; in cu_find_lineinfo()
146 * cu_walk_functions_at - Walk on function DIEs at given address
147 * @cu_die: A CU DIE
152 * Walk on function DIEs at given @addr in @cu_die. Passed DIEs
153 * should be subprogram or inlined-subroutines.
160 int ret = -ENOENT; in cu_walk_functions_at()
177 * die_get_linkage_name - Get the linkage name of the object
178 * @dw_die: A DIE of the object
193 * die_compare_name - Compare diename and tname
194 * @dw_die: a DIE
208 * die_match_name - Match diename/linkage name and glob
209 * @dw_die: a DIE
231 * die_get_call_lineno - Get callsite line number of inline-function instance
232 * @in_die: a DIE of an inlined function instance
234 * Get call-site line number of @in_die. This means from where the inline
243 return -ENOENT; in die_get_call_lineno()
250 * die_get_type - Get type DIE
251 * @vr_die: a DIE of a variable
252 * @die_mem: where to store a type DIE
254 * Get a DIE of the type of given variable (@vr_die), and store
255 * it to die_mem. Return NULL if fails to get a type DIE.
268 /* Get a type die, but skip qualifiers */
287 * die_get_real_type - Get a type die, but skip qualifiers and typedef
288 * @vr_die: a DIE of a variable
289 * @die_mem: where to store a type DIE
291 * Get a DIE of the type of given variable (@vr_die), and store
292 * it to die_mem. Return NULL if fails to get a type DIE.
313 return -ENOENT; in die_get_attr_udata()
319 * die_is_signed_type - Check whether a type DIE is signed or not
320 * @tp_die: a DIE of a type
337 * die_is_func_def - Ensure that this DIE is a subprogram and definition
338 * @dw_die: a DIE
340 * Ensure that this DIE is a subprogram and NOT a declaration. This
357 * So we need to check this subprogram DIE has DW_AT_inline in die_is_func_def()
368 * die_entrypc - Returns entry PC (the lowest address) of a DIE
369 * @dw_die: a DIE
372 * Since dwarf_entrypc() does not return entry PC if the DIE has only address
382 return -EINVAL; in die_entrypc()
392 return -ENOENT; in die_entrypc()
394 return dwarf_ranges(dw_die, 0, &base, addr, &end) < 0 ? -ENOENT : 0; in die_entrypc()
398 * die_is_func_instance - Ensure that this DIE is an instance of a subprogram
399 * @dw_die: a DIE
401 * Ensure that this DIE is an instance (which has an entry address).
421 * die_get_data_member_location - Get the data-member offset
422 * @mb_die: a DIE of a member of a data structure
436 return -ENOENT; in die_get_data_member_location()
442 return -ENOENT; in die_get_data_member_location()
447 return -ENOTSUP; in die_get_data_member_location()
454 /* Get the call file index number in CU DIE */
462 return -ENOENT; in die_get_call_fileno()
465 /* Get the declared file index number in CU DIE */
473 return -ENOENT; in die_get_decl_fileno()
492 * die_get_call_file - Get callsite file name of inlined function instance
493 * @in_die: a DIE of an inlined function instance
495 * Get call-site file name of @in_die. This means from which file the inline
504 * die_get_decl_file - Find the declared file name of this DIE
505 * @dw_die: a DIE for something declared.
518 * die_find_child - Generic DIE search function in DIE tree
519 * @rt_die: a root DIE
522 * @die_mem: a buffer for result DIE
524 * Trace DIE tree from @rt_die and call @callback for each child DIE.
525 * If @callback returns DIE_FIND_CB_END, this stores the DIE into
530 * Returns NULL if @callback can't find any appropriate DIE.
571 addr == ad->addr) { in __die_search_func_tail_cb()
572 memcpy(ad->die_mem, fn_die, sizeof(Dwarf_Die)); in __die_search_func_tail_cb()
579 * die_find_tailfunc - Search for a non-inlined function with tail call at
581 * @cu_die: a CU DIE which including @addr
583 * @die_mem: a buffer for result DIE
585 * Search for a non-inlined function DIE with tail call at @addr. Stores the
586 * DIE to @die_mem and returns it if found. Returns NULL if failed.
601 /* die_find callback for non-inlined function search */
611 dwarf_haspc(fn_die, ad->addr)) { in __die_search_func_cb()
612 memcpy(ad->die_mem, fn_die, sizeof(Dwarf_Die)); in __die_search_func_cb()
619 * die_find_realfunc - Search a non-inlined function at given address
620 * @cu_die: a CU DIE which including @addr
622 * @die_mem: a buffer for result DIE
624 * Search a non-inlined function DIE which includes @addr. Stores the
625 * DIE to @die_mem and returns it if found. Returns NULL if failed.
653 * die_find_top_inlinefunc - Search the top inlined function at given address
654 * @sp_die: a subprogram DIE which including @addr
656 * @die_mem: a buffer for result DIE
658 * Search an inlined function DIE which includes @addr. Stores the
659 * DIE to @die_mem and returns it if found. Returns NULL if failed.
670 * die_find_inlinefunc - Search an inlined function at given address
671 * @sp_die: a subprogram DIE which including @addr
673 * @die_mem: a buffer for result DIE
675 * Search an inlined function DIE which includes @addr. Stores the
676 * DIE to @die_mem and returns it if found. Returns NULL if failed.
723 if (origin == NULL || origin->addr != iwp->addr) in __die_walk_instances_cb()
736 iwp->retval = iwp->callback(inst, iwp->data); in __die_walk_instances_cb()
738 return (iwp->retval) ? DIE_FIND_CB_END : DIE_FIND_CB_CONTINUE; in __die_walk_instances_cb()
742 * die_walk_instances - Walk on instances of given DIE
743 * @or_die: an abstract original DIE
744 * @callback: a callback function which is called with instance DIE
747 * Walk on the instances of give @in_die. @in_die must be an inlined function
749 * non-zero value, or -ENOENT if there is no instance.
757 .addr = or_die->addr, in die_walk_instances()
760 .retval = -ENOENT, in die_walk_instances()
764 return -ENOENT; in die_walk_instances()
790 lw->retval = lw->callback(fname, lineno, addr, lw->data); in __die_walk_funclines_cb()
791 if (lw->retval != 0) in __die_walk_funclines_cb()
794 if (!lw->recursive) in __die_walk_funclines_cb()
801 lw->retval = lw->callback(fname, lineno, addr, lw->data); in __die_walk_funclines_cb()
802 if (lw->retval != 0) in __die_walk_funclines_cb()
807 /* Continue to search nested inlined function call-sites */ in __die_walk_funclines_cb()
811 /* Walk on lines of blocks included in given DIE */
847 lw->retval = __die_walk_funclines(sp_die, true, lw->callback, lw->data); in __die_walk_culines_cb()
848 if (lw->retval != 0) in __die_walk_culines_cb()
855 * die_walk_lines - Walk on lines inside given DIE
856 * @rt_die: a root DIE (CU, subprogram or inlined_subroutine)
860 * Walk on all lines inside given @rt_die and call @callback on each line.
861 * If the @rt_die is a function, walk only on the lines inside the function,
862 * otherwise @rt_die must be a CU DIE.
864 * and inline call-site.
878 /* Get the CU die */ in die_walk_lines()
886 return -EINVAL; in die_walk_lines()
891 pr_debug2("Failed to get CU from given DIE.\n"); in die_walk_lines()
892 return -EINVAL; in die_walk_lines()
897 pr_debug2("Failed to get source lines on this CU.\n"); in die_walk_lines()
898 return -ENOENT; in die_walk_lines()
902 /* Walk on the lines on lines list */ in die_walk_lines()
912 /* Skip end-of-sequence */ in die_walk_lines()
915 /* Skip Non statement line-info */ in die_walk_lines()
918 /* Filter lines based on address */ in die_walk_lines()
929 /* Call-site check */ in die_walk_lines()
988 die_compare_name(die_mem, fvp->name) && in __die_find_variable_cb()
990 * Does the DIE have location information or const value in __die_find_variable_cb()
997 if (dwarf_haspc(die_mem, fvp->addr)) in __die_find_variable_cb()
1004 * die_find_variable_at - Find a given name variable at given address
1005 * @sp_die: a function DIE
1008 * @die_mem: a buffer for result DIE
1010 * Find a variable DIE called @name at @addr in @sp_die.
1039 * die_find_member - Find a given name member in a data structure
1040 * @st_die: a data structure type DIE
1042 * @die_mem: a buffer for result DIE
1044 * Find a member DIE called @name in @st_die.
1054 * die_get_typename - Get the name of given variable DIE
1055 * @vr_die: a variable DIE
1059 * and Return -ENOENT if failed to find type name.
1070 return -ENOENT; in die_get_typename()
1088 return -ENOENT; in die_get_typename()
1097 * die_get_varname - Get the name and type of given variable DIE
1098 * @vr_die: a variable DIE
1118 * die_get_var_innermost_scope - Get innermost scope range of given variable DIE
1119 * @sp_die: a subprogram DIE
1120 * @vr_die: a variable DIE
1124 * "@<function_name+[NN-NN,NN-NN]>".
1145 return -ENOENT; in die_get_var_innermost_scope()
1149 /* (*SCOPES)[1] is the DIE for the scope containing that scope */ in die_get_var_innermost_scope()
1151 ret = -EINVAL; in die_get_var_innermost_scope()
1157 start -= entry; in die_get_var_innermost_scope()
1158 end -= entry; in die_get_var_innermost_scope()
1161 ret = strbuf_addf(buf, "@<%s+[%" PRIu64 "-%" PRIu64, in die_get_var_innermost_scope()
1165 ret = strbuf_addf(buf, ",%" PRIu64 "-%" PRIu64, in die_get_var_innermost_scope()
1181 * die_get_var_range - Get byte offset range of given variable DIE
1182 * @sp_die: a subprogram DIE
1183 * @vr_die: a variable DIE
1187 * "@<function_name+[NN-NN,NN-NN]>".
1208 return -ENOENT; in die_get_var_range()
1211 return -EINVAL; in die_get_var_range()
1222 start -= entry; in die_get_var_range()
1223 end -= entry; in die_get_var_range()
1225 ret = strbuf_addf(buf, "@<%s+[%" PRIu64 "-%" PRIu64, in die_get_var_range()
1229 ret = strbuf_addf(buf, ",%" PRIu64 "-%" PRIu64, in die_get_var_range()
1246 return -ENOTSUP; in die_get_var_range()
1251 * die_has_loclist - Check if DW_AT_location of @vr_die is a location list
1252 * @vr_die: a variable DIE
1268 * die_is_optimized_target - Check if target program is compiled with
1270 * @cu_die: a CU DIE
1295 * die_search_idx - Search index of given line address
1325 * die_get_postprologue_addr - Search next address after function prologue
1332 * Look for prologue-end marker. If there is no explicit marker, return
1364 /* clang supports prologue-end marker */ in die_get_postprologue_addr()
1386 dwarf_lineaddr(dwarf_onesrcline(lines, i - 1), in die_get_postprologue_addr()
1393 * die_skip_prologue - Use next address after prologue as probe location
1394 * @sp_die: a subprogram DIE
1395 * @cu_die: a CU DIE