1 # Copyright 2008-2012 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file is part of the gdb testsuite.
18 # This test verifies that setting breakpoint on line in inline
19 # function will fire in all instantiations of that function.
25 if { [skip_cplus_tests] } { continue }
28 set testfile "mb-inline"
29 set hdrfile "${testfile}.h"
30 set srcfile1 "${testfile}1.cc"
31 set objfile1 "${testfile}1.o"
32 set srcfile2 "${testfile}2.cc"
33 set objfile2 "${testfile}2.o"
34 set binfile "${objdir}/${subdir}/${testfile}"
36 if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } {
37 untested mb-inline.exp
41 if { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } {
42 untested mb-inline.exp
46 if { [gdb_compile "$objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2" "${binfile}" executable {debug c++}] != "" } {
47 untested mb-inline.exp
51 if [get_compiler_info ${binfile} "c++"] {
57 gdb_reinitialize_dir $srcdir/$subdir
60 set bp_location [gdb_get_line_number "set breakpoint here" $hdrfile]
62 # Set a breakpoint with multiple locations.
64 gdb_test "break $hdrfile:$bp_location" \
65 "Breakpoint.*at.*: $hdrfile:$bp_location. \\(2 locations\\).*" \
70 -re "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*$gdb_prompt $" {
71 pass "run to breakpoint"
74 fail "run to breakpoint"
77 fail "run to breakpoint (timeout)"
82 ".*Breakpoint.*foo \\(i=1\\).*" \
85 # Try disabling a single location. We also test
86 # that at least in simple cases, the enable/disable
87 # state of locations survive "run".
88 # Early bug would disable 1.1 and enable 1.2 when program is run.
89 gdb_test_no_output "disable 1.2" "disabling location: disable"
93 -re "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*$gdb_prompt $" {
94 pass "disabling location: run to breakpoint"
97 fail "disabling location: run to breakpoint"
100 fail "disabling location: run to breakpoint (timeout)"
104 gdb_test_multiple "info break" "disabled breakpoint 1.2" {
105 -re "1\.2.* n .* at .*$hdrfile:$bp_location.*$gdb_prompt $" {
106 pass "disabled breakpoint 1.2"
108 -re "1\.2.* y .* at .*$hdrfile:$bp_location.*$gdb_prompt $" {
109 # When inferior is restarted, breakpoint locations will be updated.
110 # On uclinux, it is not guaranteed that new inferior is located the
111 # same address as previous one, so status/state of breakpoint location
112 # will loose. The heuristic of GDB should be improved.
113 setup_kfail gdb/12924 "*-*-uclinux*"
114 fail "disabled breakpoint 1.2"
118 # Make sure we can set a breakpoint on a source statement that spans
123 set bp_location [gdb_get_line_number "set multi-line breakpoint here" $hdrfile]
125 if { ![runto_main] } {
126 fail "Can't run to main for multi_line_foo tests."
130 gdb_test "break $hdrfile:$bp_location" \
131 "Breakpoint.*at.*: $hdrfile:$bp_location. \\(2 locations\\).*" \
132 "set multi_line_foo breakpoint"
133 gdb_test "continue" \
134 ".*Breakpoint.*multi_line_foo \\(i=0\\).*" \
135 "run to multi_line_foo breakpoint 4 afn"
136 gdb_test "continue" \
137 ".*Breakpoint.*multi_line_foo \\(i=1\\).*" \
138 "run to multi_line_foo breakpoint 4 bfn"