* gdb.cp/maint.exp: Set complaints to a positive value.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / maint.exp
1 # Copyright 2003, 2004, 2006 Free Software Foundation Inc.
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
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 {} {
29 set first_component_help "Print the first class/namespace component of NAME"
30 set namespace_help "Print the list of possible C\\+\\+ namespaces"
31
32 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."
33
34 set help_maint_cp "C\\+\\+ maintenance commands.\r\n\r\n${multiple_help_body}"
35
36 gdb_test "help maintenance cplus" "${help_maint_cp}"
37 gdb_test "help maint cp" "${help_maint_cp}"
38 gdb_test "maint cp" "\"maintenance cplus\" must be followed by the name of a command.\r\n${multiple_help_body}"
39
40 gdb_test "help maint cp first_component" "${first_component_help}."
41 gdb_test "help maint cp namespace" "${namespace_help}."
42 }
43
44 # This is used when NAME should contain only a single component. Be
45 # careful to make sure that parentheses get escaped properly.
46 proc test_single_component {name} {
47 set matchname [string_to_regexp "$name"]
48 gdb_test "maint cp first_component $name" "$matchname"
49 }
50
51 # This is used when NAME is invalid.
52 proc test_invalid_name {name} {
53 set matchname [string_to_regexp "$name"]
54 gdb_test "maint cp first_component $name" \
55 "During symbol reading, unexpected demangled name '$matchname'.\r\n$matchname"
56 }
57
58 proc test_first_component {} {
59 # The function in question might complain; make sure that we see
60 # all complaints.
61
62 gdb_test "set complaints 1000" ""
63
64 test_single_component "foo"
65 test_single_component "operator<<"
66 test_single_component "operator>>"
67 test_single_component "operator ->"
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
74 test_single_component "foo()"
75 test_single_component "foo(int)"
76 test_single_component "foo(X::Y)"
77 test_single_component "foo(X::Y, A::B)"
78 test_single_component "foo(std::basic_streambuf<wchar_t,std::char_traits<wchar_t> >)"
79 test_single_component "operator>(X::Y)"
80
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
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> > >"
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>"
107 }
108
109 proc test_namespace {} {
110 # There's not a lot we can do to test this.
111
112 gdb_test "maint cp namespace" "Possible namespaces:"
113 }
114
115 gdb_exit
116 gdb_start
117
118 test_help
119 test_first_component
120 test_namespace
121
122 gdb_exit
123 return 0
This page took 0.032877 seconds and 5 git commands to generate.