blob: 001609a99cd65235d5f346272cbd30e25ee6e3fb [file] [log] [blame]
sewardj3b290482011-05-06 21:02:55 +00001#! /bin/sh
2
3# (must be called from the valgrind top source dir).
4#
5# Make local links in the gdbserver_tests directory
6# so that tests needing gdb can be disabled if
sewardj47ffedb2011-10-24 07:36:57 +00007# a too old version of gdb is provided or if no gdb is
sewardj3b290482011-05-06 21:02:55 +00008# provided.
9#
10# The vgdb link is needed either for gdb tests
11# or for standalone vgdb tests.
12
florian3c836872011-08-13 15:35:21 +000013# Make sure we're in the correct directory, i.e. the root of the valgrind
14# source tree. We use the existence of the coregrind directory as evidence
15# that we're in the right place.
16if [ ! -d "coregrind" ]; then
17 echo "make_local_links is not invoked from the top-of-tree directory" 1>&2
18 exit 1
19fi
20
21# Make sure there is an argument
22if [ "x$1" = "x" ]; then
23 echo "usage: make_local_links /path/to/gdb" 1>&2
24 exit 1
25fi
26
sewardj47ffedb2011-10-24 07:36:57 +000027
28export GDB=""
29export GDBVERSIONLINE=""
30export GDBMAJ=""
31export GDBMIN=""
32
33# $1 = Major.Minor gdb version needed
34# $2 = marker file to touch (if version ok) or to remove (version not ok)
35# $3 and following: msg in output
36check_version()
37{
38 NEEDED=$1
39 shift
40 NEEDEDMAJ=$(echo $NEEDED | awk -F\. '{ print $1 }')
41 NEEDEDMIN=$(echo $NEEDED | awk -F\. '{ print $2 }')
42
43 MARKERFILE=$1
44 shift
45
46 if [ \( $GDBMAJ -gt $NEEDEDMAJ \) \
47 -o \( \( $GDBMAJ -eq $NEEDEDMAJ \) \
48 -a \( $GDBMIN -ge $NEEDEDMIN \) \) ]
49 then
50 if [ ! -f $MARKERFILE ]
51 then
52 touch $MARKERFILE
53 fi
54 else
55 echo "$@" "suppressed as $GDB version" $GDBVERSIONLINE "is <" $NEEDED
56 rm -f $MARKERFILE
57 fi
58}
59
bart09e22c62011-05-15 06:18:24 +000060if [ -x "$1" ]
sewardj3b290482011-05-06 21:02:55 +000061then
sewardj47ffedb2011-10-24 07:36:57 +000062 GDB=$1
63 ln -f -s "$GDB" gdbserver_tests/gdb
64 # Try to extract the gdb version major and minor numbers.
65 # We assume these are the first two integers separated by a .
66 GDBVERSIONLINE=`gdbserver_tests/gdb --version | head -n 1`
67 GDBMAJ=`echo $GDBVERSIONLINE | sed -e 's/[^0-9\.]//g' |
68 awk -F\. '{print $1}'`
69 GDBMIN=`echo $GDBVERSIONLINE | sed -e 's/[^0-9\.]//g' |
70 awk -F\. '{print $2}'`
sewardj3b290482011-05-06 21:02:55 +000071
sewardjf5194b32011-07-04 22:00:41 +000072 # We need at least a 6.5 version to use the Valgrind gdbserver.
sewardj47ffedb2011-10-24 07:36:57 +000073 # However, the gdb tests are only supported/maintained for gdb >= 7
74 check_version 7.0 gdbserver_tests/gdb "gdbserver gdb tests"
sewardj6b7357b2011-05-27 13:23:44 +000075
sewardj47ffedb2011-10-24 07:36:57 +000076 # We need at least a 7.1 version to run the 'pic' executable tests
sewardjf5194b32011-07-04 22:00:41 +000077 # (with 7.0, it fails on many platforms)
sewardj47ffedb2011-10-24 07:36:57 +000078 check_version 7.1 gdbserver_tests/gdb.pic "pic executable tests"
79
80 # by default, we can run tests needed next/step/...
81 # But on ARM, we need at least 7.1 to run the 'next/step/...' tests.
sewardj6b7357b2011-05-27 13:23:44 +000082 # (gdb 7.0 has bugs in the 'guess next pc' heuristic in thumb mode).
sewardj47ffedb2011-10-24 07:36:57 +000083 if tests/arch_test arm
sewardj6b7357b2011-05-27 13:23:44 +000084 then
sewardj47ffedb2011-10-24 07:36:57 +000085 check_version 7.1 gdbserver_tests/gdb.step "gdbserver next/step/... tests ARM"
sewardj6b7357b2011-05-27 13:23:44 +000086 else
sewardj47ffedb2011-10-24 07:36:57 +000087 check_version 7.0 gdbserver_tests/gdb.step "gdbserver next/step/... tests"
sewardj3b290482011-05-06 21:02:55 +000088 fi
89
90 # We need at least a 7.2 version for gdb tests using eval command
sewardj47ffedb2011-10-24 07:36:57 +000091 check_version 7.2 gdbserver_tests/gdb.eval "gdbserver eval tests"
92
sewardj3b290482011-05-06 21:02:55 +000093else
94 echo "gdbserver gdb tests suppressed as $1 is not executable"
95fi
96
97ln -f -s ../coregrind/vgdb gdbserver_tests/vgdb
sewardj8eb8bab2015-07-21 14:44:28 +000098ln -f -s ../../coregrind/vgdb gdbserver_tests/solaris/vgdb
sewardj3b290482011-05-06 21:02:55 +000099
100# if ptrace not implemented in vgdb or OS restricts the initial attach,
101# some tests would block for a loooonnnng time.
102if gdbserver_tests/vgdb --help 2>&1 |
philippe3c761f02013-12-01 14:56:28 +0000103 grep -e 'invoker not implemented' > /dev/null
sewardj3b290482011-05-06 21:02:55 +0000104then
philippe3c761f02013-12-01 14:56:28 +0000105 rm -f gdbserver_tests/vgdb.invoker
sewardj3b290482011-05-06 21:02:55 +0000106else
philippe3c761f02013-12-01 14:56:28 +0000107 touch gdbserver_tests/vgdb.invoker
sewardj3b290482011-05-06 21:02:55 +0000108fi
109
110# cleanup the possibly big garbage previously collected output
111rm -f gdbserver_tests/garbage.filtered.out
sewardj8eb8bab2015-07-21 14:44:28 +0000112rm -f gdbserver_tests/solaris/garbage.filtered.out