GDB server: fix tests following recent commits.
Fixes #276987.  (Philippe Waroquiers, philippe.waroquiers@skynet.be)

* make_local_links
  - disable gdb tests if gdb version < 7
  - disable pic tests if gdb version < 7.1
* nlfork_chain test
  - reduce chain from 20 to 15 to avoid ENOMEM
    on small ARM systems
* main_pic.c
  - put break at line 11 rather than main entry, as ARM gdb
     does not properly show main args till it has started executing.
* passsigalrm.c
  - do not setsa.sa_restorer (obsolete on linux, unknown on darwin)
* mcvabits.vgtest
  - make prereq consistent with other tests
* filter_gdb
  - upgraded filter to new linenr in clean_after_fork.c



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11853 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/gdbserver_tests/filter_gdb b/gdbserver_tests/filter_gdb
index 3828ebb..0078ac5 100755
--- a/gdbserver_tests/filter_gdb
+++ b/gdbserver_tests/filter_gdb
@@ -88,7 +88,7 @@
     -e 's/\(Could not write register \)".*"/\1 "xxx"/'                                                \
     -e 's/\(ERROR changing register \).*$/\1 xxx regno y/'                                            \
     -e 's/0x........ in \(main (argc=1, argv=0x........) at watchpoints.c:[24][3689]\)/\1/'           \
-    -e 's/0x........ in \(main () at clean_after_fork.c:32\)/\1/'                                     \
+    -e 's/0x........ in \(main () at clean_after_fork.c:34\)/\1/'                                     \
     -e 's/\(^.*signal SIGFPE.*$\)/\1\nafter trap SIGFPE/'                                             \
     -e '/Id   Target Id         Frame/d'                                                              \
     -e 's/^\([ \*] [1234] \) *Thread /\1Thread /'                                                     \
diff --git a/gdbserver_tests/fork_chain.c b/gdbserver_tests/fork_chain.c
index ae40f6e..b5d60f0 100644
--- a/gdbserver_tests/fork_chain.c
+++ b/gdbserver_tests/fork_chain.c
@@ -32,6 +32,6 @@
 }
 int main()
 {
-   fork_chain (20);
+   fork_chain (15);
    return 0;
 }
diff --git a/gdbserver_tests/make_local_links b/gdbserver_tests/make_local_links
index 7fbdd33..30d7231 100755
--- a/gdbserver_tests/make_local_links
+++ b/gdbserver_tests/make_local_links
@@ -18,30 +18,35 @@
    VERSION=`echo $VERSIONLINE                         |
             sed -e 's/[^0-9\.]//g' -e 's/\./ /g'`
    
-   # We need at least a 6.5 version to run any gdb test
+   # 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) || (($1 == 6) && ($2 >= 5)) ) print "version ok"}'`
+              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 on ARM to run tests doing step/next/...
+   # 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).
-   if tests/arch_test arm
+   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
-      VERSIONOK=`echo $VERSION |
-                 awk '{ if ( ($1 >= 8) || (($1 == 7) && ($2 >= 1)) ) print "version ok"}'`
-      if [ "$VERSIONOK" = "" ]
+      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
+         echo "gdbserver 'step/next' tests suppressed as arm $1 version is < 7.1: " $VERSIONLINE
          rm -f gdbserver_tests/gdb.step
-      else
-         touch gdbserver_tests/gdb.step
       fi
    else
-      touch gdbserver_tests/gdb.step
+      touch gdbserver_tests/gdb.pic
    fi
 
    # We need at least a 7.2 version for gdb tests using eval command
diff --git a/gdbserver_tests/mcmain_pic.stdinB.gdb b/gdbserver_tests/mcmain_pic.stdinB.gdb
index baa64fc..46e19f9 100644
--- a/gdbserver_tests/mcmain_pic.stdinB.gdb
+++ b/gdbserver_tests/mcmain_pic.stdinB.gdb
@@ -4,7 +4,7 @@
 monitor v.set vgdb-error 999999
 #
 # break
-break main
+break main_pic.c:11
 #
 continue
 # first break encountered.
diff --git a/gdbserver_tests/mcmain_pic.stdout.exp b/gdbserver_tests/mcmain_pic.stdout.exp
index b207484..591c805 100644
--- a/gdbserver_tests/mcmain_pic.stdout.exp
+++ b/gdbserver_tests/mcmain_pic.stdout.exp
@@ -1,4 +1,4 @@
-another func called msg called from gdb
 address of main 0x........
+another func called msg called from gdb
 address of another_func 0x........
 another func called msg called from main
diff --git a/gdbserver_tests/mcmain_pic.stdoutB.exp b/gdbserver_tests/mcmain_pic.stdoutB.exp
index 4bb0a69..a548a66 100644
--- a/gdbserver_tests/mcmain_pic.stdoutB.exp
+++ b/gdbserver_tests/mcmain_pic.stdoutB.exp
@@ -1,7 +1,7 @@
-Breakpoint 1 at 0x........: file main_pic.c, line 10.
+Breakpoint 1 at 0x........: file main_pic.c, line 11.
 Continuing.
-Breakpoint 1, main (argc=1, argv=0x........) at main_pic.c:10
-10	   printf("address of main %p\n", &main);
+Breakpoint 1, main (argc=1, argv=0x........) at main_pic.c:11
+11	   printf("address of another_func %p\n", &another_func);
 $1 = void
 $2 = (int (*)(int, char **)) 0x........ <main>
 $3 = (void (*)(char *)) 0x........ <another_func>
diff --git a/gdbserver_tests/mcmain_pic.vgtest b/gdbserver_tests/mcmain_pic.vgtest
index 80ea610..1fab67f 100644
--- a/gdbserver_tests/mcmain_pic.vgtest
+++ b/gdbserver_tests/mcmain_pic.vgtest
@@ -3,7 +3,7 @@
 # information via the gdbserver protocol packet qXfer:auxv:read:
 # The content of the auxv data can be shown by gdb using
 # gdb command 'info auxv'
-prereq: test -e gdb
+prereq: test -e gdb.pic
 prog: main_pic
 vgopts: --tool=memcheck --vgdb=yes --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-mcmain_pic
 stdout_filter: filter_gdb
diff --git a/gdbserver_tests/mcvabits.vgtest b/gdbserver_tests/mcvabits.vgtest
index 48b35e8..9ef834f 100644
--- a/gdbserver_tests/mcvabits.vgtest
+++ b/gdbserver_tests/mcvabits.vgtest
@@ -4,7 +4,7 @@
 vgopts: --tool=memcheck --vgdb=yes --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-mcvabits
 stdout_filter: filter_make_empty
 stderr_filter: filter_make_empty
-prereq: test -e ./gdb.eval
+prereq: test -e gdb.eval
 progB: gdb
 argsB: --quiet -l 60 --nx ./t
 stdinB: mcvabits.stdinB.gdb
diff --git a/gdbserver_tests/nlfork_chain.stderr.exp b/gdbserver_tests/nlfork_chain.stderr.exp
index a0eeaba..8480949 100644
--- a/gdbserver_tests/nlfork_chain.stderr.exp
+++ b/gdbserver_tests/nlfork_chain.stderr.exp
@@ -17,8 +17,3 @@
 
 
 
-
-
-
-
-
diff --git a/gdbserver_tests/nlfork_chain.stdout.exp b/gdbserver_tests/nlfork_chain.stdout.exp
index a263b7e..1a425f3 100644
--- a/gdbserver_tests/nlfork_chain.stdout.exp
+++ b/gdbserver_tests/nlfork_chain.stdout.exp
@@ -1,8 +1,3 @@
-forking level 20
-forking level 19
-forking level 18
-forking level 17
-forking level 16
 forking level 15
 forking level 14
 forking level 13
diff --git a/gdbserver_tests/passsigalrm.c b/gdbserver_tests/passsigalrm.c
index c6f1fb5..a625eb6 100644
--- a/gdbserver_tests/passsigalrm.c
+++ b/gdbserver_tests/passsigalrm.c
@@ -15,7 +15,7 @@
    sa.sa_handler = sigalrm_handler;
    sigemptyset(&sa.sa_mask);
    sa.sa_flags = 0;
-   sa.sa_restorer = NULL;
+
    if (sigaction (SIGALRM, &sa, NULL) != 0)
       perror("sigaction");
    if (kill(getpid(), SIGALRM) != 0)