This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] initscript: automatically detect uprobes dependency
- From: Stefan Hajnoczi <stefanha at redhat dot com>
- To: systemtap at sourceware dot org
- Cc: Jonathan Lebon <jlebon at redhat dot com>, Josh Stone <jistone at redhat dot com>, Stefan Hajnoczi <stefanha at redhat dot com>
- Date: Tue, 9 Sep 2014 16:23:46 +0100
- Subject: [PATCH] initscript: automatically detect uprobes dependency
- Authentication-results: sourceware.org; auth=none
systemtap-initscript scripts that rely on uprobes must be configured
with the --save-uprobes option. This option saves the generated
uprobes.ko module and loads it when running the script.
The uprobes dependency information is actually available at compile time
so we can autodetect as follows:
1. Check if uprobes.ko was generated during compile
2. When uprobes.ko was generated, touch <name>.uprobes in the cache
directory.
3. Add the staprun -u option if <name>.uprobes exists
It is no longer necessary to specify the --save-uprobes option in the
initscript configuration file, although doing so allowed.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
initscript/systemtap.in | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/initscript/systemtap.in b/initscript/systemtap.in
index 683734d..c8219cb 100755
--- a/initscript/systemtap.in
+++ b/initscript/systemtap.in
@@ -495,13 +495,16 @@ compile_script () { # script checkcache
return 1
fi
pushd "$tmpdir" &> /dev/null
- logex $STAP -m "$1" -p4 -r $KRELEASE $opts "$f"
+ logex $STAP -m "$1" -p4 -r $KRELEASE --save-uprobes $opts "$f"
ret=$?
if [ $ret -eq 0 ]; then
if [ -f "uprobes/uprobes.ko" ]; then
+ logex touch "$CACHE_PATH/$1.uprobes"
logex mkdir -p "$CACHE_PATH/uprobes"
logex mv "uprobes/uprobes.ko" "$CACHE_PATH/uprobes/"
ret=$?
+ elif [ -f "$CACHE_PATH/$1.uprobes" ]; then
+ rm "$CACHE_PATH/$1.uprobes"
fi
fi
if [ $ret -eq 0 ]; then
@@ -575,6 +578,10 @@ start_script () { # script
mode=$?
[ $mode -eq 0 ] && return 2
+ if [ -f "$CACHE_PATH/$s.uprobes" ]; then
+ opts="$opts -u$CACHE_PATH/uprobes/uprobes.ko"
+ fi
+
clog " Starting $1 ... " -n
tmpdir=`mktemp -d -p "$TEMP_PATH" cache.XXXXXXXX` # bz7097
if [ $? -ne 0 ]; then
@@ -767,7 +774,7 @@ compile () {
return 1
fi
for s in $SCRIPTS; do
- ss="$ss "`ls "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts" 2> /dev/null`
+ ss="$ss "`ls "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts" "$CACHE_PATH/$s.uprobes" 2> /dev/null`
done
ss=`echo -n $ss`
if [ "$ss" ]; then
@@ -960,7 +967,7 @@ cleanup () {
fi
for s in $SCRIPTS; do
- ss="$ss "`ls "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts" 2> /dev/null`
+ ss="$ss "`ls "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts" "$CACHE_PATH/$s.uprobes" 2> /dev/null`
done
ss=`echo -n $ss`
if [ "$ss" ]; then
@@ -968,7 +975,7 @@ cleanup () {
ask_yesno "Do you really want to remove above caches"
[ $? -eq 0 ] && return 0
for s in $SCRIPTS; do
- logex rm -f "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts"
+ logex rm -f "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts" "$CACHE_PATH/$s.uprobes"
[ $? -ne 0 ] && might_fail $"failed to clean cache $s.ko"
done
might_success "done"
--
1.9.3