]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2011-2024 Free Software Foundation, Inc. |
598997c8 KS |
2 | # |
3 | # Contributed by Red Hat, originally written by Keith Seitz. | |
4 | # | |
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. | |
9 | # | |
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. | |
14 | # | |
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/>. | |
17 | ||
18 | # This file is part of the gdb testsuite. | |
19 | ||
20 | proc test_class {class} { | |
21 | ||
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, | |
25 | # e.g. "ovsrch?.cc". | |
26 | array set tests { | |
27 | "char*" 4 | |
28 | "int" 3 | |
29 | "void" 2 | |
30 | } | |
31 | ||
32 | # Test each overload instance twice: once quoted, once unquoted | |
d8ea7931 | 33 | set conditional1 "if (a_param == 3)" |
598997c8 KS |
34 | set conditional2 "if (A::outer::func ())" |
35 | foreach ovld [array names tests] { | |
36 | set method "${class}::foo ($ovld) const" | |
0e7a53fc | 37 | set result "Breakpoint (\[0-9\]).*file .*ovsrch$tests($ovld).*" |
598997c8 KS |
38 | gdb_test "break $method" $result |
39 | gdb_test "break '$method'" $result | |
40 | ||
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 | |
47 | } | |
48 | } | |
49 | ||
50 | # Test whether open parentheses are correctly identified as overload | |
51 | # information or conditional. | |
f8eba3c6 | 52 | gdb_test "break ${class}::hibob if (a_param == 3)" "Breakpoint (\[0-9\]).*" |
598997c8 KS |
53 | } |
54 | ||
0b94d2b9 | 55 | require allow_cplus_tests |
598997c8 KS |
56 | |
57 | # Test for c++/11734 | |
f5f3a911 | 58 | standard_testfile ovsrch1.cc ovsrch2.cc ovsrch3.cc ovsrch4.cc |
598997c8 | 59 | |
722c4596 TV |
60 | include_file ovsrch.h |
61 | ||
5b362f04 | 62 | if {[prepare_for_testing "failed to prepare" $testfile \ |
f5f3a911 | 63 | [list $srcfile $srcfile2 $srcfile3 $srcfile4] {c++ debug}]} { |
598997c8 KS |
64 | return -1 |
65 | } | |
66 | ||
67 | if {![runto_main]} { | |
cdd42066 | 68 | return |
598997c8 KS |
69 | } |
70 | ||
71 | # Break in A::stop_here and run tests. | |
f8eba3c6 TT |
72 | if {[gdb_breakpoint "A::stop_here"]} { |
73 | pass "break A::stop_here" | |
598997c8 KS |
74 | } |
75 | ||
f8eba3c6 TT |
76 | if {[gdb_breakpoint "'A::stop_here'"]} { |
77 | pass "break 'A::stop_here'" | |
598997c8 KS |
78 | } |
79 | ||
80 | gdb_continue_to_breakpoint "stop_here" | |
f8eba3c6 | 81 | test_class A::outer |
598997c8 KS |
82 | |
83 | # Break in A::B::stop_here_too and run tests. | |
f8eba3c6 TT |
84 | if {[gdb_breakpoint "A::B::stop_here_too"]} { |
85 | pass "break A::B::stop_here_too" | |
598997c8 KS |
86 | } |
87 | ||
f8eba3c6 TT |
88 | if {[gdb_breakpoint "'A::B::stop_here_too'"]} { |
89 | pass "break 'A::B::stop_here_too'" | |
598997c8 KS |
90 | } |
91 | ||
92 | gdb_continue_to_breakpoint "stop_here_too" | |
f8eba3c6 | 93 | test_class A::B::inner |
598997c8 KS |
94 | |
95 | gdb_exit |