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

uprobe: improve C++ probes listing #2693

Merged
merged 1 commit into from
Aug 3, 2023

Conversation

viktormalik
Copy link
Contributor

@viktormalik viktormalik commented Jul 21, 2023

When listing probes with the new :cpp prefix, demangle function names.

Example:

# bpftrace -l 'uprobe:/my/prog:*'
uprobe:/my/prog:_Z3funi
uprobe:/my/prog:_ZN3Bar3funEv
uprobe:/my/prog:_ZN3Foo3funEv

# bpftrace -l 'uprobe:/my/prog:cpp:*'
uprobe:/my/prog:cpp:"fun(int)"
uprobe:/my/prog:cpp:"Bar::fun()"
uprobe:/my/prog:cpp:"Foo::fun()"

Note: we need to surround the demangled name with quotes as it may contain some symbols which won't be accepted by the attach point parser (e.g. :: or ()). With quotes, the listing entries can be directly used as attach points.

Second note: I didn't add any tests for this b/c we don't have support for C++ testing programs and it didn't make sense to add it (could be quite a lot of changes in CMake) for this simple thing.

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

When listing probes with the new ":cpp" prefix, demangle function names.

Example:

    # bpftrace -l 'uprobe:/my/prog:*'
    uprobe:/my/prog:_Z3funi
    uprobe:/my/prog:_ZN3Bar3funEv
    uprobe:/my/prog:_ZN3Foo3funEv

    # bpftrace -l 'uprobe:/my/prog:cpp:*'
    uprobe:/my/prog:cpp:"fun(int)"
    uprobe:/my/prog:cpp:"Bar::fun()"
    uprobe:/my/prog:cpp:"Foo::fun()"

Note: we need to surround the demangled name with quotes as it may
contain some symbols which won't be accepted by the attach point parser
(e.g.  "::" or "()"). With quotes, the listing entries can be directly
used as attach points.
@viktormalik viktormalik merged commit 5fcc340 into bpftrace:master Aug 3, 2023
21 checks passed
@viktormalik viktormalik deleted the cxx-listing branch August 3, 2023 14:32
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

2 participants