tools/perf/tests/symbols.c
Source file repositories/reference/linux-study-clean/tools/perf/tests/symbols.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/tests/symbols.c- Extension
.c- Size
- 4826 bytes
- Lines
- 227
- 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
linux/compiler.hlinux/string.hsys/mman.hlimits.hdebug.hdso.henv.hmachine.hthread.hsymbol.hmap.hutil.htests.h
Detected Declarations
struct test_infostruct dso_mapfunction init_test_infofunction exit_test_infofunction find_map_cbfunction get_test_dso_filenamefunction create_mapfunction test_dsofunction subdivided_dso_cbfunction process_subdivided_dsofunction test_filefunction test__symbols
Annotated Snippet
struct test_info {
struct perf_env host_env;
struct machine *machine;
struct thread *thread;
};
static int init_test_info(struct test_info *ti)
{
perf_env__init(&ti->host_env);
ti->machine = machine__new_host(&ti->host_env);
if (!ti->machine) {
pr_debug("machine__new_host() failed!\n");
perf_env__exit(&ti->host_env);
return TEST_FAIL;
}
/* Create a dummy thread */
ti->thread = machine__findnew_thread(ti->machine, 100, 100);
if (!ti->thread) {
pr_debug("machine__findnew_thread() failed!\n");
perf_env__exit(&ti->host_env);
return TEST_FAIL;
}
return TEST_OK;
}
static void exit_test_info(struct test_info *ti)
{
thread__put(ti->thread);
machine__delete(ti->machine);
perf_env__exit(&ti->host_env);
}
struct dso_map {
struct dso *dso;
struct map *map;
};
static int find_map_cb(struct map *map, void *d)
{
struct dso_map *data = d;
if (map__dso(map) != data->dso)
return 0;
data->map = map;
return 1;
}
static struct map *find_module_map(struct machine *machine, struct dso *dso)
{
struct dso_map data = { .dso = dso };
machine__for_each_kernel_map(machine, find_map_cb, &data);
return data.map;
}
static void get_test_dso_filename(char *filename, size_t max_sz)
{
if (dso_to_test)
strlcpy(filename, dso_to_test, max_sz);
else
perf_exe(filename, max_sz);
}
static int create_map(struct test_info *ti, char *filename, struct map **map_p)
{
struct dso *dso = machine__findnew_dso(ti->machine, filename);
/*
* If 'filename' matches a current kernel module, must use a kernel
* map. Find the one that already exists.
*/
if (dso && dso__kernel(dso) != DSO_SPACE__USER) {
*map_p = find_module_map(ti->machine, dso);
dso__put(dso);
if (!*map_p) {
pr_debug("Failed to find map for current kernel module %s",
filename);
return TEST_FAIL;
}
map__get(*map_p);
return TEST_OK;
}
dso__put(dso);
/* Create a dummy map at 0x100000 */
*map_p = map__new(ti->machine, 0x100000, 0xffffffff, 0, &dso_id_empty,
Annotation
- Immediate include surface: `linux/compiler.h`, `linux/string.h`, `sys/mman.h`, `limits.h`, `debug.h`, `dso.h`, `env.h`, `machine.h`.
- Detected declarations: `struct test_info`, `struct dso_map`, `function init_test_info`, `function exit_test_info`, `function find_map_cb`, `function get_test_dso_filename`, `function create_map`, `function test_dso`, `function subdivided_dso_cb`, `function process_subdivided_dso`.
- 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.