138494Sobrien# Copyright 2011-2023 Free Software Foundation, Inc. 282794Sobrien# 338494Sobrien# Contributed by Red Hat, originally written by Keith Seitz. 438494Sobrien# 538494Sobrien# This program is free software; you can redistribute it and/or modify 638494Sobrien# it under the terms of the GNU General Public License as published by 738494Sobrien# the Free Software Foundation; either version 3 of the License, or 838494Sobrien# (at your option) any later version. 938494Sobrien# 1038494Sobrien# This program is distributed in the hope that it will be useful, 1138494Sobrien# but WITHOUT ANY WARRANTY; without even the implied warranty of 1238494Sobrien# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1338494Sobrien# GNU General Public License for more details. 1438494Sobrien# 1538494Sobrien# You should have received a copy of the GNU General Public License 1638494Sobrien# along with this program. If not, see <http://www.gnu.org/licenses/>. 1738494Sobrien 1838494Sobrien# This file is part of the gdb testsuite. 1938494Sobrien 2042629Sobrienproc test_class {class} { 2138494Sobrien 2238494Sobrien # An array holding the overload types for the methods A::outer::foo 2338494Sobrien # and A::B::inner::foo. The first element is the overloaded method 2438494Sobrien # parameter. The second element is the expected source file number, 2538494Sobrien # e.g. "ovsrch?.cc". 2638494Sobrien array set tests { 2738494Sobrien "char*" 4 2838494Sobrien "int" 3 2938494Sobrien "void" 2 3038494Sobrien } 3138494Sobrien 3238494Sobrien # Test each overload instance twice: once quoted, once unquoted 3338494Sobrien set conditional1 "if (a_param == 3)" 3438494Sobrien set conditional2 "if (A::outer::func ())" 3538494Sobrien foreach ovld [array names tests] { 3638494Sobrien set method "${class}::foo ($ovld) const" 3738494Sobrien set result "Breakpoint (\[0-9\]).*file .*ovsrch$tests($ovld).*" 3838494Sobrien gdb_test "break $method" $result 3938494Sobrien gdb_test "break '$method'" $result 4038494Sobrien 4182794Sobrien # Also test with a conditional tacked onto the end. 4238494Sobrien if {[string compare $ovld "void"] != 0} { 4338494Sobrien gdb_test "break $method $conditional1" $result 4438494Sobrien gdb_test "break '$method' $conditional1" $result 4538494Sobrien gdb_test "break $method $conditional2" $result 4638494Sobrien gdb_test "break '$method' $conditional2" $result 4738494Sobrien } 4838494Sobrien } 4938494Sobrien 5038494Sobrien # Test whether open parentheses are correctly identified as overload 5138494Sobrien # information or conditional. 5238494Sobrien gdb_test "break ${class}::hibob if (a_param == 3)" "Breakpoint (\[0-9\]).*" 5338494Sobrien} 5438494Sobrien 5538494Sobrienif { [skip_cplus_tests] } { return } 5682794Sobrien 5738494Sobrien# Test for c++/11734 5838494Sobrienstandard_testfile ovsrch1.cc ovsrch2.cc ovsrch3.cc ovsrch4.cc 5938494Sobrien 6038494Sobrienif {[prepare_for_testing "failed to prepare" $testfile \ 6138494Sobrien [list $srcfile $srcfile2 $srcfile3 $srcfile4] {c++ debug}]} { 6238494Sobrien return -1 6338494Sobrien} 6438494Sobrien 6538494Sobrienif {![runto_main]} { 6638494Sobrien return 6738494Sobrien} 6838494Sobrien 6938494Sobrien# Break in A::stop_here and run tests. 7038494Sobrienif {[gdb_breakpoint "A::stop_here"]} { 7138494Sobrien pass "break A::stop_here" 7238494Sobrien} 7338494Sobrien 7438494Sobrienif {[gdb_breakpoint "'A::stop_here'"]} { 7538494Sobrien pass "break 'A::stop_here'" 7638494Sobrien} 7738494Sobrien 7838494Sobriengdb_continue_to_breakpoint "stop_here" 7938494Sobrientest_class A::outer 8038494Sobrien 8138494Sobrien# Break in A::B::stop_here_too and run tests. 8238494Sobrienif {[gdb_breakpoint "A::B::stop_here_too"]} { 8338494Sobrien pass "break A::B::stop_here_too" 8438494Sobrien} 8538494Sobrien 8638494Sobrienif {[gdb_breakpoint "'A::B::stop_here_too'"]} { 8738494Sobrien pass "break 'A::B::stop_here_too'" 8838494Sobrien} 8938494Sobrien 9038494Sobriengdb_continue_to_breakpoint "stop_here_too" 9138494Sobrientest_class A::B::inner 9238494Sobrien 9338494Sobriengdb_exit 9438494Sobrienreturn 0 9538494Sobrien