On this page
ftrace and bpftrace User-Space Tracing
Coverage: uprobe → USDT (DTrace probes) → bpftrace user-space scripts → perf probe on userspace → User-space dynamic tracing panorama Applicable to: Linux + bpftrace/bcc/perf
uprobe: User-Space Function Probes
# uprobe: Place probes at the entry/return of any user-space function
# Syntax: uprobe:<binary>:<function>
# Example: Trace readline in bash:
# → Each time bash calls readline → record
# With arguments:
# cmd: The first argument after the function returns (%si=x0 on ARM, %rdi on x86)
# uretprobe: On function return
USDT: Pre-planted Static Probes
// USDT (User Statically Defined Tracing): Similar to DTrace probes
// Planted at compile time, zero overhead (NOP) at runtime → until activated
;
// → Compiled into a NOP sled → Replaced with INT3 breakpoint by uprobe at runtime
// View USDT probes embedded in the binary:
bpftrace -l 'usdt:/path/to/binary:*'
readelf -n /path/to/binary | grep NT_STAPSDT
bpftrace: User-Space Tracing
# One-line trace:
# Histogram:
# Statistics:
# By process:
# Trace function latency:
# Trace open calls (with filename):
bcc User-Space Tools
# bcc: High-level wrapper of Python + BPF
# Pre-compiled tools (located in /usr/share/bcc/tools/):
# Use case: No need to write BPF programs → Use pre-compiled tools directly
Combination with Kernel Tracing
# Complete chain from user-space to kernel-space:
Debugging Tips
# Find functions in a binary that can be probed:
| | |
# View installed uprobes:
# View perf probes:
# Cleanup:
References
- Tools: bpftrace (github.com/bpftrace), bcc (github.com/iovisor/bcc)
- Documentation:
man perf-probe, Brendan Gregg's blog - LWN: "Uprobes and USDT", "Dynamic tracing with bpftrace"
Keywords: uprobe, uretprobe, USDT, DTRACE_PROBE, bpftrace, bcc, user-space tracing, SDT