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 7 # a too old version of gdb is provided or if no gdb is 8 # provided. 9 # 10 # The vgdb link is needed either for gdb tests 11 # or for standalone vgdb tests. 12 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 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 60 if [ -x "$1" ] 61 then 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}'` 71 72 # We need at least a 6.5 version to use the Valgrind gdbserver. 73 # However, the gdb tests are only supported/maintained for gdb >= 7 74 check_version 7.0 gdbserver_tests/gdb "gdbserver gdb tests" 75 76 # We need at least a 7.1 version to run the 'pic' executable tests 77 # (with 7.0, it fails on many platforms) 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. 82 # (gdb 7.0 has bugs in the 'guess next pc' heuristic in thumb mode). 83 if tests/arch_test arm 84 then 85 check_version 7.1 gdbserver_tests/gdb.step "gdbserver next/step/... tests ARM" 86 else 87 check_version 7.0 gdbserver_tests/gdb.step "gdbserver next/step/... tests" 88 fi 89 90 # We need at least a 7.2 version for gdb tests using eval command 91 check_version 7.2 gdbserver_tests/gdb.eval "gdbserver eval tests" 92 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 112