Skip to content

[BUG] 37-uprobe-rust wrong function symbol #173

@DavidHernandez21

Description

@DavidHernandez21

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 main function not the hello function
  • The hello function gets inlined in release build mode (I have not confirmed this, but cannot find it using nm)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions