tools/testing/selftests/bpf/prog_tests/build_id.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/build_id.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/build_id.c- Extension
.c- Size
- 3370 bytes
- Lines
- 119
- 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
test_progs.htest_build_id.skel.h
Detected Declarations
function print_stackfunction subtest_nofaultfunction subtest_sleepablefunction serial_test_build_id
Annotated Snippet
switch (stack[i].status) {
case BPF_STACK_BUILD_ID_EMPTY:
printf("<EMPTY>\n");
break;
case BPF_STACK_BUILD_ID_VALID:
printf("BUILD ID = ");
for (j = 0; j < BPF_BUILD_ID_SIZE; j++)
printf("%02hhx", (unsigned)stack[i].build_id[j]);
printf(" OFFSET = %llx", (unsigned long long)stack[i].offset);
break;
case BPF_STACK_BUILD_ID_IP:
printf("IP = %llx", (unsigned long long)stack[i].ip);
break;
default:
printf("UNEXPECTED STATUS %d ", stack[i].status);
break;
}
printf("\n");
}
}
static void subtest_nofault(bool build_id_resident)
{
struct test_build_id *skel;
struct bpf_stack_build_id *stack;
int frame_cnt;
skel = test_build_id__open_and_load();
if (!ASSERT_OK_PTR(skel, "skel_open"))
return;
skel->links.uprobe_nofault = bpf_program__attach(skel->progs.uprobe_nofault);
if (!ASSERT_OK_PTR(skel->links.uprobe_nofault, "link"))
goto cleanup;
if (build_id_resident)
ASSERT_OK(system("./uprobe_multi uprobe-paged-in"), "trigger_uprobe");
else
ASSERT_OK(system("./uprobe_multi uprobe-paged-out"), "trigger_uprobe");
if (!ASSERT_GT(skel->bss->res_nofault, 0, "res"))
goto cleanup;
stack = skel->bss->stack_nofault;
frame_cnt = skel->bss->res_nofault / sizeof(struct bpf_stack_build_id);
if (env.verbosity >= VERBOSE_NORMAL)
print_stack(stack, frame_cnt);
if (build_id_resident) {
ASSERT_EQ(stack[0].status, BPF_STACK_BUILD_ID_VALID, "build_id_status");
ASSERT_EQ(memcmp(stack[0].build_id, build_id, build_id_sz), 0, "build_id_match");
} else {
ASSERT_EQ(stack[0].status, BPF_STACK_BUILD_ID_IP, "build_id_status");
}
cleanup:
test_build_id__destroy(skel);
}
static void subtest_sleepable(void)
{
struct test_build_id *skel;
struct bpf_stack_build_id *stack;
int frame_cnt;
skel = test_build_id__open_and_load();
if (!ASSERT_OK_PTR(skel, "skel_open"))
return;
skel->links.uprobe_sleepable = bpf_program__attach(skel->progs.uprobe_sleepable);
if (!ASSERT_OK_PTR(skel->links.uprobe_sleepable, "link"))
goto cleanup;
/* force build ID to not be paged in */
ASSERT_OK(system("./uprobe_multi uprobe-paged-out"), "trigger_uprobe");
if (!ASSERT_GT(skel->bss->res_sleepable, 0, "res"))
goto cleanup;
stack = skel->bss->stack_sleepable;
frame_cnt = skel->bss->res_sleepable / sizeof(struct bpf_stack_build_id);
if (env.verbosity >= VERBOSE_NORMAL)
print_stack(stack, frame_cnt);
ASSERT_EQ(stack[0].status, BPF_STACK_BUILD_ID_VALID, "build_id_status");
ASSERT_EQ(memcmp(stack[0].build_id, build_id, build_id_sz), 0, "build_id_match");
cleanup:
test_build_id__destroy(skel);
}
Annotation
- Immediate include surface: `test_progs.h`, `test_build_id.skel.h`.
- Detected declarations: `function print_stack`, `function subtest_nofault`, `function subtest_sleepable`, `function serial_test_build_id`.
- 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.