tools/perf/util/symbol.c
Source file repositories/reference/linux-study-clean/tools/perf/util/symbol.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/symbol.c- Extension
.c- Size
- 62905 bytes
- Lines
- 2638
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
dirent.herrno.hstdlib.hstdio.hstring.hlinux/capability.hlinux/kernel.hlinux/mman.hlinux/string.hlinux/time64.hsys/types.hsys/stat.hsys/param.hfcntl.hunistd.hinttypes.hannotate.hbuild-id.hcap.hcpumap.hdebug.hdemangle-cxx.hdemangle-java.hdemangle-ocaml.hdemangle-rust-v0.hdso.hutil.hevent.hmachine.hmap.hsymbol.hmap_symbol.h
Detected Declarations
struct map_list_nodestruct module_infostruct kcore_mapfn_datafunction symbol_type__filterfunction prefix_underscores_countfunction arch__normalize_symbol_namefunction arch__compare_symbol_namesfunction arch__compare_symbol_names_nfunction arch__choose_best_symbolfunction choose_best_symbolfunction symbols__fixup_duplicatefunction symbols__fixup_endfunction addressesfunction symbol__deletefunction symbols__deletefunction __symbols__insertfunction symbols__insertfunction symbols__sort_name_cmpfunction symbol__match_symbol_namefunction dso__reset_find_symbol_cachefunction dso__insert_symbolfunction dso__delete_symbolfunction dso__sort_by_namefunction hex2u64function modules__parsefunction symbol__is_idlefunction map__process_kallsym_symbolfunction dso__load_all_kallsymsfunction maps__split_kallsyms_for_kcorefunction maps__split_kallsymsfunction symbol__restricted_filenamefunction add_modulefunction delete_modulesfunction __read_proc_modulesfunction read_proc_modulesfunction compare_proc_modulesfunction do_validate_kcore_modules_cbfunction do_validate_kcore_modulesfunction filename_from_kallsyms_filenamefunction validate_kcore_modulesfunction validate_kcore_addressesfunction kcore_mapfnfunction remove_old_mapsfunction dso__load_kcorefunction list_for_each_entryfunction kallsyms__deltafunction __dso__load_kallsymsfunction dso__load_kallsyms
Annotated Snippet
struct map_list_node {
struct list_head node;
struct map *map;
};
static struct map_list_node *map_list_node__new(void)
{
return malloc(sizeof(struct map_list_node));
}
static enum dso_binary_type binary_type_symtab[] = {
DSO_BINARY_TYPE__KALLSYMS,
DSO_BINARY_TYPE__GUEST_KALLSYMS,
DSO_BINARY_TYPE__JAVA_JIT,
DSO_BINARY_TYPE__DEBUGLINK,
DSO_BINARY_TYPE__BUILD_ID_CACHE,
DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO,
DSO_BINARY_TYPE__FEDORA_DEBUGINFO,
DSO_BINARY_TYPE__UBUNTU_DEBUGINFO,
DSO_BINARY_TYPE__BUILDID_DEBUGINFO,
DSO_BINARY_TYPE__GNU_DEBUGDATA,
DSO_BINARY_TYPE__SYSTEM_PATH_DSO,
DSO_BINARY_TYPE__GUEST_KMODULE,
DSO_BINARY_TYPE__GUEST_KMODULE_COMP,
DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE,
DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP,
DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO,
DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO,
DSO_BINARY_TYPE__NOT_FOUND,
};
#define DSO_BINARY_TYPE__SYMTAB_CNT ARRAY_SIZE(binary_type_symtab)
static bool symbol_type__filter(char symbol_type)
{
symbol_type = toupper(symbol_type);
return symbol_type == 'T' || symbol_type == 'W' || symbol_type == 'D' || symbol_type == 'B';
}
static int prefix_underscores_count(const char *str)
{
const char *tail = str;
while (*tail == '_')
tail++;
return tail - str;
}
const char * __weak arch__normalize_symbol_name(const char *name)
{
return name;
}
int __weak arch__compare_symbol_names(const char *namea, const char *nameb)
{
return strcmp(namea, nameb);
}
int __weak arch__compare_symbol_names_n(const char *namea, const char *nameb,
unsigned int n)
{
return strncmp(namea, nameb, n);
}
int __weak arch__choose_best_symbol(struct symbol *syma,
struct symbol *symb __maybe_unused)
{
/* Avoid "SyS" kernel syscall aliases */
if (strlen(syma->name) >= 3 && !strncmp(syma->name, "SyS", 3))
return SYMBOL_B;
if (strlen(syma->name) >= 10 && !strncmp(syma->name, "compat_SyS", 10))
return SYMBOL_B;
return SYMBOL_A;
}
static int choose_best_symbol(struct symbol *syma, struct symbol *symb)
{
s64 a;
s64 b;
size_t na, nb;
/* Prefer a symbol with non zero length */
a = syma->end - syma->start;
b = symb->end - symb->start;
if ((b == 0) && (a > 0))
return SYMBOL_A;
else if ((a == 0) && (b > 0))
return SYMBOL_B;
Annotation
- Immediate include surface: `dirent.h`, `errno.h`, `stdlib.h`, `stdio.h`, `string.h`, `linux/capability.h`, `linux/kernel.h`, `linux/mman.h`.
- Detected declarations: `struct map_list_node`, `struct module_info`, `struct kcore_mapfn_data`, `function symbol_type__filter`, `function prefix_underscores_count`, `function arch__normalize_symbol_name`, `function arch__compare_symbol_names`, `function arch__compare_symbol_names_n`, `function arch__choose_best_symbol`, `function choose_best_symbol`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.