]>
Commit | Line | Data |
---|---|---|
4a94e368 | 1 | # Copyright 2003-2022 Free Software Foundation, Inc. |
9219021c DC |
2 | |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
9219021c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
9219021c DC |
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. | |
e22f8b7c | 12 | # |
9219021c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
9219021c | 15 | |
9219021c DC |
16 | |
17 | # This file tests C++-specific maintenance commands and help on those. | |
18 | ||
19 | # Currently, no source file is used. | |
20 | ||
9219021c DC |
21 | # Test the help messages. |
22 | ||
23 | proc test_help {} { | |
5c4e30ca | 24 | set first_component_help "Print the first class/namespace component of NAME" |
0c2e6019 | 25 | set namespace_help "Deprecated placeholder for removed functionality." |
9219021c | 26 | |
d8295fe9 VP |
27 | test_prefix_command_help {"maintenance cplus"} { |
28 | "C\\+\\+ maintenance commands\.\[\r\n\]+" | |
29 | } | |
30 | ||
31 | test_prefix_command_help {"maint cp" "maintenance cplus"} { | |
32 | "C\\+\\+ maintenance commands.\r\n\r\n" | |
33 | } | |
9219021c | 34 | |
0743fc83 | 35 | set multiple_help_body "List of maintenance cplus subcommands:.*Command name abbreviations are allowed if unambiguous." |
9219021c | 36 | |
0743fc83 | 37 | gdb_test "maint cp" $multiple_help_body |
5c4e30ca DC |
38 | |
39 | gdb_test "help maint cp first_component" "${first_component_help}." | |
40 | gdb_test "help maint cp namespace" "${namespace_help}." | |
9219021c DC |
41 | } |
42 | ||
43 | # This is used when NAME should contain only a single component. Be | |
44 | # careful to make sure that parentheses get escaped properly. | |
45 | proc test_single_component {name} { | |
46 | set matchname [string_to_regexp "$name"] | |
47 | gdb_test "maint cp first_component $name" "$matchname" | |
48 | } | |
49 | ||
b2a7f303 DC |
50 | # This is used when NAME is invalid. |
51 | proc test_invalid_name {name} { | |
52 | set matchname [string_to_regexp "$name"] | |
53 | gdb_test "maint cp first_component $name" \ | |
5ca8c39f | 54 | "During symbol reading: unexpected demangled name '$matchname'\r\n$matchname" |
b2a7f303 DC |
55 | } |
56 | ||
9219021c | 57 | proc test_first_component {} { |
b2a7f303 DC |
58 | # The function in question might complain; make sure that we see |
59 | # all complaints. | |
60 | ||
a8d52276 | 61 | gdb_test_no_output "set complaints 1000" |
b2a7f303 | 62 | |
9219021c | 63 | test_single_component "foo" |
baecbb3d AB |
64 | |
65 | foreach spc [list "" " " " "] { | |
66 | test_single_component "operator${spc}<<" | |
67 | test_single_component "operator${spc}>>" | |
68 | test_single_component "operator${spc}->" | |
69 | test_single_component "operator${spc}()" | |
70 | test_single_component "operator${spc}>" | |
71 | test_single_component "operator${spc}<" | |
72 | ||
73 | test_single_component "foo${spc}()" | |
74 | test_single_component "foo${spc}(int)" | |
75 | test_single_component "foo${spc}(X::Y)" | |
76 | test_single_component "foo${spc}(X::Y, A::B)" | |
77 | test_single_component "foo${spc}(std::basic_streambuf<wchar_t,std::char_traits<wchar_t> >)" | |
78 | test_single_component "operator>${spc}(X::Y)" | |
79 | } | |
9219021c | 80 | |
0f20eeea DC |
81 | # Operator names can show up in weird places. |
82 | ||
83 | test_single_component "int operator<< <char>()" | |
84 | test_single_component "T<Cooperator>" | |
85 | ||
86 | # NOTE: carlton/2003-04-23: I've only seen the first of these | |
87 | # produced by the demangler, but I'm including two more just to be | |
88 | # on the safe side. | |
89 | test_single_component "int foo<&(operator<<(C, C))>()" | |
90 | test_single_component "int foo<&operator<<(C, C)>()" | |
91 | test_single_component "int foo<operator<<(C, C)>()" | |
92 | ||
9219021c DC |
93 | gdb_test "maint cp first_component foo::bar" "foo" |
94 | gdb_test "maint cp first_component foo::bar::baz" "foo" | |
95 | gdb_test "maint cp first_component C<A>::bar" "C<A>" | |
96 | gdb_test "maint cp first_component C<std::basic_streambuf<wchar_t,std::char_traits<wchar_t> > >::bar" "C<std::basic_streambuf<wchar_t,std::char_traits<wchar_t> > >" | |
b2a7f303 DC |
97 | |
98 | # Make sure we behave appropriately on invalid input. | |
99 | ||
100 | # NOTE: carlton/2003-06-25: As of today, the demangler can in fact | |
101 | # produce examples like the third case below: there really should | |
102 | # be a space between the two <'s. See PR gdb/1245. | |
103 | ||
104 | test_invalid_name "foo<" | |
105 | test_invalid_name "foo(" | |
106 | test_invalid_name "bool operator<<char>" | |
9219021c DC |
107 | } |
108 | ||
5c4e30ca | 109 | proc test_namespace {} { |
0c2e6019 | 110 | gdb_test "maint cp namespace" "The `maint namespace' command was removed." |
5c4e30ca DC |
111 | } |
112 | ||
9219021c DC |
113 | gdb_exit |
114 | gdb_start | |
115 | ||
116 | test_help | |
117 | test_first_component | |
5c4e30ca | 118 | test_namespace |
9219021c DC |
119 | |
120 | gdb_exit | |
121 | return 0 |