tools/perf/util/annotate-data.c
Source file repositories/reference/linux-study-clean/tools/perf/util/annotate-data.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/annotate-data.c- Extension
.c- Size
- 50678 bytes
- Lines
- 1954
- 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.hstdio.hstdlib.hinttypes.hlinux/zalloc.hannotate.hannotate-data.hdebuginfo.hdebug.hdso.hdwarf-regs.hevsel.hevlist.hmap.hmap_symbol.hsort.hstrbuf.hsymbol.hsymbol_conf.hthread.h
Detected Declarations
struct global_var_entryenum type_match_resultfunction pr_debug_type_namefunction pr_debug_locationfunction pr_debug_scopefunction has_reg_typefunction init_type_statefunction exit_type_statefunction list_for_each_entry_safefunction placesfunction data_type_lessfunction __add_member_cbfunction add_member_typesfunction delete_membersfunction list_for_each_entry_safefunction fill_member_namefunction list_for_each_entryfunction annotated_data_type__get_member_namefunction find_cu_diefunction is_compound_typefunction is_better_typefunction check_variablefunction list_for_each_entryfunction set_stack_statefunction global_var_cmpfunction global_var_lessfunction global_var__addfunction global_var_type__tree_deletefunction get_global_var_infofunction global_var__collectfunction get_global_var_typefunction die_is_samefunction tsr_set_lifetimefunction update_var_statefunction container_offunction update_insn_statefunction this_blocksfunction delete_basic_blocksfunction list_for_each_entry_safefunction fixup_var_addressfunction delete_var_typesfunction setup_stack_canaryfunction check_matching_typefunction find_data_type_insnfunction list_for_each_entryfunction list_for_each_entry_fromfunction arch_supports_insn_trackingfunction find_data_type_block
Annotated Snippet
struct global_var_entry {
struct rb_node node;
char *name;
u64 start;
u64 end;
u64 die_offset;
};
static int global_var_cmp(const void *_key, const struct rb_node *node)
{
const u64 addr = (uintptr_t)_key;
struct global_var_entry *gvar;
gvar = rb_entry(node, struct global_var_entry, node);
if (gvar->start <= addr && addr < gvar->end)
return 0;
return gvar->start > addr ? -1 : 1;
}
static bool global_var_less(struct rb_node *node_a, const struct rb_node *node_b)
{
struct global_var_entry *gvar_a, *gvar_b;
gvar_a = rb_entry(node_a, struct global_var_entry, node);
gvar_b = rb_entry(node_b, struct global_var_entry, node);
return gvar_a->start < gvar_b->start;
}
static struct global_var_entry *global_var__find(struct data_loc_info *dloc, u64 addr)
{
struct dso *dso = map__dso(dloc->ms->map);
struct rb_node *node;
node = rb_find((void *)(uintptr_t)addr, dso__global_vars(dso), global_var_cmp);
if (node == NULL)
return NULL;
return rb_entry(node, struct global_var_entry, node);
}
static bool global_var__add(struct data_loc_info *dloc, u64 addr,
const char *name, Dwarf_Die *type_die)
{
struct dso *dso = map__dso(dloc->ms->map);
struct global_var_entry *gvar;
Dwarf_Word size;
if (dwarf_aggregate_size(type_die, &size) < 0)
return false;
gvar = malloc(sizeof(*gvar));
if (gvar == NULL)
return false;
gvar->name = name ? strdup(name) : NULL;
if (name && gvar->name == NULL) {
free(gvar);
return false;
}
gvar->start = addr;
gvar->end = addr + size;
gvar->die_offset = dwarf_dieoffset(type_die);
rb_add(&gvar->node, dso__global_vars(dso), global_var_less);
return true;
}
void global_var_type__tree_delete(struct rb_root *root)
{
struct global_var_entry *gvar;
while (!RB_EMPTY_ROOT(root)) {
struct rb_node *node = rb_first(root);
rb_erase(node, root);
gvar = rb_entry(node, struct global_var_entry, node);
zfree(&gvar->name);
free(gvar);
}
}
bool get_global_var_info(struct data_loc_info *dloc, u64 addr,
const char **var_name, int *var_offset)
{
struct addr_location al;
struct symbol *sym;
u64 mem_addr;
Annotation
- Immediate include surface: `errno.h`, `stdio.h`, `stdlib.h`, `inttypes.h`, `linux/zalloc.h`, `annotate.h`, `annotate-data.h`, `debuginfo.h`.
- Detected declarations: `struct global_var_entry`, `enum type_match_result`, `function pr_debug_type_name`, `function pr_debug_location`, `function pr_debug_scope`, `function has_reg_type`, `function init_type_state`, `function exit_type_state`, `function list_for_each_entry_safe`, `function places`.
- 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.