Kprobes: Difference between revisions
| Line 13: | Line 13: | ||
To add, trace, and destroy a kprobe, use the <tt>kprobe</tt> binary (sometimes known as <tt>kprobe-perf</tt>) from the [[perf]] toolkit. | To add, trace, and destroy a kprobe, use the <tt>kprobe</tt> binary (sometimes known as <tt>kprobe-perf</tt>) from the [[perf]] toolkit. | ||
The primary means for working with longterm kprobes from userspace is | The primary means for working with longterm kprobes from userspace is debugfs (typically mounted at <tt>/sys/kernel/debug</tt>) and the [[perf]] tool. Note that <tt>/sys/kernel/debug/tracing/events/kprobes</tt> will not appear until you have enabled at least one kprobe. | ||
{|class="wikitable" | {|class="wikitable" | ||
! Task !! sysfs !! perf | ! Task !! sysfs !! perf | ||
|- | |- | ||
| List functions suitable for probing | | List functions suitable for probing | ||
|| read <tt> | || read <tt>debug/tracing/available_filter_functions</tt> | ||
|| <tt>perf probe -F</tt> (note: in my experience, this always lacks a few available from the sysfs list. i'm unsure why.) | || <tt>perf probe -F</tt> (note: in my experience, this always lacks a few available from the sysfs list. i'm unsure why.) | ||
|- | |- | ||
| List registered kprobes | | List registered kprobes | ||
|| read <tt> | || read <tt>debug/kprobes/list</tt> | ||
|| ? | || ? | ||
|- | |- | ||
| List probe events || read <tt> | | List probe events || read <tt>debug/tracing/kprobe_events</tt> || <tt>perf probe -l</tt> | ||
|- | |- | ||
| Add kprobe || write <tt> | | Add kprobe || write <tt>debug/tracing/kprobe_events</tt> | ||
|| <tt>perf probe -a</tt> | || <tt>perf probe -a</tt> | ||
|- | |- | ||
| Line 35: | Line 35: | ||
|- | |- | ||
| Enable kprobe | | Enable kprobe | ||
|| write <tt> | || write <tt>debug/tracing/events/kprobes/NAME/enable</tt> | ||
|| ? | || ? | ||
|- | |- | ||
|} | |} | ||