tools/perf/util/dwarf-aux.c
Source file repositories/reference/linux-study-clean/tools/perf/util/dwarf-aux.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/dwarf-aux.c- Extension
.c- Size
- 57336 bytes
- Lines
- 2184
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
errno.hinttypes.hstdbool.hstdlib.hdebug.hdwarf-aux.hdwarf-regs.hstrbuf.hstring2.h
Detected Declarations
struct __addr_die_search_paramstruct __instance_walk_paramstruct __line_walk_paramstruct __find_variable_paramstruct find_var_datastruct find_scope_datafunction realfunction cu_find_lineinfofunction cu_walk_functions_atfunction die_compare_namefunction die_match_namefunction die_get_call_linenofunction variablefunction variablefunction qualifierfunction die_get_attr_udatafunction die_is_signed_typefunction die_is_func_deffunction dwarf_entrypcfunction instancefunction die_get_data_member_locationfunction die_get_call_filenofunction die_get_decl_filenofunction intfunction __die_search_func_tail_cbfunction __die_search_func_cbfunction dwarf_haspcfunction __die_find_inline_cbfunction __die_find_func_rettype_cbfunction __die_walk_instances_cbfunction die_walk_instancesfunction __die_walk_funclines_cbfunction __die_walk_funclinesfunction die_entrypcfunction __die_walk_culines_cbfunction die_walk_linesfunction __die_find_variable_cbfunction __die_find_member_cbfunction die_get_typename_from_typefunction die_get_typenamefunction die_get_varnamefunction reg_from_dwarf_opfunction offset_from_dwarf_opfunction check_allowed_opsfunction die_get_var_innermost_scopefunction die_get_var_rangefunction match_var_offsetfunction is_breg_access_indirect
Annotated Snippet
struct __addr_die_search_param {
Dwarf_Addr addr;
Dwarf_Die *die_mem;
};
static int __die_search_func_tail_cb(Dwarf_Die *fn_die, void *data)
{
struct __addr_die_search_param *ad = data;
Dwarf_Addr addr = 0;
if (dwarf_tag(fn_die) == DW_TAG_subprogram &&
!dwarf_highpc(fn_die, &addr) &&
addr == ad->addr) {
memcpy(ad->die_mem, fn_die, sizeof(Dwarf_Die));
return DWARF_CB_ABORT;
}
return DWARF_CB_OK;
}
/**
* die_find_tailfunc - Search for a non-inlined function with tail call at
* given address
* @cu_die: a CU DIE which including @addr
* @addr: target address
* @die_mem: a buffer for result DIE
*
* Search for a non-inlined function DIE with tail call at @addr. Stores the
* DIE to @die_mem and returns it if found. Returns NULL if failed.
*/
Dwarf_Die *die_find_tailfunc(Dwarf_Die *cu_die, Dwarf_Addr addr,
Dwarf_Die *die_mem)
{
struct __addr_die_search_param ad;
ad.addr = addr;
ad.die_mem = die_mem;
/* dwarf_getscopes can't find subprogram. */
if (!dwarf_getfuncs(cu_die, __die_search_func_tail_cb, &ad, 0))
return NULL;
else
return die_mem;
}
/* die_find callback for non-inlined function search */
static int __die_search_func_cb(Dwarf_Die *fn_die, void *data)
{
struct __addr_die_search_param *ad = data;
/*
* Since a declaration entry doesn't has given pc, this always returns
* function definition entry.
*/
if (dwarf_tag(fn_die) == DW_TAG_subprogram &&
dwarf_haspc(fn_die, ad->addr)) {
memcpy(ad->die_mem, fn_die, sizeof(Dwarf_Die));
return DWARF_CB_ABORT;
}
return DWARF_CB_OK;
}
/**
* die_find_realfunc - Search a non-inlined function at given address
* @cu_die: a CU DIE which including @addr
* @addr: target address
* @die_mem: a buffer for result DIE
*
* Search a non-inlined function DIE which includes @addr. Stores the
* DIE to @die_mem and returns it if found. Returns NULL if failed.
*/
Dwarf_Die *die_find_realfunc(Dwarf_Die *cu_die, Dwarf_Addr addr,
Dwarf_Die *die_mem)
{
struct __addr_die_search_param ad;
ad.addr = addr;
ad.die_mem = die_mem;
/* dwarf_getscopes can't find subprogram. */
if (!dwarf_getfuncs(cu_die, __die_search_func_cb, &ad, 0))
return NULL;
else
return die_mem;
}
/* die_find callback for inline function search */
static int __die_find_inline_cb(Dwarf_Die *die_mem, void *data)
{
Dwarf_Addr *addr = data;
if (dwarf_tag(die_mem) == DW_TAG_inlined_subroutine &&
dwarf_haspc(die_mem, *addr))
return DIE_FIND_CB_END;
Annotation
- Immediate include surface: `errno.h`, `inttypes.h`, `stdbool.h`, `stdlib.h`, `debug.h`, `dwarf-aux.h`, `dwarf-regs.h`, `strbuf.h`.
- Detected declarations: `struct __addr_die_search_param`, `struct __instance_walk_param`, `struct __line_walk_param`, `struct __find_variable_param`, `struct find_var_data`, `struct find_scope_data`, `function real`, `function cu_find_lineinfo`, `function cu_walk_functions_at`, `function die_compare_name`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.