tools/perf/tests/vmlinux-kallsyms.c
Source file repositories/reference/linux-study-clean/tools/perf/tests/vmlinux-kallsyms.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/tests/vmlinux-kallsyms.c- Extension
.c- Size
- 10939 bytes
- Lines
- 382
- 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.
- 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
linux/compiler.hlinux/rbtree.hinttypes.hstring.hctype.hstdlib.hdso.hmap.hsymbol.hinternal/lib.htests.hdebug.hmachine.h
Detected Declarations
struct test__vmlinux_matches_kallsyms_cb_argsfunction is_ignored_symbolfunction test__vmlinux_matches_kallsyms_cb1function test__vmlinux_matches_kallsyms_cb2function test__vmlinux_matches_kallsyms_cb3function test__vmlinux_matches_kallsyms
Annotated Snippet
struct test__vmlinux_matches_kallsyms_cb_args {
struct machine kallsyms;
struct map *vmlinux_map;
bool header_printed;
};
static int test__vmlinux_matches_kallsyms_cb1(struct map *map, void *data)
{
struct test__vmlinux_matches_kallsyms_cb_args *args = data;
struct dso *dso = map__dso(map);
/*
* If it is the kernel, kallsyms is always "[kernel.kallsyms]", while
* the kernel will have the path for the vmlinux file being used, so use
* the short name, less descriptive but the same ("[kernel]" in both
* cases.
*/
struct map *pair = maps__find_by_name(args->kallsyms.kmaps,
(dso__kernel(dso) ? dso__short_name(dso) : dso__name(dso)));
if (pair) {
map__set_priv(pair);
map__put(pair);
} else {
if (!args->header_printed) {
pr_info("WARN: Maps only in vmlinux:\n");
args->header_printed = true;
}
map__fprintf(map, stderr);
}
return 0;
}
static int test__vmlinux_matches_kallsyms_cb2(struct map *map, void *data)
{
struct test__vmlinux_matches_kallsyms_cb_args *args = data;
struct map *pair;
u64 mem_start = map__unmap_ip(args->vmlinux_map, map__start(map));
u64 mem_end = map__unmap_ip(args->vmlinux_map, map__end(map));
pair = maps__find(args->kallsyms.kmaps, mem_start);
if (pair != NULL && !map__priv(pair) && map__start(pair) == mem_start) {
struct dso *dso = map__dso(map);
if (!args->header_printed) {
pr_info("WARN: Maps in vmlinux with a different name in kallsyms:\n");
args->header_printed = true;
}
pr_info("WARN: %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s in kallsyms as",
map__start(map), map__end(map), map__pgoff(map), dso__name(dso));
if (mem_end != map__end(pair))
pr_info(":\nWARN: *%" PRIx64 "-%" PRIx64 " %" PRIx64,
map__start(pair), map__end(pair), map__pgoff(pair));
pr_info(" %s\n", dso__name(dso));
map__set_priv(pair);
}
map__put(pair);
return 0;
}
static int test__vmlinux_matches_kallsyms_cb3(struct map *map, void *data)
{
struct test__vmlinux_matches_kallsyms_cb_args *args = data;
if (!map__priv(map)) {
if (!args->header_printed) {
pr_info("WARN: Maps only in kallsyms:\n");
args->header_printed = true;
}
map__fprintf(map, stderr);
}
return 0;
}
static int test__vmlinux_matches_kallsyms(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
int err = TEST_FAIL;
struct rb_node *nd;
struct symbol *sym;
struct map *kallsyms_map;
struct machine vmlinux;
struct maps *maps;
u64 mem_start, mem_end;
struct test__vmlinux_matches_kallsyms_cb_args args;
/*
* Step 1:
*
Annotation
- Immediate include surface: `linux/compiler.h`, `linux/rbtree.h`, `inttypes.h`, `string.h`, `ctype.h`, `stdlib.h`, `dso.h`, `map.h`.
- Detected declarations: `struct test__vmlinux_matches_kallsyms_cb_args`, `function is_ignored_symbol`, `function test__vmlinux_matches_kallsyms_cb1`, `function test__vmlinux_matches_kallsyms_cb2`, `function test__vmlinux_matches_kallsyms_cb3`, `function test__vmlinux_matches_kallsyms`.
- 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.