make lttv runnable from anywhere
[lttv.git] / runlttv
1 #!/bin/sh
2 # Released under the GPL
3 # pmf - 2008/07/31
4
5 # This script runs LTTV in place in the compile directory without need for
6 # installing it with make install.
7 #
8 # In order for icons to display correctly, it might be necessary to create a
9 # symlink:
10 # $ ln -s ./lttv/modules/gui/lttvwindow/pixmaps
11 # while in the same directory as this script.
12
13 PROGNAME=$0
14 BUILDPATH=$(dirname $0)
15 RCFILE="$(dirname $0)/.runlttvrc"
16 TEXTLIBS="-L ${BUILDPATH}/lttv/modules/text/.libs -m textDump"
17 GRAPHLIBS="-L ${BUILDPATH}/lttv/modules/gui/lttvwindow/lttvwindow/.libs -m lttvwindow "\
18 "-L ${BUILDPATH}/lttv/modules/gui/controlflow/.libs -m guicontrolflow "\
19 "-L ${BUILDPATH}/lttv/modules/gui/detailedevents/.libs -m guievents "\
20 "-L ${BUILDPATH}/lttv/modules/gui/tracecontrol/.libs -m guitracecontrol "\
21 "-L ${BUILDPATH}/lttv/modules/gui/statistics/.libs -m guistatistics "\
22 "-L ${BUILDPATH}/lttv/modules/gui/resourceview/.libs -m resourceview "\
23 "-L ${BUILDPATH}/lttv/modules/gui/filter/.libs -m guifilter "\
24 "-L ${BUILDPATH}/lttv/modules/gui/interrupts/.libs -m interrupts "\
25 "-L ${BUILDPATH}/lttv/modules/gui/histogram/.libs -m guihistogram"
26 DEFAULTMODE="gui"
27
28 usage () {
29 echo "Usage: $0 [OPTION]... [TRACE]..." >/dev/stderr
30 echo "" >/dev/stderr
31 echo "Options:" >/dev/stderr
32 printf "\t-m MODE Output mode (modes: text, gui)\n" >/dev/stderr
33 printf "\t-H HELPER Invoke LTTV through a helper program\n" >/dev/stderr
34 printf "\t (helpers: gdb, valgrind, massif, strace)\n" >/dev/stderr
35 printf "\t-b OPTIONS LTTV options to specify before the module list\n" >/dev/stderr
36 printf "\t-a OPTIONS LTTV options to specify after the module list\n" >/dev/stderr
37 echo "" >/dev/stderr
38 }
39
40 if [ -e "${BUILDPATH}/lttv/lttv/.libs/lttv.real" ]; then
41 LTTV_EXEC="${BUILDPATH}/lttv/lttv/.libs/lttv.real"
42 elif [ -e "${BUILDPATH}/lttv/lttv/lttv.real" ]; then
43 LTTV_EXEC="${BUILDPATH}/lttv/lttv/lttv.real"
44 else
45 echo "error: LTTV should be compiled before running this script." >/dev/stderr
46 exit 1
47 fi
48
49 while getopts "H:m:b:a:h" options; do
50 case $options in
51 H) HELPER=$OPTARG;;
52 m) MODE=$OPTARG;;
53 b) BOPTIONS="$BOPTIONS $OPTARG";;
54 a) AOPTIONS="$AOPTIONS $OPTARG";;
55 h) usage;
56 exit 0;;
57 \?) usage;
58 exit 1;;
59 esac
60 done
61 shift $(($OPTIND - 1))
62
63 for trace in $@
64 do
65 TRACEFILES="$TRACEFILES -t $trace "
66 done
67
68 if [ -e "$RCFILE" ]; then
69 . "$RCFILE";
70 fi
71
72 if [ -z "$MODE" ]; then
73 MODE=$DEFAULTMODE
74 fi
75
76 if [ "$MODE" = "text" ]; then
77 LIBS="$TEXTLIBS"
78 elif [ "$MODE" = "gui" ]; then
79 LIBS="$GRAPHLIBS"
80 else
81 echo "$PROGNAME: unknown mode -- $MODE" >/dev/stderr
82 exit 1
83 fi
84
85 LTTV_ARGS="$BOPTIONS $LIBS $TRACEFILES $AOPTIONS"
86 if [ "$HELPER" = "gdb" ]; then
87 LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs gdb --args $LTTV_EXEC $LTTV_ARGS
88 elif [ "$HELPER" = "valgrind" ]; then
89 LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs valgrind --track-origins=yes --show-reachable=yes --leak-check=full --error-limit=no $LTTV_EXEC $LTTV_ARGS
90 elif [ "$HELPER" = "massif" ]; then
91 LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs valgrind --tool=massif $LTTV_EXEC $LTTV_ARGS
92 elif [ "$HELPER" = "strace" ]; then
93 LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs strace $LTTV_EXEC $LTTV_ARGS
94 else
95 LD_LIBRARY_PATH=${BUILDPATH}/ltt/.libs $LTTV_EXEC $LTTV_ARGS
96 fi
This page took 0.033015 seconds and 5 git commands to generate.