]> git.mxchange.org Git - flightgear.git/blob - scripts/debug/debug-fgfs
Connect the FlightGear /environment/turbulence-norm property to the
[flightgear.git] / scripts / debug / debug-fgfs
1 #!/bin/bash
2 # $Id$
3 #
4 #
5 #  To use this script you need
6 #  - a Linux 2.4 system with libc 2.2.* and at least XFree86 4.1
7 #  - the valgrind debugger (http://developer.kde.org/~sewardj/)
8 #  - lots of memory (RAM + swap space > 600MB!) and
9 #  - a fast computer =or= a lot of patience.
10 #
11 #  It is useful (but not required) to compile FlightGear without
12 #  any optimizations (-O0 without -funroll-loops etc.). Otherwise
13 #  the debug messages might not seem to make sense in some cases.
14 #
15 #  The sample suppression file is designed for a SuSE 7.1 system
16 #  with Linux 2.4.18, XFree86 4.2.0 and a 3dfx card. Don't use it
17 #  as it is, but create your own! You will likely have different
18 #  libraries with different bugs.
19 #
20 #  If you have problems with valgrind and FlightGear, don't bother
21 #  the valgrind author -- ask on the flightgear-devel list first!
22 #
23 #
24
25 #  adapt the following two entries to your needs:
26 #
27 fgfs="../../src/Main/fgfs"
28 opt="--disable-game-mode --disable-fullscreen --fdm=magic"
29
30
31
32 gdb="--gdb-attach=yes"
33 cmd=
34 extra=
35
36 while true; do
37         case "$1" in
38         -h|--help)      cat <<-EOF
39                 debug [-r] [-g] [-i] [-b] [-c] [-x] [-h]
40
41                 -r      run fgfs
42                 -g      run fgfs with gdb
43                 -i      interactive valgrind run (default)
44                 -b      valgrind batch run
45                 -c      start gdb with most recent core dump
46                 -x      add some extra pedantic valgrind parameters
47                 -h      show this help screen
48                 EOF
49                 exit 0
50                 ;;
51         -r)     cmd="$fgfs $opt" ;;
52         -g)     cmd="gdb -x .gdbinit $fgfs" ;;
53         -i)     cmd=""; gdb="" ;;
54         -b)     gdb="" ;;
55         -x)     extra="--single-step=yes --optimise=no --cleanup=no --dump-error=1" ;;
56         -c)     core=$(ls -t core* 2>/dev/null|head -1)
57                 if test -z $core; then
58                         echo "$0: there's no core file"
59                         exit 1
60                 fi
61                 cmd="gdb $fgfs $core"
62                 ;;
63         *)      break ;;
64         esac
65         shift
66 done
67
68 if ! test -e "$fgfs"; then
69         echo "$0: there's no fgfs executable $fgfs"
70         exit 2
71 fi
72
73 echo "set args $opt" > .gdbinit
74
75 test -e fgfs.supp || head -14 sample.fgfs.supp > fgfs.supp
76
77 test -z "$cmd" && cmd="nice valgrind $gdb --num-callers=10 --suppressions=fgfs.supp $extra $* $fgfs $opt"
78
79 echo "command: $cmd"
80 exec $cmd
81