bpftrace: BEGIN probe not working

$ sudo ./src/bpftrace -e 'BEGIN { printf("hello\n"); }'
Attaching 1 probe...
Could not resolve symbol: /proc/self/exe:BEGIN_trigger

Built from master at time of writing.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 8
  • Comments: 22 (13 by maintainers)

Commits related to this issue

Most upvoted comments

On Ubuntu, I followed the guide to install the dbgsym packages as described here: https://wiki.ubuntu.com/Debug Symbol Packages

Then:

sudo apt install bpftrace-dbgsym

I experience this problem on vanilla ubuntu 22.04

On Ubuntu, I followed the guide to install the dbgsym packages as described here: https://wiki.ubuntu.com/Debug Symbol Packages

Then:

sudo apt install bpftrace-dbgsym

Thx, it works for me 😃

I’m just dropping this comment for anyone else who hits the same issue. I hit this on my bone stock Fedora 31 install and it was resolved by installing the debug package.

dnf debuginfo-install bpftrace

The cause of this was discovered by @fbs.

edit: it may have also just been an overall uprobe issue

The problem is that these executables have been stripped, and they need to leave the symbol BEGIN_trigger. I’ve added this to the post-processing of the release artifacts of #1041 with the --keep-symbol flag to strip. To verify, just run nm on the bpftrace binary. For it to work you must see:

nm src/bpftrace
0000000000b5a750 T BEGIN_trigger

I think this can be closed as solved - don’t strip this symbol as bpftrace’s BEGIN probe works by probing itself, which I think is the intended behavior, but poses a quirk for released binaries.

It’s also not just BEGIN, it’s any uprobe:

That doesn’t explain the uprobe error though I’ve just realized, so perhaps this is backwards - because the BEGIN probe is trying to probe itself, it wouldn’t work because uprobes were broken.