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

Fixes for watchpoint probes and runtime tests #3161

Merged
merged 3 commits into from May 13, 2024

Conversation

viktormalik
Copy link
Contributor

@viktormalik viktormalik commented May 10, 2024

Fix two issues with watchpoint probes/tests introduced by recent PRs:

The reason why neither of these was captured is a strange issue in CMake. During CMake run, we copy files from tests/runtime/ to build/tests/runtime, however, the last file (in our case tests/runtime/watchpoint) is never copied. Due to this, watchpoint tests are not run in the CI and also do not get updated in local builds (it seems to have worked in the past b/c I had the file in my build directory but it was never updated).

I'm not sure if this is caused by our change or by a CMake update, however, our approach is IMHO not correct as it makes the runtime_tests target depend on the runtime tests files from the source directory. Changing it to depend on the (newly copied) files from the build directory eliminates the above issue. This is done by the last commit in the PR.

Checklist
  • Language changes are updated in man/adoc/bpftrace.adoc
  • User-visible and non-trivial changes updated in CHANGELOG.md
  • The new behaviour is covered by tests

Commit ccb7785 ("Add probe index to LLVM function name") changed the
way LLVM function and section names are generated for probes. It did it
wrong for watchpoint setup probes where it generated

    <attach_point>_<index>_wp_setup_<index>

instead of

    <attach_point>_wp_setup_<index>

for the LLVM function name (notice the extra "_<index>"). The same
difference is for sections names which just have "s_" prepended.

Consequently, bpftrace was not able to find BPF programs for watchpoint
setup probes as they were not stored under expected section names.

Fix the function/section name to have the expected form.
Since commit 611176d ("Runtime tests: Make EXPECT only match exact
lines of output"), the EXPECT clause in runtime tests must contain the
exact entire line. The change has not been reflected in a few runtime
tests and it was missed b/c they are not run in the CI (this will be
addressed by the following patch).

Update the affected tests to check for correct lines.
During CMake, all runtime test files are copied into the CMake build
directory using add_custom_command which issues 'cmake -E copy ...'.
For some reason, the last file in the tests/runtime directory
(tests/runtime/watchpoint) is never copied which causes two issues:
- the watchpoint tests are never run in CI,
- even if the local setup already has tests/runtime/watchpoint in the
  build directory (it seems to have been working in the past), it is
  never updated.

I'm not sure if this is caused by our change or a CMake update, however,
our approach is IMHO not correct as it makes the runtime_tests target
depend on the runtime tests files from the source directory. Changing it
to depend on the (newly copied) files from the build directory
eliminates the above issue.
Copy link
Contributor

@jordalgo jordalgo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Copy link
Member

@danobi danobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent catch!

@danobi danobi merged commit 6a1f3f0 into bpftrace:master May 13, 2024
18 checks passed
@viktormalik viktormalik deleted the watchpoint-fix branch May 22, 2024 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants