sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 1 | #! /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 |
sewardj | 47ffedb | 2011-10-24 07:36:57 +0000 | [diff] [blame^] | 7 | # a too old version of gdb is provided or if no gdb is |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 8 | # provided. |
| 9 | # |
| 10 | # The vgdb link is needed either for gdb tests |
| 11 | # or for standalone vgdb tests. |
| 12 | |
florian | 3c83687 | 2011-08-13 15:35:21 +0000 | [diff] [blame] | 13 | # 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. |
| 16 | if [ ! -d "coregrind" ]; then |
| 17 | echo "make_local_links is not invoked from the top-of-tree directory" 1>&2 |
| 18 | exit 1 |
| 19 | fi |
| 20 | |
| 21 | # Make sure there is an argument |
| 22 | if [ "x$1" = "x" ]; then |
| 23 | echo "usage: make_local_links /path/to/gdb" 1>&2 |
| 24 | exit 1 |
| 25 | fi |
| 26 | |
sewardj | 47ffedb | 2011-10-24 07:36:57 +0000 | [diff] [blame^] | 27 | |
| 28 | export GDB="" |
| 29 | export GDBVERSIONLINE="" |
| 30 | export GDBMAJ="" |
| 31 | export 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 |
| 36 | check_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 | |
bart | 09e22c6 | 2011-05-15 06:18:24 +0000 | [diff] [blame] | 60 | if [ -x "$1" ] |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 61 | then |
sewardj | 47ffedb | 2011-10-24 07:36:57 +0000 | [diff] [blame^] | 62 | 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}'` |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 71 | |
sewardj | f5194b3 | 2011-07-04 22:00:41 +0000 | [diff] [blame] | 72 | # We need at least a 6.5 version to use the Valgrind gdbserver. |
sewardj | 47ffedb | 2011-10-24 07:36:57 +0000 | [diff] [blame^] | 73 | # However, the gdb tests are only supported/maintained for gdb >= 7 |
| 74 | check_version 7.0 gdbserver_tests/gdb "gdbserver gdb tests" |
sewardj | 6b7357b | 2011-05-27 13:23:44 +0000 | [diff] [blame] | 75 | |
sewardj | 47ffedb | 2011-10-24 07:36:57 +0000 | [diff] [blame^] | 76 | # We need at least a 7.1 version to run the 'pic' executable tests |
sewardj | f5194b3 | 2011-07-04 22:00:41 +0000 | [diff] [blame] | 77 | # (with 7.0, it fails on many platforms) |
sewardj | 47ffedb | 2011-10-24 07:36:57 +0000 | [diff] [blame^] | 78 | 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. |
sewardj | 6b7357b | 2011-05-27 13:23:44 +0000 | [diff] [blame] | 82 | # (gdb 7.0 has bugs in the 'guess next pc' heuristic in thumb mode). |
sewardj | 47ffedb | 2011-10-24 07:36:57 +0000 | [diff] [blame^] | 83 | if tests/arch_test arm |
sewardj | 6b7357b | 2011-05-27 13:23:44 +0000 | [diff] [blame] | 84 | then |
sewardj | 47ffedb | 2011-10-24 07:36:57 +0000 | [diff] [blame^] | 85 | check_version 7.1 gdbserver_tests/gdb.step "gdbserver next/step/... tests ARM" |
sewardj | 6b7357b | 2011-05-27 13:23:44 +0000 | [diff] [blame] | 86 | else |
sewardj | 47ffedb | 2011-10-24 07:36:57 +0000 | [diff] [blame^] | 87 | check_version 7.0 gdbserver_tests/gdb.step "gdbserver next/step/... tests" |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 88 | fi |
| 89 | |
| 90 | # We need at least a 7.2 version for gdb tests using eval command |
sewardj | 47ffedb | 2011-10-24 07:36:57 +0000 | [diff] [blame^] | 91 | check_version 7.2 gdbserver_tests/gdb.eval "gdbserver eval tests" |
| 92 | |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 93 | else |
| 94 | echo "gdbserver gdb tests suppressed as $1 is not executable" |
| 95 | fi |
| 96 | |
| 97 | ln -f -s ../coregrind/vgdb gdbserver_tests/vgdb |
| 98 | |
| 99 | # if ptrace not implemented in vgdb or OS restricts the initial attach, |
| 100 | # some tests would block for a loooonnnng time. |
| 101 | if gdbserver_tests/vgdb --help 2>&1 | |
| 102 | grep -e 'ptrace invoker not implemented' \ |
| 103 | -e 'kernel restricts ptrace invoker' > /dev/null |
| 104 | then |
| 105 | rm -f gdbserver_tests/vgdb.ptraceinvoker |
| 106 | else |
| 107 | touch gdbserver_tests/vgdb.ptraceinvoker |
| 108 | fi |
| 109 | |
| 110 | # cleanup the possibly big garbage previously collected output |
| 111 | rm -f gdbserver_tests/garbage.filtered.out |