#!/bin/sh # Released under the GPL # pmf - 2008/07/31 # This script runs LTTV in place in the compile directory without need for # installing it with make install. # # 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 BUILDPATH=$(dirname $0) RCFILE="$(dirname $0)/.runlttvrc" TEXTLIBS="-L ${BUILDPATH}/lttv/modules/text/.libs -m textDump" 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/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/resourceview/.libs -m resourceview "\ #"-L ${BUILDPATH}/lttv/modules/gui/filter/.libs -m guifilter "\ #"-L ${BUILDPATH}/lttv/modules/gui/interrupts/.libs -m interrupts " DEFAULTMODE="gui" 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 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 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 . "$RCFILE"; fi if [ -z "$MODE" ]; then MODE=$DEFAULTMODE fi if [ "$MODE" = "text" ]; then LIBS="$TEXTLIBS" elif [ "$MODE" = "eval" ]; then LIBS="$EVALLIBS" 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 LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs gdb --args $LTTV_EXEC $LTTV_ARGS elif [ "$HELPER" = "valgrind" ]; then LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs 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_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --tool=callgrind $LTTV_EXEC $LTTV_ARGS elif [ "$HELPER" = "massif" ]; then LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs valgrind --tool=massif $LTTV_EXEC $LTTV_ARGS elif [ "$HELPER" = "strace" ]; then LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs strace $LTTV_EXEC $LTTV_ARGS else LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs $LTTV_EXEC $LTTV_ARGS fi