3 # A small script to export some variables and run tshark or wireshark in
4 # valgrind on a given capture file.
6 # Copyright 2012 Jeff Morriss <jeff.morriss.ws [AT] gmail.com>
10 # Wireshark - Network traffic analyzer
11 # By Gerald Combs <gerald@wireshark.org>
12 # Copyright 1998 Gerald Combs
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License
16 # as published by the Free Software Foundation; either version 2
17 # of the License, or (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 # Directory containing tshark or wireshark. Default current directory.
31 # Use tshark by default
39 while getopts ":2b:C:lmnpP:rtTYwcevW" OPTCHAR
; do
41 2) COMMAND_ARGS
="-2 $COMMAND_ARGS" ;;
43 C
) COMMAND_ARGS
="-C $OPTARG $COMMAND_ARGS" ;;
44 l
) LEAK_CHECK
="--leak-check=full" ;;
48 p
) TOOL
="callgrind" ;;
50 CALLGRIND_OUT_FILE
="--callgrind-out-file=$OPTARG" ;;
51 r
) REACHABLE
="--show-reachable=yes" ;;
52 t
) TRACK_ORIGINS
="--track-origins=yes" ;;
53 T
) COMMAND_ARGS
="-Vx $COMMAND_ARGS" ;; # "build the Tree"
54 Y
) COMMAND_ARGS
="-Yframe $COMMAND_ARGS" ;; # Run with a read filter (but no tree)
60 COMMAND_ARGS
="-E 0.02"
61 # We don't care about the output of editcap
62 COMMAND_ARGS2
="/dev/null" ;;
63 v
) VERBOSE
="--num-callers=256" ;;
67 *) printf "Unknown option -$OPTARG!\n"
71 shift $
(($OPTIND - 1))
81 printf "Usage: $0 [-2] [-b bin_dir] [-c] [-e] [-C config_profile] [-l] [-m] [-n] [-p] [-r] [-t] [-T] [-w] [-v] /path/to/file.pcap\n"
85 if [ "$BIN_DIR" = "." ]; then
86 export WIRESHARK_RUN_FROM_BUILD_DIRECTORY
=
89 if [ "$TOOL" != "callgrind" ]; then
90 export WIRESHARK_DEBUG_EP_NO_CHUNKS
=
91 export WIRESHARK_DEBUG_SE_NO_CHUNKS
=
92 export WIRESHARK_DEBUG_WMEM_OVERRIDE
=simple
93 export G_SLICE
=always-malloc
# or debug-blocks
96 COMMAND
="$BIN_DIR/$COMMAND"
98 if file $COMMAND |
grep -q "ASCII text"; then
99 if [ -x "`dirname $0`/../libtool" ]; then
100 LIBTOOL
="`dirname $0`/../libtool"
104 LIBTOOL
="$LIBTOOL --mode=execute"
109 $LIBTOOL valgrind
--suppressions=`dirname $0`/vg-suppressions
--tool=$TOOL $CALLGRIND_OUT_FILE $VERBOSE $LEAK_CHECK $REACHABLE $TRACK_ORIGINS $COMMAND $COMMAND_ARGS $PCAP $COMMAND_ARGS2 > /dev
/null