~mozillateam/thunderbird/thunderbird-beta.vivid

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/sh

set -e

# Firefox launcher containing a Profile migration helper for
# temporary profiles used during alpha and beta phases.

# Authors:
#  Alexander Sack <asac@jwsdot.com>
#  Fabien Tassin <fta@sofaraway.org>
#  Steve Langasek <steve.langasek@canonical.com>
#  Chris Coulson <chris.coulson@canonical.com>
# License: GPLv2 or later

MOZ_LIBDIR=/@MOZ_LIBDIR@
MOZ_APP_LAUNCHER=`which $0`
EXE=@MOZ_APP_NAME@
MOZ_APP_NAME=@MOZ_APP_NAME@

export MOZ_APP_LAUNCHER

while [ ! -x $MOZ_LIBDIR/$EXE ] ; do
    if [ -L "$MOZ_APP_LAUNCHER" ] ; then
        MOZ_APP_LAUNCHER=`readlink -f $MOZ_APP_LAUNCHER`
        MOZ_LIBDIR=`dirname $MOZ_APP_LAUNCHER`
    else
        echo "Can't find $MOZ_LIBDIR/$EXE"
        exit 1
    fi
done

usage () {
    $MOZ_LIBDIR/$EXE -h | sed -e 's,/.*/,,'
    echo
    echo "      -g or --debug          Start within debugger"
    echo "      -d or --debugger       Specify debugger to start with (eg, gdb or valgrind)"
    echo "      -a or --debugger-args  Specify arguments for debugger"
}

moz_debug=0
moz_debugger_args=""
moz_debugger="gdb"

while [ $# -gt 0 ]; do
    case "$1" in
        -h | --help )
            usage
            exit 0
            ;;
        -g | --debug )
            moz_debug=1
            shift
            ;;
        -d | --debugger)
            moz_debugger=$2;
            if [ "${moz_debugger}" != "" ]; then
	            shift 2
            else
                echo "-d requires an argument"
                exit 1
            fi
            ;;
        -a | --debugger-args )
            moz_debugger_args=$2;
            if [ "${moz_debugger_args}" != "" ] ; then
                shift 2
            else
                echo "-a requires an argument"
                exit 1
            fi
            ;;
        -- ) # Stop option processing
            shift
            break
            ;;
        * )
            break
            ;;
    esac
done

if [ $moz_debug -eq 1 ] ; then
    case $moz_debugger in
        memcheck)
            debugger="valgrind"
            ;;
        *)
            debugger=$moz_debugger
            ;;
    esac

    debugger=`which $debugger`
    if [ ! -x $debugger ] ; then
        echo "Invalid debugger"
        exit 1
    fi

    case `basename $moz_debugger` in
        gdb)
            exec $debugger $moz_debugger_args --args $MOZ_LIBDIR/$MOZ_APP_NAME "$@"
            ;;
        memcheck)
%%ifdef MOZ_VALGRIND
            export G_SLICE=always-malloc
            export G_DEBUG=gc-friendly
            exec $debugger -v --tool=memcheck --leak-check=full --smc-check=all-non-file $moz_debugger_args $MOZ_LIBDIR/$MOZ_APP_NAME "$@"
%%else
            echo "$MOZ_APP_NAME has not been compiled with valgrind support"
            exit 1
%%endif
            ;;
        *)
            exec $debugger $moz_debugger_args $MOZ_LIBDIR/$MOZ_APP_NAME "$@"
            ;;
    esac
else
    exec $MOZ_LIBDIR/$EXE "$@"
fi