2011-10-27 02:32:32 +00:00
|
|
|
#!/bin/bash
|
2012-05-01 18:59:12 +00:00
|
|
|
|
|
|
|
# A small script to export some variables and run tshark or wireshark in
|
|
|
|
# valgrind on a given capture file.
|
|
|
|
#
|
|
|
|
# Copyright 2012 Jeff Morriss <jeff.morriss.ws [AT] gmail.com>
|
2011-10-27 02:32:32 +00:00
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
2012-05-01 18:59:12 +00:00
|
|
|
# Wireshark - Network traffic analyzer
|
|
|
|
# By Gerald Combs <gerald@wireshark.org>
|
|
|
|
# Copyright 1998 Gerald Combs
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2012-06-28 23:18:38 +00:00
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2011-10-27 02:32:32 +00:00
|
|
|
|
|
|
|
# Directory containing tshark or wireshark. Default current directory.
|
|
|
|
BIN_DIR=.
|
|
|
|
|
|
|
|
# Use tshark by default
|
|
|
|
COMMAND=tshark
|
2012-12-02 02:58:29 +00:00
|
|
|
COMMAND_ARGS="-nr"
|
2012-03-16 14:12:01 +00:00
|
|
|
COMMAND_ARGS2=
|
2012-11-09 02:10:48 +00:00
|
|
|
VALID=0
|
|
|
|
PCAP=""
|
2013-05-11 19:03:54 +00:00
|
|
|
TOOL=""
|
2011-10-27 02:32:32 +00:00
|
|
|
|
2013-06-05 21:30:08 +00:00
|
|
|
while getopts ":2b:C:lmnprtTYwcevW" OPTCHAR ; do
|
2011-10-27 02:32:32 +00:00
|
|
|
case $OPTCHAR in
|
2012-07-26 02:38:34 +00:00
|
|
|
2) COMMAND_ARGS="-2 $COMMAND_ARGS" ;;
|
2011-10-27 02:32:32 +00:00
|
|
|
b) BIN_DIR=$OPTARG ;;
|
2012-07-26 02:38:34 +00:00
|
|
|
C) COMMAND_ARGS="-C $OPTARG $COMMAND_ARGS" ;;
|
2011-10-27 02:32:32 +00:00
|
|
|
l) LEAK_CHECK="--leak-check=full" ;;
|
2013-05-11 19:03:54 +00:00
|
|
|
m) TOOL="--tool=massif" ;;
|
2012-11-09 02:10:48 +00:00
|
|
|
n) COMMAND_ARGS="-v"
|
|
|
|
VALID=1 ;;
|
2013-05-23 02:30:40 +00:00
|
|
|
p) TOOL="--tool=callgrind" ;;
|
2012-12-01 20:51:20 +00:00
|
|
|
r) REACHABLE="--show-reachable=yes" ;;
|
2012-04-30 13:20:27 +00:00
|
|
|
t) TRACK_ORIGINS="--track-origins=yes" ;;
|
2012-12-04 00:05:58 +00:00
|
|
|
T) COMMAND_ARGS="-Vx $COMMAND_ARGS" ;; # "build the Tree"
|
2013-06-05 21:30:08 +00:00
|
|
|
Y) COMMAND_ARGS="-Yframe $COMMAND_ARGS" ;; # Run with a read filter (but no tree)
|
2012-07-26 02:38:34 +00:00
|
|
|
w) COMMAND=wireshark
|
|
|
|
COMMAND_ARGS="-nr" ;;
|
|
|
|
c) COMMAND=capinfos
|
|
|
|
COMMAND_ARGS="" ;;
|
|
|
|
e) COMMAND=editcap
|
|
|
|
COMMAND_ARGS="-E 0.02"
|
|
|
|
# We don't care about the output of editcap
|
|
|
|
COMMAND_ARGS2="/dev/null" ;;
|
2013-03-02 21:16:32 +00:00
|
|
|
v) VERBOSE="--num-callers=256" ;;
|
2013-03-15 16:42:05 +00:00
|
|
|
W) COMMAND=wireshark
|
|
|
|
COMMAND_ARGS=""
|
|
|
|
VALID=1 ;;
|
2012-12-02 02:58:29 +00:00
|
|
|
*) printf "Unknown option -$OPTARG!\n"
|
|
|
|
exit ;;
|
2011-10-27 02:32:32 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
|
2012-11-09 02:10:48 +00:00
|
|
|
if [ $# -ge 1 ]
|
2011-10-27 02:32:32 +00:00
|
|
|
then
|
2012-11-09 02:10:48 +00:00
|
|
|
PCAP=$1
|
|
|
|
VALID=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $VALID -eq 0 ]
|
|
|
|
then
|
2013-06-19 18:06:46 +00:00
|
|
|
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"
|
2012-07-26 02:38:34 +00:00
|
|
|
exit 1
|
2011-10-27 02:32:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$BIN_DIR" = "." ]; then
|
|
|
|
export WIRESHARK_RUN_FROM_BUILD_DIRECTORY=
|
|
|
|
fi
|
|
|
|
|
|
|
|
export WIRESHARK_DEBUG_EP_NO_CHUNKS=
|
|
|
|
export WIRESHARK_DEBUG_SE_NO_CHUNKS=
|
2012-12-27 22:51:33 +00:00
|
|
|
export WIRESHARK_DEBUG_WMEM_OVERRIDE=simple
|
2011-10-27 02:32:32 +00:00
|
|
|
export G_SLICE=always-malloc # or debug-blocks
|
|
|
|
|
2013-05-28 22:29:02 +00:00
|
|
|
./libtool --mode=execute valgrind $TOOL $VERBOSE $LEAK_CHECK $REACHABLE $TRACK_ORIGINS $BIN_DIR/$COMMAND $COMMAND_ARGS $PCAP $COMMAND_ARGS2 > /dev/null
|