summaryrefslogtreecommitdiff
path: root/gdbserver_tests/make_local_links
blob: 44f36c5041495d12d2cee66266c62dff21a706f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#! /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 tool 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

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'`
   
   # 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

   # We need at least a 7.1 version to run the 'pic' executable test
   # (with 7.0, it fails on many platforms)
   # 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" = "" ]
   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
   else
      touch gdbserver_tests/gdb.pic
   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
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 'ptrace invoker not implemented' \
         -e 'kernel restricts ptrace invoker' > /dev/null
then
    rm -f gdbserver_tests/vgdb.ptraceinvoker
else
    touch gdbserver_tests/vgdb.ptraceinvoker
fi

# cleanup the possibly big garbage previously collected output
rm -f gdbserver_tests/garbage.filtered.out