From: Benjamin Poirier Date: Fri, 25 Sep 2009 19:44:07 +0000 (-0400) Subject: runlttv: Add options to specify LTTV options X-Git-Tag: v0.12.20~20 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=697977bbabfda699894a1a5d921214191a9b31d9;p=lttv.git runlttv: Add options to specify LTTV options It is possible, from .runlttvrc: * to modify the list of modules loaded in text mode or in graphical mode while still honoring the mode specified in the runlttv command line * to change the default mode while still honoring the mode specified in the runlttv command line from the command line or .runlttvrc: * force the mode * specify traces * specify options that go before (eg. -v) or after (eg. -h) the list of modules Signed-off-by: Benjamin Poirier --- diff --git a/runlttv b/runlttv index 73b7d8ee..e26fc6ff 100755 --- a/runlttv +++ b/runlttv @@ -10,14 +10,29 @@ # $ ln -s ./lttv/modules/gui/lttvwindow/pixmaps # while in the same directory as this script. +PROGNAME=$0 RCFILE="$(dirname $0)/.runlttvrc" +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 "\ +"-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" +DEFAULTMODE="gui" function usage { - echo "Usage: $0 OPTIONS TRACES..." >/dev/stderr + echo "Usage: $0 [OPTION]... [TRACE]..." >/dev/stderr echo "" >/dev/stderr echo "Options:" >/dev/stderr - echo -e "\t-m mode (modes: text)" >/dev/stderr - echo -e "\t-H helper (helpers: gdb, valgrind, massif, strace)" >/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 } @@ -30,55 +45,51 @@ else exit 1 fi -if [ -e "$RCFILE" ]; then - source "$RCFILE"; -fi - -while getopts ":hH:m:" options; do - case $options in - H) HELPER=$OPTARG;; +while getopts "H:m:b:a:h" options; do + case $options in + H) HELPER=$OPTARG;; m) MODE=$OPTARG;; - h) usage; - exit 0;; - \?) usage - exit 1;; - *) usage - exit 1;; - esac + b) BOPTIONS="$BOPTIONS $OPTARG";; + a) AOPTIONS="$AOPTIONS $OPTARG";; + h) usage; + exit 0;; + \?) usage; + exit 1;; + esac done shift $(($OPTIND - 1)) -for trace in $@; +for trace in $@ do - TRACEFILE="$TRACEFILE -t $trace " + TRACEFILES="$TRACEFILES -t $trace " done +if [ -e "$RCFILE" ]; then + source "$RCFILE"; +fi + +if [ -z "$MODE" ]; then + MODE=$DEFAULTMODE +fi + if [ "$MODE" = "text" ]; then - ARGS="-L lttv/modules/text/.libs -m textDump" + LIBS="$TEXTLIBS" +elif [ "$MODE" = "gui" ]; then + LIBS="$GRAPHLIBS" else - ARGS="-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 "\ -"-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" + 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