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