/* this is how USDT semaphore is actually defined, except volatile modifier */ volatileunsignedshort uprobe_ref_ctr __attribute__((unused)) __attribute((section(".probes")));
/* test attach by name for a library function, using the library * as the binary argument. libc.so.6 will be resolved via dlopen()/dlinfo().
*/
uprobe_opts.func_name = "fopen";
uprobe_opts.retprobe = false;
skel->links.handle_uprobe_byname2 =
bpf_program__attach_uprobe_opts(skel->progs.handle_uprobe_byname2, 0/* this pid */, "libc.so.6", 0, &uprobe_opts); if (!ASSERT_OK_PTR(skel->links.handle_uprobe_byname2, "attach_uprobe_byname2")) return;
uprobe_opts.func_name = "fclose";
uprobe_opts.retprobe = true;
skel->links.handle_uretprobe_byname2 =
bpf_program__attach_uprobe_opts(skel->progs.handle_uretprobe_byname2,
-1/* any pid */, "libc.so.6", 0, &uprobe_opts); if (!ASSERT_OK_PTR(skel->links.handle_uretprobe_byname2, "attach_uretprobe_byname2")) return;
/* trigger & validate shared library u[ret]probes attached by name */
devnull = fopen("/dev/null", "r");
fclose(devnull);
/* if uprobe uses ref_ctr, uretprobe has to use ref_ctr as well */
uprobe_opts.retprobe = true;
uprobe_opts.ref_ctr_offset = ref_ctr_offset;
uretprobe_link = bpf_program__attach_uprobe_opts(skel->progs.handle_uretprobe_ref_ctr,
-1/* any pid */, "/proc/self/exe",
uprobe_offset, &uprobe_opts); if (!ASSERT_OK_PTR(uretprobe_link, "attach_uretprobe_ref_ctr")) return;
skel->links.handle_uretprobe_ref_ctr = uretprobe_link;
}
skel = test_attach_kprobe_sleepable__open(); if (!ASSERT_OK_PTR(skel, "skel_kprobe_sleepable_open")) return;
/* sleepable kprobe test case needs flags set before loading */ if (!ASSERT_OK(bpf_program__set_flags(skel->progs.handle_kprobe_sleepable,
BPF_F_SLEEPABLE), "kprobe_sleepable_flags")) goto cleanup;
if (!ASSERT_OK(test_attach_kprobe_sleepable__load(skel), "skel_kprobe_sleepable_load")) goto cleanup;
/* sleepable kprobes should not attach successfully */
skel->links.handle_kprobe_sleepable = bpf_program__attach(skel->progs.handle_kprobe_sleepable);
ASSERT_ERR_PTR(skel->links.handle_kprobe_sleepable, "attach_kprobe_sleepable");
skel = test_attach_probe__open(); if (!ASSERT_OK_PTR(skel, "skel_open")) return;
if (!ASSERT_OK(test_attach_probe__load(skel), "skel_load")) goto cleanup; if (!ASSERT_OK_PTR(skel->bss, "check_bss")) goto cleanup;
if (test__start_subtest("manual-default"))
test_attach_probe_manual(PROBE_ATTACH_MODE_DEFAULT); if (test__start_subtest("manual-legacy"))
test_attach_probe_manual(PROBE_ATTACH_MODE_LEGACY); if (test__start_subtest("manual-perf"))
test_attach_probe_manual(PROBE_ATTACH_MODE_PERF); if (test__start_subtest("manual-link"))
test_attach_probe_manual(PROBE_ATTACH_MODE_LINK);
if (test__start_subtest("auto"))
test_attach_probe_auto(skel); if (test__start_subtest("kprobe-sleepable"))
test_kprobe_sleepable(); if (test__start_subtest("uprobe-lib"))
test_uprobe_lib(skel); if (test__start_subtest("uprobe-sleepable"))
test_uprobe_sleepable(skel); if (test__start_subtest("uprobe-ref_ctr"))
test_uprobe_ref_ctr(skel);
if (test__start_subtest("uprobe-long_name"))
test_attach_uprobe_long_event_name(); if (test__start_subtest("kprobe-long_name"))
test_attach_kprobe_long_event_name();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.