This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 1/2] initscript: copy uprobes.ko to cache directory


If the uprobes.ko module was built then it will be needed at staprun
time.  Copy the module into the cache directory alongside compiled
scripts.

This patch uses the stap -k option to keep the temporary build directory
around.  The uprobes.ko module file can be found in there.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 initscript/systemtap.in | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/initscript/systemtap.in b/initscript/systemtap.in
index 2d770e4..7e9c680 100755
--- a/initscript/systemtap.in
+++ b/initscript/systemtap.in
@@ -457,7 +457,7 @@ prepare_stat_dir () {
 }
 
 compile_script () { # script checkcache
-  local opts f tmpdir ret
+  local opts f tmpdir ret stap_tmpdir
   eval f="$SCRIPT_PATH/$1.stp"
   if [ ! -f "$f" ]; then
     if [ $ALLOW_CACHEONLY -eq 1 ]; then
@@ -489,8 +489,19 @@ compile_script () { # script checkcache
     return 1
   fi
   pushd "$tmpdir" &> /dev/null
-  logex $STAP -m "$1" -p4 -r $KRELEASE $opts "$f"
+  log "Exec: $STAP -m \"$1\" -p4 -r $KRELEASE -k $opts \"$f\""
+  $STAP -m "$1" -p4 -r $KRELEASE -k $opts "$f" >stap.outerr 2>&1
   ret=$?
+  cat stap.outerr >> "$LOG_FILE"
+  stap_tmpdir=$(grep 'Keeping temporary directory' stap.outerr | \
+                sed 's/^Keeping temporary directory "\([^"]*\)"/\1/')
+  if [ $ret -eq 0 ]; then
+    if [ -f "$stap_tmpdir/uprobes/uprobes.ko" ]; then
+      logex mkdir -p "$CACHE_PATH/uprobes"
+      logex mv "$stap_tmpdir/uprobes/uprobes.ko" "$CACHE_PATH/uprobes/"
+      ret=$?
+    fi
+  fi
   if [ $ret -eq 0 ]; then
     $UNAME -a > "$1.opts"
     echo $opts >> "$1.opts"
@@ -500,6 +511,7 @@ compile_script () { # script checkcache
     slog "Failed to compile script($1)."
   fi
   popd &> /dev/null
+  [ -n "$stap_tmpdir" ] && rm -rf "$stap_tmpdir"
   rm -rf $tmpdir
   [ $ret -eq 0 ] && clog "done" || clog "error"
   return $ret
-- 
1.9.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]