The easier way – dynamic kprobes or kprobe-based event tracing
Similar, but much superior, to how I built a small script in demo 4, to make it easier for us to hook into any kernel function via kprobes, there is a package called perf-tools
(or perf-tools-unstable
). The creator and lead author is Brendan Gregg. Within the useful tools you'll find in this package, a bash script named kprobe
(or kprobe-perf
) is a fantastic wrapper, easily letting us set up kprobes (and kretprobes)!
Assuming you've installed the package (we specified it back in Chapter 1, A General Introduction to Debugging Software), let's go ahead and verify it's there and then run the script (by the way, on my x86_64 Ubuntu 20.04 LTS system, the package name is perf-tools-unstable
and the script is called kprobe-perf
):
# dpkg -l|grep perf-tools ii perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu1 all ...