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

examples/c: demo how to get IP for uprobe and uretprobe #221

Closed
wants to merge 1 commit into from

Conversation

anakryiko
Copy link
Member

@anakryiko anakryiko commented Sep 26, 2023

Show how it's possible to fetch user-space function's address from
uprobe and uretprobe BPF programs.

When uprobe example is run, you'll see:

Triggering user function test_func, addr 0x402bc2...

in the console output. And corresponding:

uprobe-1805730 [036] ....1 674139.123096: bpf_trace_printk: UPROBE    IP 0x402bc2.
uprobe-1805730 [036] ....1 674139.123110: bpf_trace_printk: URETPROBE IP 0x402bc2.

in /sys/kernel/debug/tracing/trace_pipe.

As you can see, those IPs match exactly.

ARM might need a bit of adjustment, I'm not sure, I think ARM can have
uprobe/uretprobe breakpoint installed not at the very first byte offset within
user space function.

Show how it's possible to fetch user-space function's address from
uprobe and uretprobe BPF programs.

When uprobe example is run, you'll see:

```
Triggering user function test_func, addr 0x402bc2...
```

in the console output. And corresponding:

```
uprobe-1805730 [036] ....1 674139.123096: bpf_trace_printk: UPROBE    IP 0x402bc2.
uprobe-1805730 [036] ....1 674139.123110: bpf_trace_printk: URETPROBE IP 0x402bc2.
```

in /sys/kernel/debug/tracing/trace_pipe.

As you can see, those IPs match exactly.

ARM might need a bit of adjustment, I'm not sure, I think ARM can have
uprobe/uretprobe breakpoint installed not at the very first byte offset within
user space function.

Signed-off-by: Andrii Nakryiko <[email protected]>
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.

1 participant