gdb/testsuite/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / valgrind-db-attach.exp
CommitLineData
9f2982ff
JK
1# Copyright 2009 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
16set test valgrind-db-attach
17set srcfile $test.c
18set executable $test
19set binfile ${objdir}/${subdir}/${executable}
20if {[build_executable $test.exp $executable $srcfile {debug}] == -1} {
21 return -1
22}
23
24gdb_exit
25
26# remote_spawn breaks the command on each whitespace despite possible quoting.
27# Use backslash-escaped whitespace there instead:
28
29set db_command "--db-command=$GDB $INTERNAL_GDBFLAGS $GDBFLAGS [host_info gdb_opts] %f %p"
30regsub -all " " $db_command "\\ " db_command
31
32set test "spawn valgrind"
33set cmd "valgrind --db-attach=yes $db_command $binfile"
34set res [remote_spawn host $cmd];
35if { $res < 0 || $res == "" } {
36 verbose -log "Spawning $cmd failed."
37 setup_xfail *-*-*
38 fail $test
39 return -1
40}
41pass $test
42# Declare GDB now as running.
43set gdb_spawn_id -1
44
45set test "valgrind started"
46# The trailing '.' differs for different memcheck versions.
47gdb_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 file or directory" {
52 setup_xfail *-*-*
53 fail $test
54 return -1
55 }
56}
57
58set double_free [gdb_get_line_number "double-free"]
59
60gdb_test_multiple "" $test {
61 -re "Invalid free\\(\\) / delete / delete\\\[\\\]\r\n.*: main \\(${srcfile}:$double_free\\)\r\n.*---- Attach to debugger \\? --- \[^\r\n\]* ---- " {
62 send_gdb "y\r"
63 }
64 -re "---- Attach to debugger \\? --- \[^\r\n\]* ---- " {
65 send_gdb "n\r"
66 exp_continue
67 }
68}
69
70gdb_test "" "" "eat first prompt"
71
72# Initialization from default_gdb_start.
73gdb_test "set height 0"
74gdb_test "set width 0"
75
76gdb_test "bt" "in main \\(.*\\) at .*${srcfile}:$double_free"
This page took 0.097815 seconds and 4 git commands to generate.