update version
[lttv.git] / runlttv
diff --git a/runlttv b/runlttv
index 86edfd3f8cb2efdff07279d0d76f5d80f634a539..e26fc6ff05b7ab5d9f644fc7f1ba5c0a509da9c9 100755 (executable)
--- a/runlttv
+++ b/runlttv
@@ -5,26 +5,15 @@
 # This script runs LTTV in place in the compile directory without need for
 # installing it with make install.
 #
-# Run with the TF environment variable set to a trace directory to open it.
-#     ex: TF=/my/trace ./runlttv
-# 
-# The .runlttvrc file can be used to control its behavior.
-# - by setting the TRACEFILE variable, a trace can be automatically loaded
-#     ex: TRACEFILE="-t /tmp/traces/dijkstra-20071212"
-# - by setting the ARGS variable, a different set of plugins can be loaded
-#     for an example see the ARGS= line below
-#
 # In order for icons to display correctly, it might be necessary to create a
 # symlink:
 #   $ ln -s ./lttv/modules/gui/lttvwindow/pixmaps
 # while in the same directory as this script.
 
+PROGNAME=$0
 RCFILE="$(dirname $0)/.runlttvrc"
-
-if [ "$MODE" = "text" ]; then
-       ARGS="-L lttv/modules/text/.libs -m textDump"
-else
-       ARGS="-L lttv/modules/gui/lttvwindow/lttvwindow/.libs -m lttvwindow "\
+TEXTLIBS="-L lttv/modules/text/.libs -m textDump"
+GRAPHLIBS="-L lttv/modules/gui/lttvwindow/lttvwindow/.libs -m lttvwindow "\
 "-L lttv/modules/gui/controlflow/.libs -m guicontrolflow "\
 "-L lttv/modules/gui/detailedevents/.libs -m guievents "\
 "-L lttv/modules/gui/tracecontrol/.libs -m guitracecontrol "\
@@ -33,7 +22,19 @@ else
 "-L lttv/modules/gui/filter/.libs -m guifilter "\
 "-L lttv/modules/gui/interrupts/.libs -m interrupts "\
 "-L lttv/modules/gui/histogram/.libs -m guihistogram"
-fi
+DEFAULTMODE="gui"
+
+function usage {
+       echo "Usage: $0 [OPTION]... [TRACE]..." >/dev/stderr
+       echo "" >/dev/stderr
+       echo "Options:" >/dev/stderr
+       echo -e "\t-m MODE      Output mode (modes: text, gui)" >/dev/stderr
+       echo -e "\t-H HELPER    Invoke LTTV through a helper program" >/dev/stderr
+       echo -e "\t             (helpers: gdb, valgrind, massif, strace)" >/dev/stderr
+       echo -e "\t-b OPTIONS   LTTV options to specify before the module list" >/dev/stderr
+       echo -e "\t-a OPTIONS   LTTV options to specify after the module list" >/dev/stderr
+       echo "" >/dev/stderr
+}
 
 if [ -e "lttv/lttv/.libs/lttv.real" ]; then
        LTTV_EXEC="lttv/lttv/.libs/lttv.real"
@@ -44,27 +45,51 @@ else
        exit 1
 fi
 
-if [ -n "$TF" ]; then
-       TRACEFILE="-t $TF"
-fi
+while getopts "H:m:b:a:h" options; do
+       case $options in
+               H) HELPER=$OPTARG;;
+               m) MODE=$OPTARG;;
+               b) BOPTIONS="$BOPTIONS $OPTARG";;
+               a) AOPTIONS="$AOPTIONS $OPTARG";;
+               h) usage;
+                       exit 0;;
+               \?) usage;
+                       exit 1;;
+       esac
+done
+shift $(($OPTIND - 1))
+
+for trace in $@
+do
+       TRACEFILES="$TRACEFILES -t $trace "
+done
 
 if [ -e "$RCFILE" ]; then
        source "$RCFILE";
 fi
 
-HELPER=$1
+if [ -z "$MODE" ]; then
+       MODE=$DEFAULTMODE
+fi
+
+if [ "$MODE" = "text" ]; then
+       LIBS="$TEXTLIBS"
+elif [ "$MODE" = "gui" ]; then
+       LIBS="$GRAPHLIBS"
+else
+       echo "$PROGNAME: unknown mode -- $MODE" >/dev/stderr
+       exit 1
+fi
+
+LTTV_ARGS="$BOPTIONS $LIBS $TRACEFILES $AOPTIONS"
 if [ "$HELPER" = "gdb" ]; then
-       shift
-       LD_LIBRARY_PATH=ltt/.libs gdb --args $LTTV_EXEC $ARGS $TRACEFILE $@
+       LD_LIBRARY_PATH=ltt/.libs gdb --args $LTTV_EXEC $LTTV_ARGS
 elif [ "$HELPER" = "valgrind" ]; then
-       shift
-       LD_LIBRARY_PATH=ltt/.libs valgrind --track-origins=yes --show-reachable=yes --leak-check=full --error-limit=no $LTTV_EXEC $ARGS $TRACEFILE $@
+       LD_LIBRARY_PATH=ltt/.libs valgrind --track-origins=yes --show-reachable=yes --leak-check=full --error-limit=no $LTTV_EXEC $LTTV_ARGS
 elif [ "$HELPER" = "massif" ]; then
-       shift
-       LD_LIBRARY_PATH=ltt/.libs valgrind --tool=massif $LTTV_EXEC $ARGS $TRACEFILE $@
+       LD_LIBRARY_PATH=ltt/.libs valgrind --tool=massif $LTTV_EXEC $LTTV_ARGS
 elif [ "$HELPER" = "strace" ]; then
-       shift
-       LD_LIBRARY_PATH=ltt/.libs strace $LTTV_EXEC $ARGS $TRACEFILE $@
+       LD_LIBRARY_PATH=ltt/.libs strace $LTTV_EXEC $LTTV_ARGS
 else
-       LD_LIBRARY_PATH=ltt/.libs $LTTV_EXEC $ARGS $TRACEFILE $@
+       LD_LIBRARY_PATH=ltt/.libs $LTTV_EXEC $LTTV_ARGS
 fi
This page took 0.023226 seconds and 4 git commands to generate.