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