Commit | Line | Data |
---|---|---|
61baf725 | 1 | # Copyright 2009-2017 Free Software Foundation, Inc. |
00903456 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 | ||
16 | if { [skip_cplus_tests] } { continue } | |
17 | ||
18 | set srcfile expand-sals.cc | |
5b362f04 | 19 | if { [prepare_for_testing "failed to prepare" expand-sals $srcfile {debug c++}] } { |
00903456 JK |
20 | return -1 |
21 | } | |
22 | if ![runto_main] { | |
23 | return -1 | |
24 | } | |
25 | ||
00903456 JK |
26 | gdb_breakpoint [gdb_get_line_number "func-line"] |
27 | gdb_continue_to_breakpoint "func" ".*func-line.*" | |
28 | ||
29 | gdb_test "up" "caller-line.*" | |
30 | ||
31 | # PC should not be now at the boundary of source lines to make the original bug | |
32 | # exploitable. The GLOBAL_X variable exists in the source for this purpose. | |
33 | ||
34 | # Original problem was an internal error here. | |
35 | set test "break" | |
36 | gdb_test_multiple $test $test { | |
37 | -re "Breakpoint \[0-9\]+ at .*, line \[0-9\]+\\. \\(\[2-9\] locations\\)\r\n$gdb_prompt $" { | |
38 | fail $test | |
39 | } | |
40 | -re "Breakpoint \[0-9\]+ at .*, line \[0-9\]+\\.\r\n$gdb_prompt $" { | |
41 | pass $test | |
42 | } | |
43 | } | |
44 | ||
45 | gdb_continue_to_breakpoint "caller" ".*caller-line.*" | |
46 | ||
47 | # Test GDB caught this return call and not the next one through B::B() | |
48 | gdb_test "bt" \ | |
cec808ec | 49 | "#0 \[^\r\n\]* (A::)?A \[^\r\n\]*\r\n#1 \[^\r\n\]* main \[^\r\n\]*" \ |
00903456 JK |
50 | "bt from A" |
51 | ||
52 | gdb_continue_to_breakpoint "next caller func" ".*func-line.*" |