Test for PR gdb/17511, spurious SIGTRAP after stepping into+in signal handler
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / valgrind-infcall.exp
index ede26f4d0a9bf0c0abf204a775013af77244f2b6..86bbc92096fd60ebb9d65cc6bd3cc1897164f4aa 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2012 Free Software Foundation, Inc.
+# Copyright 2012-2014 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -18,17 +18,14 @@ if [is_remote target] {
     return 0
 }
 
-set test valgrind-infcall
-set srcfile $test.c
-set executable $test
-set binfile ${objdir}/${subdir}/${executable}
-if {[build_executable $test.exp $executable $srcfile {debug}] == -1} {
+standard_testfile .c
+if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
     return -1
 }
 
 set test "spawn valgrind"
 set cmd "valgrind --vgdb-error=0 $binfile"
-set res [remote_spawn host $cmd];
+set res [remote_spawn host $cmd]
 if { $res < 0 || $res == "" } {
     verbose -log "Spawning $cmd failed."
     unsupported $test
@@ -62,7 +59,7 @@ gdb_test_multiple "" $test {
        unsupported $test
        return -1
     }
-    -re "valgrind: Bad option '--vgdb-error=0'" {
+    -re "valgrind: Bad option.*--vgdb-error=0" {
        # valgrind is not >= 3.7.0.
        unsupported $test
        return -1
@@ -79,23 +76,37 @@ gdb_test_multiple "" $test {
 }
 
 # Do not kill valgrind.
+set valgrind_pid [exp_pid -i [board_info host fileid]]
 unset gdb_spawn_id
 set board [host_info name]
 unset_board_info fileid
 
-clean_restart $executable
+clean_restart $testfile
 
-gdb_test "$vgdbcmd" " in _start .*" "target remote for vgdb"
+gdb_test "$vgdbcmd" " in \\.?_start .*" "target remote for vgdb"
 
 gdb_test "monitor v.set gdb_output" "valgrind output will go to gdb.*"
 
 set continue_count 1
-while 1 {
+set loop 1
+while {$loop && $continue_count < 100} {
     set test "continue #$continue_count"
     gdb_test_multiple "continue" "" {
        -re "Invalid free\\(\\).*: main .*\r\n$gdb_prompt $" {
            pass $test
-           break
+           set loop 0
+       }
+       -re "Remote connection closed.*\r\n$gdb_prompt $" {
+           fail "$test (remote connection closed)"
+           # Only if valgrind got stuck.
+           remote_exec host "kill -9 ${valgrind_pid}"
+           return -1
+       }
+       -re "The program is not being run\\.\r\n$gdb_prompt $" {
+           fail "$test (valgrind vgdb has terminated)"
+           # Only if valgrind got stuck.
+           remote_exec host "kill -9 ${valgrind_pid}"
+           return -1
        }
        -re "\r\n$gdb_prompt $" {
            pass "$test (false warning)"
@@ -113,3 +124,6 @@ gdb_test_multiple $test $test {
        pass $test
     }
 }
+
+# Only if valgrind got stuck.
+remote_exec host "kill -9 ${valgrind_pid}"
This page took 0.026236 seconds and 4 git commands to generate.