OLD | NEW |
(Empty) | |
| 1 # Copyright 2012 Free Software Foundation, Inc. |
| 2 |
| 3 # This program is free software; you can redistribute it and/or modify |
| 4 # it under the terms of the GNU General Public License as published by |
| 5 # the Free Software Foundation; either version 3 of the License, or |
| 6 # (at your option) any later version. |
| 7 # |
| 8 # This program is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 # GNU General Public License for more details. |
| 12 # |
| 13 # You should have received a copy of the GNU General Public License |
| 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
| 16 if [is_remote target] { |
| 17 # The test always runs locally. |
| 18 return 0 |
| 19 } |
| 20 |
| 21 set test valgrind-infcall |
| 22 set srcfile $test.c |
| 23 set executable $test |
| 24 set binfile ${objdir}/${subdir}/${executable} |
| 25 if {[build_executable $test.exp $executable $srcfile {debug}] == -1} { |
| 26 return -1 |
| 27 } |
| 28 |
| 29 set test "spawn valgrind" |
| 30 set cmd "valgrind --vgdb-error=0 $binfile" |
| 31 set res [remote_spawn host $cmd]; |
| 32 if { $res < 0 || $res == "" } { |
| 33 verbose -log "Spawning $cmd failed." |
| 34 unsupported $test |
| 35 return -1 |
| 36 } |
| 37 pass $test |
| 38 # Declare GDB now as running. |
| 39 set gdb_spawn_id -1 |
| 40 |
| 41 # GDB started by vgdb stops already after the startup is executed, like with |
| 42 # non-extended gdbserver. It is also not correct to run/attach the inferior. |
| 43 set use_gdb_stub 1 |
| 44 |
| 45 set test "valgrind started" |
| 46 # The trailing '.' differs for different memcheck versions. |
| 47 gdb_test_multiple "" $test { |
| 48 -re "Memcheck, a memory error detector\\.?\r\n" { |
| 49 pass $test |
| 50 } |
| 51 -re "valgrind: failed to start tool 'memcheck' for platform '.*': No such fi
le or directory" { |
| 52 unsupported $test |
| 53 return -1 |
| 54 } |
| 55 -re "valgrind: wrong ELF executable class" { |
| 56 unsupported $test |
| 57 return -1 |
| 58 } |
| 59 -re "command not found" { |
| 60 # The spawn succeeded, but then valgrind was not found - e.g. if |
| 61 # we spawned SSH to a remote system. |
| 62 unsupported $test |
| 63 return -1 |
| 64 } |
| 65 -re "valgrind: Bad option.*--vgdb-error=0" { |
| 66 # valgrind is not >= 3.7.0. |
| 67 unsupported $test |
| 68 return -1 |
| 69 } |
| 70 } |
| 71 |
| 72 set test "vgdb prompt" |
| 73 # The trailing '.' differs for different memcheck versions. |
| 74 gdb_test_multiple "" $test { |
| 75 -re " (target remote | \[^\r\n\]*/vgdb \[^\r\n\]*)\r\n" { |
| 76 set vgdbcmd $expect_out(1,string) |
| 77 pass $test |
| 78 } |
| 79 } |
| 80 |
| 81 # Do not kill valgrind. |
| 82 unset gdb_spawn_id |
| 83 set board [host_info name] |
| 84 unset_board_info fileid |
| 85 |
| 86 clean_restart $executable |
| 87 |
| 88 gdb_test "$vgdbcmd" " in \\.?_start .*" "target remote for vgdb" |
| 89 |
| 90 gdb_test "monitor v.set gdb_output" "valgrind output will go to gdb.*" |
| 91 |
| 92 set continue_count 1 |
| 93 set loop 1 |
| 94 while {$loop && $continue_count < 100} { |
| 95 set test "continue #$continue_count" |
| 96 gdb_test_multiple "continue" "" { |
| 97 -re "Invalid free\\(\\).*: main .*\r\n$gdb_prompt $" { |
| 98 pass $test |
| 99 set loop 0 |
| 100 } |
| 101 -re "Remote connection closed.*\r\n$gdb_prompt $" { |
| 102 fail "$test (remote connection closed)" |
| 103 return -1 |
| 104 } |
| 105 -re "The program is not being run\\.\r\n$gdb_prompt $" { |
| 106 fail "$test (valgrind vgdb has terminated)" |
| 107 return -1 |
| 108 } |
| 109 -re "\r\n$gdb_prompt $" { |
| 110 pass "$test (false warning)" |
| 111 } |
| 112 } |
| 113 set continue_count [expr $continue_count + 1] |
| 114 } |
| 115 |
| 116 set test "p gdb_test_infcall ()" |
| 117 gdb_test_multiple $test $test { |
| 118 -re "unhandled instruction bytes.*\r\n$gdb_prompt $" { |
| 119 fail $test |
| 120 } |
| 121 -re "Continuing \\.\\.\\..*\r\n\\\$1 = 2\r\n$gdb_prompt $" { |
| 122 pass $test |
| 123 } |
| 124 } |
OLD | NEW |