From: Julian Seward Date: Mon, 24 Oct 2011 07:36:57 +0000 (+0000) Subject: gdbsrv: factorize gdb version handling, fix doc and typos X-Git-Tag: svn/VALGRIND_3_7_0~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8a36cfde4236930d2b8aa2804bbff3d17692d50;p=thirdparty%2Fvalgrind.git gdbsrv: factorize gdb version handling, fix doc and typos * fix various typos in doc * following commit in gdb http://sourceware.org/ml/gdb-patches/2011-07/msg00742.html means unlimited length for valgrind watchpoints is understood by the (future) gdb 7.4 => doc updated * factorize gdb version detection and reporting in gdbserver_tests/make_local_links * replace zignal by signal in a string used in umsg. * updated gdbserver_tests/README_DEVELOPPERS (ref to --port vgdb option) No functional change, tested on f12/x86, debian5/amd64, s390/RHEL4 Fixes #278892. (Philippe Waroquiers, philippe.waroquiers@skynet.be) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12223 --- diff --git a/coregrind/m_gdbserver/server.c b/coregrind/m_gdbserver/server.c index 6dc5e1ad14..a1a26087f5 100644 --- a/coregrind/m_gdbserver/server.c +++ b/coregrind/m_gdbserver/server.c @@ -1016,7 +1016,7 @@ void server_main (void) if (status == 'W') VG_(umsg) ("\nChild exited with status %d\n", zignal); if (status == 'X') - VG_(umsg) ("\nChild terminated with zignal = 0x%x (%s)\n", + VG_(umsg) ("\nChild terminated with signal = 0x%x (%s)\n", target_signal_to_host (zignal), target_signal_to_name (zignal)); if (status == 'W' || status == 'X') { diff --git a/docs/xml/manual-core-adv.xml b/docs/xml/manual-core-adv.xml index 0ef20d2e9f..2039f6f10c 100644 --- a/docs/xml/manual-core-adv.xml +++ b/docs/xml/manual-core-adv.xml @@ -14,6 +14,8 @@ ways. The subjects covered are: The "Client Request" mechanism + Debugging your program using Valgrind's gdbserver + and GDB Function Wrapping @@ -376,7 +378,7 @@ command line. To debug a program "prog" running under Valgrind, you must ensure that the Valgrind gdbserver is activated by specifying either -or ). A secondary command line option, +or . A secondary command line 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 @@ -595,7 +597,7 @@ these from a shell command line. For example, the following command lines, when given in a shell, will cause the same leak search to be executed by the process 3145: @@ -728,12 +730,10 @@ are however some limitations and peculiarities: 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. Memcheck implements hardware watchpoint simulation by marking the watched address ranges as being unaddressable. When @@ -1223,7 +1223,7 @@ problems or bugs. v.info gdbserver_status 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 diff --git a/gdbserver_tests/README_DEVELOPERS b/gdbserver_tests/README_DEVELOPERS index 1509a83711..e33eb03387 100644 --- a/gdbserver_tests/README_DEVELOPERS +++ b/gdbserver_tests/README_DEVELOPERS @@ -17,14 +17,13 @@ or (to just run the gdbserver tests with another gdb): 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). diff --git a/gdbserver_tests/make_local_links b/gdbserver_tests/make_local_links index 44f36c5041..8e50093b2e 100755 --- a/gdbserver_tests/make_local_links +++ b/gdbserver_tests/make_local_links @@ -4,7 +4,7 @@ # # 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 @@ -24,55 +24,72 @@ if [ "x$1" = "x" ]; then 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