X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=usttrace;h=fe8a5cd8f8c47f80a53a72164c1ac8852d20a1a3;hb=b924c127ff931e20e6de9c88aafad0829c97de29;hp=c77f73114ae97d6e2db7f431f4f03c9714a17dd7;hpb=89a10f62996c8fa75cb2eb90871a705c919ea625;p=ust.git diff --git a/usttrace b/usttrace index c77f731..fe8a5cd 100755 --- a/usttrace +++ b/usttrace @@ -3,13 +3,14 @@ # usttrace by Pierre-Marc Fournier 2009 # Distributed under the GPLv2. -USTD="./ustd/ustd" -LIBINTERFORK_PATH="./libinterfork/.libs/libinterfork.so" -LIBMALLOCWRAP_PATH="./libmallocwrap/.libs/libmallocwrap.so" +USTTRACE_DIR="$(dirname $0)" +USTD="${USTTRACE_DIR}/ustd/ustd" +LIBINTERFORK_PATH="${USTTRACE_DIR}/libinterfork/.libs/libinterfork.so" +LIBMALLOCWRAP_PATH="${USTTRACE_DIR}/libmallocwrap/.libs/libmallocwrap.so" -STD_LDLIBRARY_UST="./libust/.libs:../liburcu" +STD_LDLIBRARY_UST="${USTTRACE_DIR}/libust/.libs" -BASE_TRACE_DIR="$HOME/.usttraces" +BASE_TRACE_DIR="${HOME}/.usttraces" function usage () { echo "usage: $0 OPTIONS COMMAND" 2>/dev/stderr @@ -36,14 +37,20 @@ while getopts ":hlLmfs" options; do s) arg_syswide_daemon=1;; h) usage; exit 0;; - \?) echo $usage + \?) usage exit 1;; - *) echo $usage + *) usage exit 1;; esac done shift $(($OPTIND - 1)) +if [ ! -x "$USTD" ]; +then + error "specified path to ustd not executable ($USTD)" + exit 1 +fi + # Prepare vars CMD=$1 @@ -70,18 +77,14 @@ SOCKPATH="/tmp/ust-sock-$$" if [ "$arg_syswide_daemon" != "1" ]; then + pidfilepath="/tmp/usttrace-$USER-$(date +%Y%m%d%H%M%S%N)-ustd-pid" + # Start daemon - $USTD -s "$SOCKPATH" -o "$OUTDIR" 2>&1 >"$OUTDIR/ustd.log" & - USTDPID="$!" + $USTD -d --pidfile "$pidfilepath" -s "$SOCKPATH" -o "$OUTDIR" >"$OUTDIR/ustd.log" 2>&1 & + USTDPID="$(<$pidfilepath)" export UST_DAEMON_SOCKET="$SOCKPATH" fi -# Wait for the daemon to settle -# If we don't, the process may try to connect to its socket before -# it's ready. -# FIXME: is there a way to make sure this works every time? -sleep 0.5 - # Establish the environment for the command export UST_TRACE=1 export UST_AUTOPROBE=1 @@ -127,6 +130,8 @@ then echo "Waiting for ustd to shutdown..." wait "$USTDPID" + + rm "$pidfilepath" fi echo "Trace was output in: " $OUTDIR