This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Cross compiling systemtap scripts
- From: William Cohen <wcohen at redhat dot com>
- To: SystemTAP <systemtap at sources dot redhat dot com>
- Date: Thu, 24 Jul 2008 18:05:38 -0400
- Subject: Cross compiling systemtap scripts
Hi All,
There is some documentation on the wiki that describes how to generated
instrumentation on a host for a target machine:
http://sourceware.org/systemtap/wiki/TipCrossCompiling
However, one of the things missing from is is where to get the various RPMs. I
have written some more detailed documentation describing where to get the
appropriate rpms for Fedora and RHEL-5. Seems that the fedora yum repositories
are purged of those files quite often. The writeup has some cookbooks steps on
how to get the rpms. Any comments and corrections on the documentation would be
appreciated.
-Will
How to Build SystemTap Instrumentation for Use on Other Computer Systems
There are cases where it is desirable to run SystemTap instrumentation
on a machine that does not have software installed to translate a
systemtap script into instrumentation. It is possible to run systemtap
in a host-target manner where the host computer generates the
instrumentation and the target computer runs the instrumentation.
This documents outlines how to do this on Red Hat Enterprise Linux 5
and Fedora 9.
SystemTap do not handle true cross compilation. Both host and target
computer systems need to be the same architecture family (for example
both x86_64) and need to be running the same distribution of
Linux. However, they can be running different versions of the kernel
and other software.
The host computer system will generate the instrumentation for the
target computer system. For the host to be able to generate
appropriate instrumentation it will need the following RPMs installed
on the host system:
systemtap
systemtap-runtime
kernel version that matches target machine
kernel-devel version that matches target machine
kernel-devel version that matches target machine
kernel-debuginfo version that matches target machine
wget (for Fedora download procedure)
yum-utils (for RHEL-5 download procedure)
The target machine will need the following RPM installed:
systemtap-runtime
You can find the version of the kernel on the target machine with:
uname -r
Armed with the information about the kernel on the target machine you
can download and install the appropriate kernel-devel and
kernel-debuginfo RPMs. The list of commands below will download and
install the appropriate rpms for Fedora to build instrumentation for
another machine. You will need to adjust UNAME and KERNEL variable to
suit local conditions. The rpm command will need to run as root:
#change UNAME and KERNEL to appropriate values
UNAME="2.6.25.9-76.fc9.x86_64"
KERNEL="kernel" # "kernel-PAE" or "kernel-smp" also alternatives
DIR=`mktemp -d`
pushd $DIR
KERN_ARCH=$(uname -m)
KERN_REV=`echo $UNAME | sed s/.$KERN_ARCH//`
KERN_VER=`echo $KERN_REV | awk -F- '{print $1}'`
KERN_BUILD=`echo $KERN_REV | awk -F- '{print $2}'`
URL_BASE="http://kojipkgs.fedoraproject.org/packages"
URL_DIR="${URL_BASE}/kernel/${KERN_VER}/${KERN_BUILD}/${KERN_ARCH}"
wget -r -l1 -nd --no-parent $URL_DIR \
-A "$KERNEL-debuginfo*","$KERNEL-devel*","$KERNEL-$KERN_REV*"
RPMS=$(ls kernel*${KERN_REV}*.rpm)
rpm --force -iv $RPMS
popd
#cleanup
rm -r $DIR
A similar set of commands can be used on Red Hat Enterprise Linux 5 to
download and install the RPMs (BOTH the yumdownloader and the rpm
commands need to be run as root):
#change UNAME and KERNEL to appropriate values
UNAME="2.6.18-92.1.1.el5"
KERNEL="kernel" # "kernel-PAE" or "kernel-smp" also alternatives
DIR=`mktemp -d`
pushd $DIR
KERN_ARCH=$(uname -m)
#KERN_REV value from target "uname -r" minus the arch
KERN_REV=`echo $UNAME | sed s/.$KERN_ARCH//`
yumdownloader --enablerepo=rhel-debuginfo \
"$KERNEL-debuginfo*$KERN_REV" "$KERNEL-debuginfo-common*$KERN_REV" \
$KERNEL-devel-$KERN_REV $KERNEL-$KERN_REV
RPMS=$(ls kernel*${KERN_REV}*.rpm)
rpm --force -iv $RPMS
popd
#cleanup
rm -r $DIR
The systemtap instrumentation can be generated on the host computer
with the the following command:
stap -r 2.6.25.9-76.fc9.x86_64 iotop.stp -m iotop
The "-r 2.6.25.9-76.fc9.x86_64" indicates that the instrumentation
should be generated for a specific kernel; this options also
implicitly indicates that systemtap should only generate the
instrumentation and not run it. The "iotop.stp" is the actual
SystemTap script being compiled. The "-m iotop" names the kernel
module. Once systemtap has compiled generating the instrumentation
module, kernel module named "iotop.ko" will be placed in the current
directory. This kernel module should be copied to the target computer.
On the target computer the following rpm will need to be installed:
systemtap-runtime
You can run the compile instrumentation on the target machine with:
staprun iotop.ko
This generates output like the following:
Process KB Read KB Written
stapio 3328 0
at-spi-registry 588 0
Xorg 400 0
gdm-simple-gree 44 0
sshd 16 0
gnome-power-man 12 0
irqbalance 6 0
sendmail 1 0
Just like regular systemtap running, a control-c will stop the
instrumentation with staprun. The staprun command can also take
options additional options:
-v Be verbose.
-c CMD Run CMD and exit when CMD exits.
-x PID Set '_stp_target' to PID.
-o FILE Write output to FILE.