bpf-developer-tutorial
bpf-developer-tutorial copied to clipboard
[BUG] 37-uprobe-rust wrong function symbol
Describe the bug Would like to start showing my appreciation to this repo and Eunomia in general.
TBH it can be also a typo, but the README.md is still a bit confusing. When tracing the helloworld project on the args directory this command is written on the README sudo bpftrace -e 'uprobe:args/target/release/helloworld:_ZN10helloworld4main17h2dce92cb81426b91E ....
I see two issues:
- The symbol corresponds to the
mainfunction not thehellofunction - The
hellofunction gets inlined inreleasebuild mode (I have not confirmed this, but cannot find it usingnm)
building the binary in debug mode and tracing the hello function both with uprobe and uretprobe gives the "expected" output
To Reproduce
cargo build
nm target/debug/helloworld | grep hello
0000000000008ce0 t _ZN10helloworld4main17h0fc2ef2e3559c5e9E
0000000000008c30 t _ZN10helloworld5hello17h2e3af3f12b54c6c3E
Expected behavior
sudo bpftrace -e 'uprobe:target/debug/helloworld:_ZN10helloworld5hello17h2e3af3f12b54c6c3E { printf("Function hello-world called\n"); }'
Function hello-world called
Function hello-world called
Function hello-world called
the above output comes from running
./target/debug/helloworld 1 2 3
Hello, world! 1 in 4
return value: 5
Hello, world! 2 in 4
return value: 6
Hello, world! 3 in 4
return value: 7
Similarly
sudo bpftrace -e 'uretprobe:target/debug/helloworld:_ZN10helloworld5hello17h2e3af3f12b54c6c3E { printf("Function hello-world called. Return vale %d\n", retval); }'
Attaching 1 probe...
Function hello-world called. Return vale 5
Function hello-world called. Return vale 6
Function hello-world called. Return vale 7
Desktop (please complete the following information):
- OS: wsl2
- Version rust edition 2024
Thanks! I think it needs some fix.