gdb/
[binutils-gdb.git] / gdb / testsuite / gdb.cp / expand-sals.exp
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
16 if { [skip_cplus_tests] } { continue }
17
18 set srcfile expand-sals.cc
19 if { [prepare_for_testing expand-sals.exp expand-sals $srcfile {debug c++}] } {
20 return -1
21 }
22 if ![runto_main] {
23 return -1
24 }
25
26 gdb_breakpoint [gdb_get_line_number "exit-line"]
27
28 gdb_breakpoint [gdb_get_line_number "func-line"]
29 gdb_continue_to_breakpoint "func" ".*func-line.*"
30
31 gdb_test "up" "caller-line.*"
32
33 # PC should not be now at the boundary of source lines to make the original bug
34 # exploitable. The GLOBAL_X variable exists in the source for this purpose.
35
36 # Original problem was an internal error here.
37 set test "break"
38 gdb_test_multiple $test $test {
39 -re "Breakpoint \[0-9\]+ at .*, line \[0-9\]+\\. \\(\[2-9\] locations\\)\r\n$gdb_prompt $" {
40 fail $test
41 }
42 -re "Breakpoint \[0-9\]+ at .*, line \[0-9\]+\\.\r\n$gdb_prompt $" {
43 pass $test
44 }
45 }
46
47 gdb_continue_to_breakpoint "caller" ".*caller-line.*"
48
49 # Test GDB caught this return call and not the next one through B::B()
50 gdb_test "bt" \
51 "#0 \[^\r\n\]* A \[^\r\n\]*\r\n#1 \[^\r\n\]* main \[^\r\n\]*" \
52 "bt from A"
53
54 gdb_continue_to_breakpoint "next caller func" ".*func-line.*"
55
56 # Verify GDB really could not catch any other breakpoint location.
57
58 gdb_continue_to_breakpoint "uncaught return" ".*exit-line.*"