Update the README file to mark the project as unmaintained
[lttv.git] / runlttv
diff --git a/runlttv b/runlttv
index 82296c3e50df15b7a6284fc14b1ee6cd4eb213fe..70e9bf55adb74ee9f6e27164dff2d3d521a712ea 100755 (executable)
--- a/runlttv
+++ b/runlttv
 
 # This script runs LTTV in place in the compile directory without need for
 # installing it with make install.
-# 
-# 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
-# - the LTTV_ARGS environment variable may be used to add additional arguments to lttv
 #
 # 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.
 
-RCFILE=".runlttvrc"
+PROGNAME=$0
+BUILDPATH=$(dirname $0)
+RCFILE="$(dirname $0)/.runlttvrc"
+TEXTLIBS="-L ${BUILDPATH}/lttv/modules/text/.libs -m textDump"
+FORMATEDLIBS="-L ${BUILDPATH}/lttv/modules/text/.libs -m formatedDump"
+EVALLIBS="-L ${BUILDPATH}/lttv/modules/text/.libs -m sync_chain_batch"
+GRAPHLIBS="-L ${BUILDPATH}/lttv/modules/gui/lttvwindow/lttvwindow/.libs -m lttvwindow "\
+"-L ${BUILDPATH}/lttv/modules/gui/detailedevents/.libs -m guievents "\
+"-L ${BUILDPATH}/lttv/modules/gui/histogram/.libs -m guihistogram "\
+"-L ${BUILDPATH}/lttv/modules/gui/resourceview/.libs -m resourceview "\
+"-L ${BUILDPATH}/lttv/modules/gui/controlflow/.libs -m guicontrolflow"
+#"-L ${BUILDPATH}/lttv/modules/gui/tracecontrol/.libs -m guitracecontrol "\
+#"-L ${BUILDPATH}/lttv/modules/gui/statistics/.libs -m guistatistics "\
+#"-L ${BUILDPATH}/lttv/modules/gui/filter/.libs -m guifilter "\
+#"-L ${BUILDPATH}/lttv/modules/gui/interrupts/.libs -m interrupts "
 
-ARGS="-L lttv/modules/gui/controlflow/.libs -m guicontrolflow -L lttv/modules/gui/lttvwindow/lttvwindow/.libs -m lttvwindow -L lttv/modules/gui/detailedevents/.libs -m guievents -L lttv/modules/gui/tracecontrol/.libs -m guitracecontrol -L lttv/modules/gui/statistics/.libs -m guistatistics -L lttv/modules/gui/resourceview/.libs -m resourceview -L lttv/modules/gui/filter/.libs -m guifilter -L lttv/modules/gui/interrupts/.libs -m interrupts -L lttv/modules/gui/histogram/.libs -m guihistogram"
-LTTV_EXEC="lttv/lttv/.libs/lttv.real"
+DEFAULTMODE="gui"
 
-if [ ! -e "$LTTV_EXEC" ]; then
+usage () {
+       echo "Usage: $0 [OPTION]... [TRACE]..." >/dev/stderr
+       echo "" >/dev/stderr
+       echo "Options:" >/dev/stderr
+       printf "\t-m MODE      Output mode (modes: text, eval, gui)\n" >/dev/stderr
+       printf "\t-H HELPER    Invoke LTTV through a helper program\n" >/dev/stderr
+       printf "\t             (helpers: gdb, valgrind, massif, strace, callgrind)\n" >/dev/stderr
+       printf "\t-b OPTIONS   LTTV options to specify before the module list\n" >/dev/stderr
+       printf "\t-a OPTIONS   LTTV options to specify after the module list\n" >/dev/stderr
+       printf "\t-d           Activate LTTV debug level\n" >/dev/stderr
+       echo "" >/dev/stderr
+}
+
+if [ -e "${BUILDPATH}/lttv/lttv/.libs/lttv.real" ]; then
+       LTTV_EXEC="${BUILDPATH}/lttv/lttv/.libs/lttv.real"
+elif [ -e "${BUILDPATH}/lttv/lttv/lttv.real" ]; then
+       LTTV_EXEC="${BUILDPATH}/lttv/lttv/lttv.real"
+else
        echo "error: LTTV should be compiled before running this script." >/dev/stderr
        exit 1
 fi
 
-for a in $@; do
-       eval $(echo $a)"=1"
+while getopts "H:m:b:a:dh" options; do
+       case $options in
+               H) HELPER=$OPTARG;;
+               m) MODE=$OPTARG;;
+               b) BOPTIONS="$BOPTIONS $OPTARG";;
+               a) AOPTIONS="$AOPTIONS $OPTARG";;
+               d) DEBUG_ARGS="--debug"; G_MESSAGES_DEBUG="all";;
+               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";
+       . "$RCFILE";
 fi
 
-ARGS="$ARGS $LTTV_ARGS"
+if [ -z "$MODE" ]; then
+       MODE=$DEFAULTMODE
+fi
 
-echo $dbg
+if [ "$MODE" = "text" ]; then
+       LIBS="$TEXTLIBS"
+elif [ "$MODE" = "format" ]; then
+        LIBS="$FORMATLIBS"
+elif [ "$MODE" = "eval" ]; then
+       LIBS="$EVALLIBS"
+elif [ "$MODE" = "gui" ]; then
+       LIBS="$GRAPHLIBS"
+else
+       echo "$PROGNAME: unknown mode -- $MODE" >/dev/stderr
+       exit 1
+fi
 
-if [ -n "$dbg" ]; then
-       LD_LIBRARY_PATH=ltt/.libs gdb --args $LTTV_EXEC $ARGS $TRACEFILE
-elif [ -n "$valgrind" ]; then
-       LD_LIBRARY_PATH=ltt/.libs valgrind --show-reachable=yes --leak-check=full $LTTV_EXEC $ARGS $TRACEFILE
-elif [ -n "$strace" ]; then
-       LD_LIBRARY_PATH=ltt/.libs strace $LTTV_EXEC $ARGS $TRACEFILE
+LTTV_ARGS="$DEBUG_ARGS $BOPTIONS $LIBS $TRACEFILES $AOPTIONS"
+if [ "$HELPER" = "gdb" ]; then
+       LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs G_MESSAGES_DEBUG=${G_MESSAGES_DEBUG} gdb --args $LTTV_EXEC $LTTV_ARGS
+elif [ "$HELPER" = "valgrind" ]; then
+       LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs G_MESSAGES_DEBUG=${G_MESSAGES_DEBUG} G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind  --show-reachable=yes --leak-check=full --tool=memcheck --suppressions=debug/gtk.suppression --track-origins=yes --error-limit=no $LTTV_EXEC $LTTV_ARGS
+elif [ "$HELPER" = "callgrind" ]; then
+       LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs G_MESSAGES_DEBUG=${G_MESSAGES_DEBUG} G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --tool=callgrind $LTTV_EXEC $LTTV_ARGS
+elif [ "$HELPER" = "massif" ]; then
+       LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs G_MESSAGES_DEBUG=${G_MESSAGES_DEBUG} valgrind --tool=massif $LTTV_EXEC $LTTV_ARGS
+elif [ "$HELPER" = "strace" ]; then
+       LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs G_MESSAGES_DEBUG=${G_MESSAGES_DEBUG} strace $LTTV_EXEC $LTTV_ARGS
 else
-       LD_LIBRARY_PATH=ltt/.libs $LTTV_EXEC $ARGS $TRACEFILE
+       LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs G_MESSAGES_DEBUG=${G_MESSAGES_DEBUG} $LTTV_EXEC $LTTV_ARGS
 fi
This page took 0.023813 seconds and 4 git commands to generate.