1# Copyright 2007
2# Free Software Foundation, Inc.
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17# This file is part of the gdb testsuite
18
19# This tests setting a break in an ambiguous c++ method with
20# current_language set to c.
21
22if { [skip_cplus_tests] } { continue }
23
24set testfile "method2"
25set srcfile ${testfile}.cc
26set binfile ${objdir}/${subdir}/${testfile}
27
28if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
29     untested method2.exp
30     return -1
31}
32
33if [get_compiler_info $binfile "c++"] {
34  return -1
35}
36
37gdb_exit
38gdb_start
39gdb_reinitialize_dir $srcdir/$subdir
40gdb_load ${binfile}
41
42if ![runto_main] then {
43    perror "couldn't run to breakpoint"
44    continue
45}
46
47proc test_break { lang } {
48    global gdb_prompt
49
50    gdb_test "set lang $lang" \
51	"" \
52	"setting language $lang"
53
54    send_gdb "break A::method\n"
55    gdb_expect {
56	-re ".0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2. A::method\\(A\\*\\) at .*\[\r\n\]*.3. A::method\\(int\\) at .*\[\r\n\]*\[\r\n\]*.4. A::method\\(\\) at .*\[\r\n\]*> $" {
57	    gdb_test "0" \
58		"canceled" \
59		"breaking in method ($lang)"
60	}
61	-re ".*$gdb_prompt $" { fail "breaking in method ($lang)" }
62	default { fail "breaking in method ($lang) (timeout)" }
63    }
64}
65
66test_break "c"
67test_break "c++"
68
69gdb_continue_to_end "continue to end"
70