From: Pierre-Marc Fournier Date: Fri, 25 Sep 2009 02:38:12 +0000 (-0400) Subject: runlttv: use cmd line arguments instead of environment variables X-Git-Tag: v0.12.20~33 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ceedc60961208d84e19d531cfa1903f2ae5f9f4a;p=lttv.git runlttv: use cmd line arguments instead of environment variables --- diff --git a/runlttv b/runlttv index 86edfd3f..73b7d8ee 100755 --- a/runlttv +++ b/runlttv @@ -5,15 +5,6 @@ # 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 @@ -21,19 +12,14 @@ 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 "\ -"-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" -fi +function usage { + echo "Usage: $0 OPTIONS TRACES..." >/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 "" >/dev/stderr +} if [ -e "lttv/lttv/.libs/lttv.real" ]; then LTTV_EXEC="lttv/lttv/.libs/lttv.real" @@ -44,15 +30,43 @@ else exit 1 fi -if [ -n "$TF" ]; then - TRACEFILE="-t $TF" -fi - if [ -e "$RCFILE" ]; then source "$RCFILE"; fi -HELPER=$1 +while getopts ":hH:m:" options; do + case $options in + H) HELPER=$OPTARG;; + m) MODE=$OPTARG;; + h) usage; + exit 0;; + \?) usage + exit 1;; + *) usage + exit 1;; + esac +done +shift $(($OPTIND - 1)) + +for trace in $@; +do + TRACEFILE="$TRACEFILE -t $trace " +done + +if [ "$MODE" = "text" ]; then + ARGS="-L lttv/modules/text/.libs -m textDump" +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" +fi + if [ "$HELPER" = "gdb" ]; then shift LD_LIBRARY_PATH=ltt/.libs gdb --args $LTTV_EXEC $ARGS $TRACEFILE $@