2010-03-15 Sami Wagiaalla <swagiaal@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / maint.exp
CommitLineData
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
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
21if $tracelevel then {
22 strace $tracelevel
23 }
24
25# Test the help messages.
26
27proc test_help {} {
5c4e30ca
DC
28 set first_component_help "Print the first class/namespace component of NAME"
29 set namespace_help "Print the list of possible C\\+\\+ namespaces"
9219021c 30
d8295fe9
VP
31 test_prefix_command_help {"maintenance cplus"} {
32 "C\\+\\+ maintenance commands\.\[\r\n\]+"
33 }
34
35 test_prefix_command_help {"maint cp" "maintenance cplus"} {
36 "C\\+\\+ maintenance commands.\r\n\r\n"
37 }
9219021c 38
d8295fe9 39 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 40
d8295fe9 41 gdb_test "maint cp" "\"maintenance cplus\" must be followed by the name of a command.\r\n.*"
5c4e30ca
DC
42
43 gdb_test "help maint cp first_component" "${first_component_help}."
44 gdb_test "help maint cp namespace" "${namespace_help}."
9219021c
DC
45}
46
47# This is used when NAME should contain only a single component. Be
48# careful to make sure that parentheses get escaped properly.
49proc test_single_component {name} {
50 set matchname [string_to_regexp "$name"]
51 gdb_test "maint cp first_component $name" "$matchname"
52}
53
b2a7f303
DC
54# This is used when NAME is invalid.
55proc test_invalid_name {name} {
56 set matchname [string_to_regexp "$name"]
57 gdb_test "maint cp first_component $name" \
58 "During symbol reading, unexpected demangled name '$matchname'.\r\n$matchname"
59}
60
9219021c 61proc test_first_component {} {
b2a7f303
DC
62 # The function in question might complain; make sure that we see
63 # all complaints.
64
80df1bbe 65 gdb_test "set complaints 1000" ""
b2a7f303 66
9219021c
DC
67 test_single_component "foo"
68 test_single_component "operator<<"
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
77 test_single_component "foo()"
78 test_single_component "foo(int)"
79 test_single_component "foo(X::Y)"
80 test_single_component "foo(X::Y, A::B)"
81 test_single_component "foo(std::basic_streambuf<wchar_t,std::char_traits<wchar_t> >)"
82 test_single_component "operator>(X::Y)"
83
0f20eeea
DC
84 # Operator names can show up in weird places.
85
86 test_single_component "int operator<< <char>()"
87 test_single_component "T<Cooperator>"
88
89 # NOTE: carlton/2003-04-23: I've only seen the first of these
90 # produced by the demangler, but I'm including two more just to be
91 # on the safe side.
92 test_single_component "int foo<&(operator<<(C, C))>()"
93 test_single_component "int foo<&operator<<(C, C)>()"
94 test_single_component "int foo<operator<<(C, C)>()"
95
9219021c
DC
96 gdb_test "maint cp first_component foo::bar" "foo"
97 gdb_test "maint cp first_component foo::bar::baz" "foo"
98 gdb_test "maint cp first_component C<A>::bar" "C<A>"
99 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
100
101 # Make sure we behave appropriately on invalid input.
102
103 # NOTE: carlton/2003-06-25: As of today, the demangler can in fact
104 # produce examples like the third case below: there really should
105 # be a space between the two <'s. See PR gdb/1245.
106
107 test_invalid_name "foo<"
108 test_invalid_name "foo("
109 test_invalid_name "bool operator<<char>"
9219021c
DC
110}
111
5c4e30ca
DC
112proc test_namespace {} {
113 # There's not a lot we can do to test this.
114
115 gdb_test "maint cp namespace" "Possible namespaces:"
116}
117
9219021c
DC
118gdb_exit
119gdb_start
120
121test_help
122test_first_component
5c4e30ca 123test_namespace
9219021c
DC
124
125gdb_exit
126return 0
This page took 1.208436 seconds and 4 git commands to generate.