2003-06-30 David Carlton <carlton@kealia.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.c++ / maint.exp
CommitLineData
9219021c
DC
1# Copyright 2003 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# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20
21# This file tests C++-specific maintenance commands and help on those.
22
23# Currently, no source file is used.
24
25if $tracelevel then {
26 strace $tracelevel
27 }
28
29# Test the help messages.
30
31proc test_help {} {
32 gdb_test "help maintenance cplus" "C\\+\\+ maintenance commands.\r\n\r\nList of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- Print the first class/namespace component of NAME\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 gdb_test "help maint cp" "C\\+\\+ maintenance commands.\r\n\r\nList of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- Print the first class/namespace component of NAME\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous."
35
36 gdb_test "maint cp" "\"maintenance cplus\" must be followed by the name of a command.\r\nList of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- Print the first class/namespace component of NAME\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous."
37
38 gdb_test "help maint cp first_component" "Print the first class/namespace component of NAME."
39}
40
41# This is used when NAME should contain only a single component. Be
42# careful to make sure that parentheses get escaped properly.
43proc test_single_component {name} {
44 set matchname [string_to_regexp "$name"]
45 gdb_test "maint cp first_component $name" "$matchname"
46}
47
b2a7f303
DC
48# This is used when NAME is invalid.
49proc test_invalid_name {name} {
50 set matchname [string_to_regexp "$name"]
51 gdb_test "maint cp first_component $name" \
52 "During symbol reading, unexpected demangled name '$matchname'.\r\n$matchname"
53}
54
9219021c 55proc test_first_component {} {
b2a7f303
DC
56 # The function in question might complain; make sure that we see
57 # all complaints.
58
59 gdb_test "set complaints -1" ""
60
9219021c
DC
61 test_single_component "foo"
62 test_single_component "operator<<"
63 test_single_component "operator>>"
64 test_single_component "operator ->"
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
71 test_single_component "foo()"
72 test_single_component "foo(int)"
73 test_single_component "foo(X::Y)"
74 test_single_component "foo(X::Y, A::B)"
75 test_single_component "foo(std::basic_streambuf<wchar_t,std::char_traits<wchar_t> >)"
76 test_single_component "operator>(X::Y)"
77
0f20eeea
DC
78 # Operator names can show up in weird places.
79
80 test_single_component "int operator<< <char>()"
81 test_single_component "T<Cooperator>"
82
83 # NOTE: carlton/2003-04-23: I've only seen the first of these
84 # produced by the demangler, but I'm including two more just to be
85 # on the safe side.
86 test_single_component "int foo<&(operator<<(C, C))>()"
87 test_single_component "int foo<&operator<<(C, C)>()"
88 test_single_component "int foo<operator<<(C, C)>()"
89
9219021c
DC
90 gdb_test "maint cp first_component foo::bar" "foo"
91 gdb_test "maint cp first_component foo::bar::baz" "foo"
92 gdb_test "maint cp first_component C<A>::bar" "C<A>"
93 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
94
95 # Make sure we behave appropriately on invalid input.
96
97 # NOTE: carlton/2003-06-25: As of today, the demangler can in fact
98 # produce examples like the third case below: there really should
99 # be a space between the two <'s. See PR gdb/1245.
100
101 test_invalid_name "foo<"
102 test_invalid_name "foo("
103 test_invalid_name "bool operator<<char>"
9219021c
DC
104}
105
106gdb_exit
107gdb_start
108
109test_help
110test_first_component
111
112gdb_exit
113return 0
This page took 0.054465 seconds and 4 git commands to generate.