xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.base/valgrind-bt.exp (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1# Copyright 2009-2020 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
16load_lib valgrind.exp
17
18if [is_remote target] {
19    # The test always runs locally.
20    return 0
21}
22
23standard_testfile .c
24if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
25    return -1
26}
27
28if { [vgdb_start] == -1 } {
29    return -1
30}
31
32set double_free [gdb_get_line_number "double-free"]
33
34set test "continue"
35gdb_test_multiple "continue" $test {
36    -re "Invalid free\\(\\).*: main \\(${srcfile}:$double_free\\)\r\n.*$gdb_prompt $" {
37	pass $test
38    }
39    -re "Remote connection closed.*\r\n$gdb_prompt $" {
40	fail "$test (remote connection closed)"
41	# Only if valgrind got stuck.
42	kill_wait_spawned_process $valgrind_spawn_id
43	return -1
44    }
45    -re "The program is not being run\\.\r\n$gdb_prompt $" {
46	fail "$test (valgrind vgdb has terminated)"
47	# Only if valgrind got stuck.
48	kill_wait_spawned_process $valgrind_spawn_id
49	return -1
50    }
51    -re "\r\n$gdb_prompt $" {
52	pass "$test (false warning)"
53    }
54}
55
56# Initialization from default_gdb_start.
57gdb_test_no_output "set height 0"
58gdb_test_no_output "set width 0"
59
60gdb_test "bt" "in main \\(.*\\) at .*${srcfile}:$double_free"
61
62# Explicitly kill the program so it doesn't dump core when we quit->detach.
63gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
64
65vgdb_stop
66