Philippe Waroquiers b8ed3a5b65 Fix 326462 Refactor vgdb to isolate invoker stuff into separate module
vgdb.c contained (conditionally compiled) "invoker" code to have ptrace syscalls
used to allow gdb/vgdb to connect to a valgrind process blocked in a syscall.
This "invoker" code is ptrace based.
Not all platforms are using ptrace.
=> refactor vgdb so as allow invoker code to be added more cleanly
for non ptrace based platforms (e.g. Darwin, Solaris).

* add file vgdb.h for:
   - definition of the vgdb-invoker interface
   - common declarations between vgdb.c and vgdb-invoker implementations
* move ptrace related code from vgdb.c to new file vgdb-invoker-ptrace.c
* new file vgdb-invoker-none.c containing an empty invoker implementation
  used on platforms that do not (yet) have a invoker implementation
  (e.g. android and darwin).
* modified Makefile.am to use one of the vgdb-invoker-*.c file depending
  on the platform.
* small changes related to changing ptraceinvoker to invoker in various files:
  gdbserver_tests/make_local_links, gdbserver_tests/nlcontrolc.vgtest,
  gdbserver_tests/mcinvokeRU.vgtest, gdbserver_tests/nlsigvgdb.vgtest  
  gdbserver_tests/mcinvokeWS.vgtest, coregrind/m_gdbserver/README_DEVELOPERS

Patch from Ivo Raisr, slightly modified



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13743
2013-12-01 14:56:28 +00:00

111 lines
3.3 KiB
Bash
Executable File

#! /bin/sh
# (must be called from the valgrind top source dir).
#
# Make local links in the gdbserver_tests directory
# so that tests needing gdb can be disabled if
# a too old version of gdb is provided or if no gdb is
# provided.
#
# The vgdb link is needed either for gdb tests
# or for standalone vgdb tests.
# Make sure we're in the correct directory, i.e. the root of the valgrind
# source tree. We use the existence of the coregrind directory as evidence
# that we're in the right place.
if [ ! -d "coregrind" ]; then
echo "make_local_links is not invoked from the top-of-tree directory" 1>&2
exit 1
fi
# Make sure there is an argument
if [ "x$1" = "x" ]; then
echo "usage: make_local_links /path/to/gdb" 1>&2
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
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 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 tests
# (with 7.0, it fails on many platforms)
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).
if tests/arch_test arm
then
check_version 7.1 gdbserver_tests/gdb.step "gdbserver next/step/... tests ARM"
else
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
check_version 7.2 gdbserver_tests/gdb.eval "gdbserver eval tests"
else
echo "gdbserver gdb tests suppressed as $1 is not executable"
fi
ln -f -s ../coregrind/vgdb gdbserver_tests/vgdb
# if ptrace not implemented in vgdb or OS restricts the initial attach,
# some tests would block for a loooonnnng time.
if gdbserver_tests/vgdb --help 2>&1 |
grep -e 'invoker not implemented' > /dev/null
then
rm -f gdbserver_tests/vgdb.invoker
else
touch gdbserver_tests/vgdb.invoker
fi
# cleanup the possibly big garbage previously collected output
rm -f gdbserver_tests/garbage.filtered.out