<itemizedlist>
<listitem><para>The "Client Request" mechanism</para></listitem>
+ <listitem><para>Debugging your program using Valgrind's gdbserver
+ and GDB</para></listitem>
<listitem><para>Function Wrapping</para></listitem>
</itemizedlist>
<para>To debug a program "<filename>prog</filename>" running under
Valgrind, you must ensure that the Valgrind gdbserver is activated by
specifying either <option>--vgdb=yes</option>
-or <option>--vgdb=full</option>). A secondary command line option,
+or <option>--vgdb=full</option>. A secondary command line option,
<option>--vgdb-error=number</option>, can be used to tell the gdbserver
only to become active once the specified number of errors have been
reported. A value of zero will therefore cause
lines, when given in a shell, will cause the same leak search to be executed
by the process 3145:
<screen><![CDATA[
-vgdb --pid=3145 leak_check any full reachable
+vgdb --pid=3145 leak_check full reachable any
vgdb --pid=3145 l f r a
]]></screen></para>
bytes. The Valgrind gdbserver does not have any limitation on the
number of simulated hardware watchpoints. It also has no
limitation on the length of the memory zone being
- watched. However, GDB currently does not understand that
- Valgrind gdbserver watchpoints have no length limit. A GDB patch
- providing a command "set remote hardware-watchpoint-length-limit"
- has been developped. Integration of this patch into GDB would
- allow full use of the flexibility of the Valgrind gdbserver's
- simulated hardware watchpoints.
+ watched. Using GDB version 7.4 or later allow full use of the
+ flexibility of the Valgrind gdbserver's simulated hardware watchpoints.
+ Previous GDB versions do not understand that Valgrind gdbserver
+ watchpoints have no length limit.
</para>
<para>Memcheck implements hardware watchpoint simulation by
marking the watched address ranges as being unaddressable. When
<listitem>
<para><varname>v.info gdbserver_status</varname> shows the
gdbserver status. In case of problems (e.g. of communications),
- this showns the values of some relevant Valgrind gdbserver internal
+ this shows the values of some relevant Valgrind gdbserver internal
variables. Note that the variables related to breakpoints and
watchpoints (e.g. the number of breakpoint addresses and the number of
watchpoints) will be zero, as GDB by default removes all
gdbserver_tests/make_local_links /path/to/another/gdb
perl tests/vg_regtest gdbserver_tests
-The minimum version to use the Valgrind gdbserver is gdb >= 6.5.
+The minimum version to run the tests is gdb >= 6.5.
Previous versions do not have the 'target remote |' command. It
- would be possible to use an older version by having a tcp relay
- application between gdb and vgdb (or, alternatively, change vgdb
- so that it could read/write from/to a tcpip socket rather than
- read/write from stdin/stdout.
+ would be possible to use an older version by using the option
+ --port of vgdb, and using the tcp/ip variant of the 'target remote'
+ GDB command.
-The tests have been run on various platforms using gdb 7.2
+The tests have been run on various platforms using gdb versions >= 7.2
and on some platforms gdb 7.0 and 7.1.
Some gdb tests implies a gdb >= 7.2. (these are automatically disabled
if testing with a lower version).
#
# Make local links in the gdbserver_tests directory
# so that tests needing gdb can be disabled if
-# a tool old version of gdb is provided or if no gdb is
+# a too old version of gdb is provided or if no gdb is
# provided.
#
# The vgdb link is needed either for gdb tests
exit 1
fi
+
+export GDB=""
+export GDBVERSIONLINE=""
+export GDBMAJ=""
+export GDBMIN=""
+
+# $1 = Major.Minor gdb version needed
+# $2 = marker file to touch (if version ok) or to remove (version not ok)
+# $3 and following: msg in output
+check_version()
+{
+ NEEDED=$1
+ shift
+ NEEDEDMAJ=$(echo $NEEDED | awk -F\. '{ print $1 }')
+ NEEDEDMIN=$(echo $NEEDED | awk -F\. '{ print $2 }')
+
+ MARKERFILE=$1
+ shift
+
+ if [ \( $GDBMAJ -gt $NEEDEDMAJ \) \
+ -o \( \( $GDBMAJ -eq $NEEDEDMAJ \) \
+ -a \( $GDBMIN -ge $NEEDEDMIN \) \) ]
+ then
+ if [ ! -f $MARKERFILE ]
+ then
+ touch $MARKERFILE
+ fi
+ else
+ echo "$@" "suppressed as $GDB version" $GDBVERSIONLINE "is <" $NEEDED
+ rm -f $MARKERFILE
+ fi
+}
+
if [ -x "$1" ]
then
- ln -f -s "$1" gdbserver_tests/gdb
- # Try to extract the gdb version.
- VERSIONLINE=`gdbserver_tests/gdb --version | head -n 1`
- VERSION=`echo $VERSIONLINE |
- sed -e 's/[^0-9\.]//g' -e 's/\./ /g'`
+ GDB=$1
+ ln -f -s "$GDB" gdbserver_tests/gdb
+ # Try to extract the gdb version major and minor numbers.
+ # We assume these are the first two integers separated by a .
+ GDBVERSIONLINE=`gdbserver_tests/gdb --version | head -n 1`
+ GDBMAJ=`echo $GDBVERSIONLINE | sed -e 's/[^0-9\.]//g' |
+ awk -F\. '{print $1}'`
+ GDBMIN=`echo $GDBVERSIONLINE | sed -e 's/[^0-9\.]//g' |
+ awk -F\. '{print $2}'`
# We need at least a 6.5 version to use the Valgrind gdbserver.
- # However, the tests are only supported/maintained for gdb >= 7
- VERSIONOK=`echo $VERSION |
- awk '{ if ($1 >= 7) print "version ok"}'`
- if [ "$VERSIONOK" = "" ]
- then
- echo "gdbserver tests suppressed as $1 version is < 6.5: " $VERSIONLINE
- rm -f gdbserver_tests/gdb
- fi
+ # However, the gdb tests are only supported/maintained for gdb >= 7
+ check_version 7.0 gdbserver_tests/gdb "gdbserver gdb tests"
- # We need at least a 7.1 version to run the 'pic' executable test
+ # We need at least a 7.1 version to run the 'pic' executable tests
# (with 7.0, it fails on many platforms)
- # On ARM, we need at least 7.1 to run the 'next/step/...' tests.
+ check_version 7.1 gdbserver_tests/gdb.pic "pic executable tests"
+
+ # by default, we can run tests needed next/step/...
+ # But on ARM, we need at least 7.1 to run the 'next/step/...' tests.
# (gdb 7.0 has bugs in the 'guess next pc' heuristic in thumb mode).
- VERSIONOK=`echo $VERSION |
- awk '{ if ( ($1 >= 8) || (($1 == 7) && ($2 >= 1)) ) print "version ok"}'`
- # By default, consider step/next/... tests are ok. We will remove for ARM if needed.
- touch gdbserver_tests/gdb.step
- if [ "$VERSIONOK" = "" ]
+ if tests/arch_test arm
then
- echo "gdbserver 'pic' tests suppressed as $1 version is < 7.1: " $VERSIONLINE
- rm -f gdbserver_tests/gdb.pic
- if tests/arch_test arm
- then
- echo "gdbserver 'step/next' tests suppressed as arm $1 version is < 7.1: " $VERSIONLINE
- rm -f gdbserver_tests/gdb.step
- fi
+ check_version 7.1 gdbserver_tests/gdb.step "gdbserver next/step/... tests ARM"
else
- touch gdbserver_tests/gdb.pic
+ check_version 7.0 gdbserver_tests/gdb.step "gdbserver next/step/... tests"
fi
# We need at least a 7.2 version for gdb tests using eval command
- VERSIONOK=`echo $VERSION |
- awk '{ if ( ($1 >= 8) || (($1 == 7) && ($2 >= 2)) ) print "version ok"}'`
- if [ "$VERSIONOK" = "" ]
- then
- echo "gdbserver eval tests suppressed as $1 version is < 7.2: " $VERSIONLINE
- rm -f gdbserver_tests/gdb.eval
- else
- touch gdbserver_tests/gdb.eval
- fi
+ check_version 7.2 gdbserver_tests/gdb.eval "gdbserver eval tests"
+
else
echo "gdbserver gdb tests suppressed as $1 is not executable"
fi