1 # Copyright 2011 Free Software Foundation, Inc.
3 # Contributed by Red Hat, originally written by Keith Seitz.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # This file is part of the gdb testsuite.
20 proc test_class {class} {
22 # An array holding the overload types for the methods A::outer::foo
23 # and A::B::inner::foo. The first element is the overloaded method
24 # parameter. The second element is the expected source file number,
32 # Test each overload instance twice: once quoted, once unquoted
33 set conditional1 "if (a == 3)"
34 set conditional2 "if (A::outer::func ())"
35 foreach ovld [array names tests] {
36 set method "${class}::foo ($ovld) const"
37 set result "Breakpoint (\[0-9\]).*file .*/ovsrch$tests($ovld).*"
38 gdb_test "break $method" $result
39 gdb_test "break '$method'" $result
41 # Also test with a conditional tacked onto the end.
42 if {[string compare $ovld "void"] != 0} {
43 gdb_test "break $method $conditional1" $result
44 gdb_test "break '$method' $conditional1" $result
45 gdb_test "break $method $conditional2" $result
46 gdb_test "break '$method' $conditional2" $result
50 # Test whether open parentheses are correctly identified as overload
51 # information or conditional.
52 gdb_test "break ${class}::foo if (a == 3)" "Breakpoint (\[0-9\]).*"
55 if { [skip_cplus_tests] } { continue }
59 set binfile [file join $objdir $subdir $testfile]
62 for {set i 1} {$i < 5} {incr i} {
63 lappend srcfiles $testfile$i.cc
66 if {[prepare_for_testing $testfile $testfile $srcfiles {c++ debug}]} {
71 perror "couldn't run to breakpoint"
75 # Break in A::stop_here and run tests.
76 if {[gdb_breakpoint "stop_here"]} {
77 pass "break stop_here"
80 if {[gdb_breakpoint "'stop_here'"]} {
81 pass "break 'stop_here'"
84 gdb_continue_to_breakpoint "stop_here"
87 # Break in A::B::stop_here_too and run tests.
88 if {[gdb_breakpoint "B::stop_here_too"]} {
89 pass "break B::stop_here_too"
92 if {[gdb_breakpoint "'B::stop_here_too'"]} {
93 pass "break 'B::stop_here_too'"
96 gdb_continue_to_breakpoint "stop_here_too"