]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/valgrind-db-attach.exp
GDB copyright headers update after running GDB's copyright.py script.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / valgrind-db-attach.exp
CommitLineData
618f726f 1# Copyright 2009-2016 Free Software Foundation, Inc.
9f2982ff
JK
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
75d9f9ff
JK
16if [is_remote target] {
17 # The test always runs locally.
18 return 0
19}
20
62cef515
TT
21standard_testfile .c
22if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
9f2982ff
JK
23 return -1
24}
25
26gdb_exit
27
28# remote_spawn breaks the command on each whitespace despite possible quoting.
29# Use backslash-escaped whitespace there instead:
30
31set db_command "--db-command=$GDB $INTERNAL_GDBFLAGS $GDBFLAGS [host_info gdb_opts] %f %p"
32regsub -all " " $db_command "\\ " db_command
33
34set test "spawn valgrind"
35set cmd "valgrind --db-attach=yes $db_command $binfile"
4ec70201 36set res [remote_spawn host $cmd]
9f2982ff
JK
37if { $res < 0 || $res == "" } {
38 verbose -log "Spawning $cmd failed."
67bdab6c 39 unsupported $test
9f2982ff
JK
40 return -1
41}
42pass $test
43# Declare GDB now as running.
717cf30c 44set gdb_spawn_id $res
9f2982ff 45
e11ac3a3
JK
46# GDB spawned by `valgrind --db-attach=yes' stops already after the startup is
47# executed, like with non-extended gdbserver. It is also not correct to
48# run/attach the inferior.
49set use_gdb_stub 1
50
9f2982ff
JK
51set test "valgrind started"
52# The trailing '.' differs for different memcheck versions.
53gdb_test_multiple "" $test {
54 -re "Memcheck, a memory error detector\\.?\r\n" {
55 pass $test
56 }
57 -re "valgrind: failed to start tool 'memcheck' for platform '.*': No such file or directory" {
67bdab6c
DJ
58 unsupported $test
59 return -1
60 }
5bbad94c
UW
61 -re "valgrind: wrong ELF executable class" {
62 unsupported $test
63 return -1
64 }
67bdab6c
DJ
65 -re "command not found" {
66 # The spawn succeeded, but then valgrind was not found - e.g. if
67 # we spawned SSH to a remote system.
68 unsupported $test
9f2982ff
JK
69 return -1
70 }
71}
72
73set double_free [gdb_get_line_number "double-free"]
74
d3765805 75set test "attach to debugger"
9f2982ff 76gdb_test_multiple "" $test {
f0d1a53e 77 -re "Invalid free\\(\\).*: main \\(${srcfile}:$double_free\\)\r\n.*---- Attach to debugger \\? --- \[^\r\n\]* ---- " {
9f2982ff
JK
78 send_gdb "y\r"
79 }
80 -re "---- Attach to debugger \\? --- \[^\r\n\]* ---- " {
81 send_gdb "n\r"
82 exp_continue
83 }
84}
85
de7ff789 86gdb_test "" ".*" "eat first prompt"
9f2982ff
JK
87
88# Initialization from default_gdb_start.
27d3a1a2
MS
89gdb_test_no_output "set height 0"
90gdb_test_no_output "set width 0"
9f2982ff
JK
91
92gdb_test "bt" "in main \\(.*\\) at .*${srcfile}:$double_free"
a391a2f6
PA
93
94# Explicitly kill the program so it doesn't dump core when we quit->detach.
95gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"