mb-inline.exp revision 1.1
1# Copyright 2008-2014 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# This file is part of the gdb testsuite.
17
18# This test verifies that setting breakpoint on line in inline
19# function will fire in all instantiations of that function.
20
21if { [skip_cplus_tests] } { continue }
22
23standard_testfile mb-inline1.cc mb-inline2.cc
24set hdrfile "${testfile}.h"
25
26if [get_compiler_info "c++"] {
27    return -1
28}
29
30if {[prepare_for_testing $testfile.exp $testfile \
31	 [list $srcfile $srcfile2] {debug c++}]} {
32    return -1
33}
34
35set bp_location [gdb_get_line_number "set breakpoint here" $hdrfile]
36
37# Set a breakpoint with multiple locations.
38
39gdb_test "break $hdrfile:$bp_location" \
40    "Breakpoint.*at.*: $hdrfile:$bp_location. \\(2 locations\\).*" \
41    "set breakpoint"
42
43# Do "info break" now so we can easily compare it with the later "info break"
44# if problems arise.
45gdb_test "info break" \
46    "\[\r\n\]1\.1.* y .* at .*$hdrfile:$bp_location.*\[\r\n\]1\.2.* y .* at .*$hdrfile:$bp_location.*"
47
48gdb_run_cmd
49gdb_expect {
50    -re "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*$gdb_prompt $" {
51	pass "run to breakpoint"
52    }
53    -re "$gdb_prompt $" {
54	fail "run to breakpoint"
55    }
56    timeout {
57	fail "run to breakpoint (timeout)"
58    }
59}
60
61gdb_test "continue" \
62    ".*Breakpoint.*foo \\(i=1\\).*" \
63    "run to breakpoint 2"
64
65# Try disabling a single location. We also test
66# that at least in simple cases, the enable/disable
67# state of locations survive "run".
68# Early bug would disable 1.1 and enable 1.2 when program is run.
69gdb_test_no_output "disable 1.2" "disabling location: disable"
70
71gdb_run_cmd
72gdb_expect {
73    -re "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*$gdb_prompt $" {
74	pass "disabling location: run to breakpoint"
75    }
76    -re "$gdb_prompt $" {
77	fail "disabling location: run to breakpoint"
78    }
79    timeout {
80	fail "disabling location: run to breakpoint (timeout)"
81    }
82}
83
84gdb_test_multiple "info break" "disabled breakpoint 1.2" {
85    -re "1\.2.* n .* at .*$hdrfile:$bp_location.*$gdb_prompt $" {
86	pass "disabled breakpoint 1.2"
87    }
88    -re "1\.2.* y .* at .*$hdrfile:$bp_location.*$gdb_prompt $" {
89	# When inferior is restarted, breakpoint locations will be updated.
90	# On uclinux, it is not guaranteed that new inferior is located the
91	# same address as previous one, so status/state of breakpoint location
92	# will loose.  The heuristic of GDB should be improved.
93	setup_kfail gdb/12924 "*-*-uclinux*"
94	fail "disabled breakpoint 1.2"
95    }
96}
97
98# Make sure we can set a breakpoint on a source statement that spans
99# multiple lines.
100
101delete_breakpoints
102
103set bp_location [gdb_get_line_number "set multi-line breakpoint here" $hdrfile]
104
105if { ![runto_main] } {
106    fail "Can't run to main for multi_line_foo tests."
107    return 0
108}
109
110gdb_test "break $hdrfile:$bp_location" \
111    "Breakpoint.*at.*: $hdrfile:$bp_location. \\(2 locations\\).*" \
112    "set multi_line_foo breakpoint"
113gdb_test "continue" \
114    ".*Breakpoint.*multi_line_foo \\(i=0\\).*" \
115    "run to multi_line_foo breakpoint 4 afn"
116gdb_test "continue" \
117    ".*Breakpoint.*multi_line_foo \\(i=1\\).*" \
118    "run to multi_line_foo breakpoint 4 bfn"
119