old-cross-binutils/gdb/testsuite/gdb.cp/maint.exp
David Carlton 5c4e30cabe 2003-09-11 David Carlton <carlton@kealia.com>
* gdbtypes.h: Add TYPE_CODE_NAMESPACE.
	* gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE.
	(recursive_dump_type): Ditto.
	* printcmd.c (print_formatted): Ditto.
	* typeprint.c (print_type_scalar): Ditto.
	* c-typeprint.c (c_type_print_varspec_prefix): Ditto.
	(c_type_print_varspec_suffix, c_type_print_base): Ditto.
	* cp-support.h: Declare cp_check_possible_namespace_symbols,
	maint_cplus_cmd_list.
	* cp-support.c: Make maint_cplus_cmd_list extern.
	* cp-namespace.c: Include objfiles.h, gdbtypes.h, dictionary.h,
	command.h.
	(lookup_symbol_file): Look in possible namespace blocks when
	appropriate.
	(initialize_namespace_symtab): New.
	(get_possible_namespace_block, free_namespace_block)
	(check_possible_namespace_symbols)
	(check_possible_namespace_symbols_loop)
	(check_one_possible_namespace_symbol)
	(lookup_possible_namespace_symbol, maintenance_cplus_namespace)
	(_initialize_cp_namespace): Ditto.
	* block.h: Declare allocate_block.
	* block.c (allocate_block): New.
	* jv-lang.c (get_java_class_symtab): Allocate blocks via
	allocate_block.
	* symfile.h: Update declaration of add_psymbol_to_list.
	* symfile.c (add_psymbol_to_list): Return the partial symbol in
	question.
	* dwarf2read.c (dwarf2_build_psymtabs_hard): Add argument to
	scan_partial_symbols_call.
	(scan_partial_symbols): Add NAMESPACE argument; update calls to
	helper functions.
	(add_partial_symbol): If necessary, scan mangled names for names
	of namespaces.
	(add_partial_namespace): Add NAMESPACE argument; generate partial
	symbols associated  to namespaces.
	(add_partial_enumeration): Add NAMESPACE argument.
	(new_symbol): Allow namespace syms.
	(read_namespace): Generate namespace syms.
	* objfiles.h: Add opaque declaration of struct symtab.
	(struct objfile): Add cp_namespace_symtab member.
	* objfiles.c (allocate_objfile): Set
	objfile->cp_namespace_symtab.
	* Makefile.in (cp-namespace.o): Depend on objfiles_h, gdbtypes_h,
	dictionary_h, command_h.

2003-09-11  David Carlton  <carlton@kealia.com>

	* gdb.c++/namespace.exp: Add tests for namespace types.
	* gdb.c++/maint.exp (test_help): Test 'help maint cp namespace'.
	(test_namespace): New.
2003-09-11 19:49:20 +00:00

126 lines
4.6 KiB
Text

# Copyright 2003 Free Software Foundation Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
# This file tests C++-specific maintenance commands and help on those.
# Currently, no source file is used.
if $tracelevel then {
strace $tracelevel
}
# Test the help messages.
proc test_help {} {
set first_component_help "Print the first class/namespace component of NAME"
set namespace_help "Print the list of possible C\\+\\+ namespaces"
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."
set help_maint_cp "C\\+\\+ maintenance commands.\r\n\r\n${multiple_help_body}"
gdb_test "help maintenance cplus" "${help_maint_cp}"
gdb_test "help maint cp" "${help_maint_cp}"
gdb_test "maint cp" "\"maintenance cplus\" must be followed by the name of a command.\r\n${multiple_help_body}"
gdb_test "help maint cp first_component" "${first_component_help}."
gdb_test "help maint cp namespace" "${namespace_help}."
}
# This is used when NAME should contain only a single component. Be
# careful to make sure that parentheses get escaped properly.
proc test_single_component {name} {
set matchname [string_to_regexp "$name"]
gdb_test "maint cp first_component $name" "$matchname"
}
# This is used when NAME is invalid.
proc test_invalid_name {name} {
set matchname [string_to_regexp "$name"]
gdb_test "maint cp first_component $name" \
"During symbol reading, unexpected demangled name '$matchname'.\r\n$matchname"
}
proc test_first_component {} {
# The function in question might complain; make sure that we see
# all complaints.
gdb_test "set complaints -1" ""
test_single_component "foo"
test_single_component "operator<<"
test_single_component "operator>>"
test_single_component "operator ->"
test_single_component "operator()"
test_single_component "operator>"
test_single_component "operator<"
test_single_component "operator ->"
test_single_component "operator ->"
test_single_component "foo()"
test_single_component "foo(int)"
test_single_component "foo(X::Y)"
test_single_component "foo(X::Y, A::B)"
test_single_component "foo(std::basic_streambuf<wchar_t,std::char_traits<wchar_t> >)"
test_single_component "operator>(X::Y)"
# Operator names can show up in weird places.
test_single_component "int operator<< <char>()"
test_single_component "T<Cooperator>"
# NOTE: carlton/2003-04-23: I've only seen the first of these
# produced by the demangler, but I'm including two more just to be
# on the safe side.
test_single_component "int foo<&(operator<<(C, C))>()"
test_single_component "int foo<&operator<<(C, C)>()"
test_single_component "int foo<operator<<(C, C)>()"
gdb_test "maint cp first_component foo::bar" "foo"
gdb_test "maint cp first_component foo::bar::baz" "foo"
gdb_test "maint cp first_component C<A>::bar" "C<A>"
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> > >"
# Make sure we behave appropriately on invalid input.
# NOTE: carlton/2003-06-25: As of today, the demangler can in fact
# produce examples like the third case below: there really should
# be a space between the two <'s. See PR gdb/1245.
test_invalid_name "foo<"
test_invalid_name "foo("
test_invalid_name "bool operator<<char>"
}
proc test_namespace {} {
# There's not a lot we can do to test this.
gdb_test "maint cp namespace" "Possible namespaces:"
}
gdb_exit
gdb_start
test_help
test_first_component
test_namespace
gdb_exit
return 0