Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new runtime tests to validate the order of probe firing #3170

Open
ajor opened this issue May 15, 2024 · 0 comments
Open

Add new runtime tests to validate the order of probe firing #3170

ajor opened this issue May 15, 2024 · 0 comments
Labels
difficulty: easy good first issue Good for newcomers priority: low tests Issues with our tests or test framework; missing tests; invalid tests

Comments

@ajor
Copy link
Member

ajor commented May 15, 2024

Multiple probes are allowed to be attached to the same event. When this happens, bpftrace tries to ensure that the probes fire in the order that they're defined in the script.

e.g. this script should always print a sequence of "abc" and not "cba":

tracepoint:syscalls:sys_enter_read { printf("a") }
tracepoint:syscalls:sys_enter_read { printf("b") }
tracepoint:syscalls:sys_enter_read { printf("c") }

For reference, this is the code that controls the order in which we load duplicate probes and defines the order they fire in:

bpftrace/src/bpftrace.cpp

Lines 952 to 976 in bc73244

bool attach_reverse(const Probe &p)
{
switch (p.type) {
case ProbeType::special:
case ProbeType::kprobe:
case ProbeType::uprobe:
case ProbeType::uretprobe:
case ProbeType::usdt:
case ProbeType::software:
case ProbeType::kfunc:
case ProbeType::iter:
return true;
case ProbeType::kretfunc:
case ProbeType::kretprobe:
case ProbeType::tracepoint:
case ProbeType::profile:
case ProbeType::interval:
case ProbeType::watchpoint:
case ProbeType::asyncwatchpoint:
case ProbeType::hardware:
case ProbeType::rawtracepoint:
return false;
case ProbeType::invalid:
LOG(BUG) << "Unknown probe type";
}

This area of code may be changing in the future, with #3128 and/or #2334, so it'd be good to add some test coverage.

For as many of the different probe types as is practical, we should try to write new runtime tests that confirm they fire in the correct order.

@ajor ajor added good first issue Good for newcomers tests Issues with our tests or test framework; missing tests; invalid tests priority: low difficulty: easy labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy good first issue Good for newcomers priority: low tests Issues with our tests or test framework; missing tests; invalid tests
Projects
None yet
Development

No branches or pull requests

1 participant