systemtap: a linux trace/probe tool
visit the project web site at <http://sourceware.org/systemtap>,
for documentation and mailing lists for developers and users.
this is free software.
see the copying file for redistribution/modification terms.
see the install file for generic build instructions.
see the hacking file for contribution advice.
prerequisites:
- linux kernel
- kernel module build environment (kernel-devel rpm) and/or dyninst
- optionally, debugging information for kernel/user-space being instrumented
- c compiler (same as what kernel was compiled with)
- elfutils with libdwfl for debugging information parsing
- root privileges
installation steps:
- install any debuginfo packages you need, for kernel and/or userspace.
on modern fedora, # debuginfo-install kernel [...]
(beware of confusion between kernel vs. kernel-debug vs kernel-pae etc.
variants. each likely has a corresponding development and debuginfo
package.)
- install the systemtap package.
on modern fedora, # yum install systemtap systemtap-runtime
build steps:
- consider installing the kernel-debuginfo, kernel-devel, gcc and
dependent packages (or see below if you are building your own
kernels from source). if using only the pure-userspace dyninst
backend, install gcc and dyninst-devel.
- if available, install your distribution's copy of elfutils and its
development headers/libraries.
or if desired, download an elfutils source release to build in
"bundled mode" (below), and untar it into some new directory.
or if desired, build elfutils separately one time, and install
it to /usr/local.
see http://fedorahosted.org/elfutils/
version 0.151 is recommended for i386 hosts probing prelinked programs.
(pr12141)
- on modern fedora, install general optional build-requisites:
# yum-builddep systemtap
on modern debian/ubuntu, similarly:
# apt-get build-dep systemtap
- download systemtap sources:
http://sourceware.org/systemtap/ftp/releases/
http://sourceware.org/systemtap/ftp/snapshots/
(or)
git clone git://sourceware.org/git/systemtap.git
(or) http://sourceware.org/git/systemtap.git
- build systemtap normally:
% .../configure [other autoconf options]
or, with build it with a bundled internal copy of elfutils:
% .../configure --with-elfutils=elfutils-source-dir [other autoconf options]
(note that elfutils > 0.139 requires gcc > 4.0 or else the
appropriate elfutils-portability.patch. ensure decompression
library headers/libraries are installed for elfutils' use.)
consider configuring with "--enable-dejazilla" to automatically
contribute to our public test result database.
consider configuring with "--prefix=directory" to specify an
installation directory other than /usr/local. it can be an ordinary
personal directory.
% make all
# make install
to uninstall systemtap:
# make uninstall
- run systemtap:
to run systemtap after installation, add $prefix/bin to your $path, or
refer to $prefix/bin/stap directly. if you keep your build tree
around, you can also use the "stap" binary there.
some samples should be available under $prefix/share/doc/systemtap/examples.
for the normal linux-kernel-module based backend, run "stap" as
root. if desired, create "stapdev" and "stapusr" entries in
/etc/groups. any users in "stapdev"+"stapusr" will be able to run
systemtap as if with root privileges. users in "stapusr" only may
launch (with "staprun") pre-compiled probe modules (created by "stap
-p4 ...") that a system administrator copied under
/lib/modules/`uname -r`/systemtap. "stapusr" may also be permitted
to create arbitrary unprivileged systemtap scripts of their own.
see readme.unprivileged for additional setup instructions.
to run a simple test.
# stap -v -e 'probe vfs.read {printf("read performed\n"); exit()}'
to run the full test suite from the build tree.
# make installcheck
for the prototype dyninst pure-userspace backend, run "stap" as any user.
% stap --runtime=dyninst -e 'probe process.function("*") {
println(pn(), ":", $$parms) }' -c 'ls'
tips:
- by default, systemtap looks for the debug info in these locations:
/boot/vmlinux-`uname -r`
/usr/lib/debug/lib/modules/`uname -r`/vmlinux
/lib/modules/`uname -r`/vmlinux
/lib/modules/`uname -r`/build/vmlinux
building a kernel.org kernel:
- consider applying the utrace kernel patches, if you wish to probe
user-space applications. http://sourceware.org/systemtap/wiki/utrace
or if your kernel is near 3.5, apply the uprobes and related patches
(see news). or if your kernel is >= 3.5, enjoy the built-in uprobes.
- build the kernel using your normal procedures. enable
config_debug_info, config_kprobes, config_relay, config_debug_fs,
config_modules, config_module_unload, config_utrace if able
- % make modules_install install headers_install
- boot into the kernel.
- if you wish to leave the kernel build tree in place, simply run
% stap -r /path/to/kernel/build/tree [...]
you're done.
- or else, if you wish to install the kernel build/debuginfo data into
a place where systemtap will find it without the "-r" option:
% ln -s /path/to/kernel/build/tree /lib/modules/release/build
- instead of using the "-r" option, you can also use the environment
variable systemtap_release to direct systemtap to the kernel data.