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 ?: -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()
326 return -ENOENT; in die_get_attr_sdata()
332 * die_is_signed_type - Check whether a type DIE is signed or not
333 * @tp_die: a DIE of a type
350 * die_is_func_def - Ensure that this DIE is a subprogram and definition
351 * @dw_die: a DIE
353 * Ensure that this DIE is a subprogram and NOT a declaration. This
370 * So we need to check this subprogram DIE has DW_AT_inline in die_is_func_def()
381 * die_entrypc - Returns entry PC (the lowest address) of a DIE
382 * @dw_die: a DIE
385 * Since dwarf_entrypc() does not return entry PC if the DIE has only address
395 return -EINVAL; in die_entrypc()
405 return -ENOENT; in die_entrypc()
407 return dwarf_ranges(dw_die, 0, &base, addr, &end) < 0 ? -ENOENT : 0; in die_entrypc()
411 * die_is_func_instance - Ensure that this DIE is an instance of a subprogram
412 * @dw_die: a DIE
414 * Ensure that this DIE is an instance (which has an entry address).
434 * die_get_data_member_location - Get the data-member offset
435 * @mb_die: a DIE of a member of a data structure
449 return -ENOENT; in die_get_data_member_location()
455 return -ENOENT; in die_get_data_member_location()
460 return -ENOTSUP; in die_get_data_member_location()
467 /* Get the call file index number in CU DIE */
475 return -ENOENT; in die_get_call_fileno()
478 /* Get the declared file index number in CU DIE */
486 return -ENOENT; in die_get_decl_fileno()
490 * die_get_call_file - Get callsite file name of inlined function instance
491 * @in_die: a DIE of an inlined function instance
493 * Get call-site file name of @in_die. This means from which file the inline
512 * die_find_child - Generic DIE search function in DIE tree
513 * @rt_die: a root DIE
516 * @die_mem: a buffer for result DIE
518 * Trace DIE tree from @rt_die and call @callback for each child DIE.
519 * If @callback returns DIE_FIND_CB_END, this stores the DIE into
524 * Returns NULL if @callback can't find any appropriate DIE.
565 addr == ad->addr) { in __die_search_func_tail_cb()
566 memcpy(ad->die_mem, fn_die, sizeof(Dwarf_Die)); in __die_search_func_tail_cb()
573 * die_find_tailfunc - Search for a non-inlined function with tail call at
575 * @cu_die: a CU DIE which including @addr
577 * @die_mem: a buffer for result DIE
579 * Search for a non-inlined function DIE with tail call at @addr. Stores the
580 * DIE to @die_mem and returns it if found. Returns NULL if failed.
595 /* die_find callback for non-inlined function search */
605 dwarf_haspc(fn_die, ad->addr)) { in __die_search_func_cb()
606 memcpy(ad->die_mem, fn_die, sizeof(Dwarf_Die)); in __die_search_func_cb()
613 * die_find_realfunc - Search a non-inlined function at given address
614 * @cu_die: a CU DIE which including @addr
616 * @die_mem: a buffer for result DIE
618 * Search a non-inlined function DIE which includes @addr. Stores the
619 * DIE to @die_mem and returns it if found. Returns NULL if failed.
647 * die_find_top_inlinefunc - Search the top inlined function at given address
648 * @sp_die: a subprogram DIE which including @addr
650 * @die_mem: a buffer for result DIE
652 * Search an inlined function DIE which includes @addr. Stores the
653 * DIE to @die_mem and returns it if found. Returns NULL if failed.
664 * die_find_inlinefunc - Search an inlined function at given address
665 * @sp_die: a subprogram DIE which including @addr
667 * @die_mem: a buffer for result DIE
669 * Search an inlined function DIE which includes @addr. Stores the
670 * DIE to @die_mem and returns it if found. Returns NULL if failed.
717 if (origin == NULL || origin->addr != iwp->addr) in __die_walk_instances_cb()
730 iwp->retval = iwp->callback(inst, iwp->data); in __die_walk_instances_cb()
732 return (iwp->retval) ? DIE_FIND_CB_END : DIE_FIND_CB_CONTINUE; in __die_walk_instances_cb()
736 * die_walk_instances - Walk on instances of given DIE
737 * @or_die: an abstract original DIE
738 * @callback: a callback function which is called with instance DIE
741 * Walk on the instances of give @in_die. @in_die must be an inlined function
743 * non-zero value, or -ENOENT if there is no instance.
751 .addr = or_die->addr, in die_walk_instances()
754 .retval = -ENOENT, in die_walk_instances()
758 return -ENOENT; in die_walk_instances()
784 lw->retval = lw->callback(fname, lineno, addr, lw->data); in __die_walk_funclines_cb()
785 if (lw->retval != 0) in __die_walk_funclines_cb()
788 if (!lw->recursive) in __die_walk_funclines_cb()
795 lw->retval = lw->callback(fname, lineno, addr, lw->data); in __die_walk_funclines_cb()
796 if (lw->retval != 0) in __die_walk_funclines_cb()
801 /* Continue to search nested inlined function call-sites */ in __die_walk_funclines_cb()
805 /* Walk on lines of blocks included in given DIE */
841 lw->retval = __die_walk_funclines(sp_die, true, lw->callback, lw->data); in __die_walk_culines_cb()
842 if (lw->retval != 0) in __die_walk_culines_cb()
849 * die_walk_lines - Walk on lines inside given DIE
850 * @rt_die: a root DIE (CU, subprogram or inlined_subroutine)
854 * Walk on all lines inside given @rt_die and call @callback on each line.
855 * If the @rt_die is a function, walk only on the lines inside the function,
856 * otherwise @rt_die must be a CU DIE.
858 * and inline call-site.
872 /* Get the CU die */ in die_walk_lines()
880 pr_debug2("Failed to get CU from given DIE.\n"); in die_walk_lines()
881 return -EINVAL; in die_walk_lines()
886 pr_debug2("Failed to get source lines on this CU.\n"); in die_walk_lines()
887 return -ENOENT; in die_walk_lines()
891 /* Walk on the lines on lines list */ in die_walk_lines()
901 /* Skip end-of-sequence */ in die_walk_lines()
904 /* Skip Non statement line-info */ in die_walk_lines()
907 /* Filter lines based on address */ in die_walk_lines()
918 /* Call-site check */ in die_walk_lines()
977 die_compare_name(die_mem, fvp->name) && in __die_find_variable_cb()
978 /* Does the DIE have location information or external instance? */ in __die_find_variable_cb()
982 if (dwarf_haspc(die_mem, fvp->addr)) in __die_find_variable_cb()
989 * die_find_variable_at - Find a given name variable at given address
990 * @sp_die: a function DIE
993 * @die_mem: a buffer for result DIE
995 * Find a variable DIE called @name at @addr in @sp_die.
1024 * die_find_member - Find a given name member in a data structure
1025 * @st_die: a data structure type DIE
1027 * @die_mem: a buffer for result DIE
1029 * Find a member DIE called @name in @st_die.
1039 * die_get_typename - Get the name of given variable DIE
1040 * @vr_die: a variable DIE
1044 * and Return -ENOENT if failed to find type name.
1055 return -ENOENT; in die_get_typename()
1065 return -ENOENT; in die_get_typename()
1080 * die_get_varname - Get the name and type of given variable DIE
1081 * @vr_die: a variable DIE
1101 * die_get_var_innermost_scope - Get innermost scope range of given variable DIE
1102 * @sp_die: a subprogram DIE
1103 * @vr_die: a variable DIE
1107 * "@<function_name+[NN-NN,NN-NN]>".
1128 return -ENOENT; in die_get_var_innermost_scope()
1132 /* (*SCOPES)[1] is the DIE for the scope containing that scope */ in die_get_var_innermost_scope()
1134 ret = -EINVAL; in die_get_var_innermost_scope()
1140 start -= entry; in die_get_var_innermost_scope()
1141 end -= entry; in die_get_var_innermost_scope()
1144 ret = strbuf_addf(buf, "@<%s+[%" PRIu64 "-%" PRIu64, in die_get_var_innermost_scope()
1148 ret = strbuf_addf(buf, ",%" PRIu64 "-%" PRIu64, in die_get_var_innermost_scope()
1164 * die_get_var_range - Get byte offset range of given variable DIE
1165 * @sp_die: a subprogram DIE
1166 * @vr_die: a variable DIE
1170 * "@<function_name+[NN-NN,NN-NN]>".
1191 return -ENOENT; in die_get_var_range()
1194 return -EINVAL; in die_get_var_range()
1205 start -= entry; in die_get_var_range()
1206 end -= entry; in die_get_var_range()
1208 ret = strbuf_addf(buf, "@<%s+[%" PRIu64 "-%" PRIu64, in die_get_var_range()
1212 ret = strbuf_addf(buf, ",%" PRIu64 "-%" PRIu64, in die_get_var_range()
1229 return -ENOTSUP; in die_get_var_range()
1234 * die_has_loclist - Check if DW_AT_location of @vr_die is a location list
1235 * @vr_die: a variable DIE
1251 * die_is_optimized_target - Check if target program is compiled with
1253 * @cu_die: a CU DIE
1278 * die_search_idx - Search index of given line address
1308 * die_get_postprologue_addr - Search next address after function prologue
1315 * Look for prologue-end marker. If there is no explicit marker, return
1347 /* clang supports prologue-end marker */ in die_get_postprologue_addr()
1369 dwarf_lineaddr(dwarf_onesrcline(lines, i - 1), in die_get_postprologue_addr()
1376 * die_skip_prologue - Use next address after prologue as probe location
1377 * @sp_die: a subprogram DIE
1378 * @cu_die: a CU DIE