2010-01-01 07:32:07 +00:00
|
|
|
# Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010
|
2004-01-02 06:38:01 +00:00
|
|
|
# Free Software Foundation, Inc.
|
2000-06-05 20:47:28 +00:00
|
|
|
|
|
|
|
# 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
|
2007-08-23 18:14:19 +00:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2000-06-05 20:47:28 +00:00
|
|
|
# (at your option) any later version.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
2000-06-05 20:47:28 +00:00
|
|
|
# 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.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
2000-06-05 20:47:28 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 18:14:19 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2000-06-05 20:47:28 +00:00
|
|
|
|
|
|
|
# tests for namespaces
|
2003-09-25 16:39:39 +00:00
|
|
|
# Originally written by Satish Pai <pai@apollo.hp.com> 1997-07-23
|
2000-06-05 20:47:28 +00:00
|
|
|
|
|
|
|
# This file is part of the gdb testsuite
|
|
|
|
|
2003-09-25 16:39:39 +00:00
|
|
|
# Note: The original tests were geared to the HP aCC compiler,
|
2000-06-05 20:47:28 +00:00
|
|
|
# which has an idiosyncratic way of emitting debug info
|
|
|
|
# for namespaces.
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 16:54:43 +00:00
|
|
|
# Note: As of 2000-06-03, they passed under g++ - djb
|
2000-06-05 20:47:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
if $tracelevel then {
|
|
|
|
strace $tracelevel
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-08 21:09:23 +00:00
|
|
|
if { [skip_cplus_tests] } { continue }
|
2000-06-05 20:47:28 +00:00
|
|
|
|
|
|
|
set testfile "namespace"
|
|
|
|
set srcfile ${testfile}.cc
|
2003-05-20 03:56:29 +00:00
|
|
|
set objfile ${objdir}/${subdir}/${testfile}.o
|
|
|
|
set srcfile1 ${testfile}1.cc
|
|
|
|
set objfile1 ${objdir}/${subdir}/${testfile}1.o
|
2000-06-05 20:47:28 +00:00
|
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
|
|
|
|
2004-01-07 08:44:32 +00:00
|
|
|
if [get_compiler_info ${binfile} c++] {
|
2000-06-05 20:47:28 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2003-05-20 03:56:29 +00:00
|
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug c++}] != "" } {
|
2006-08-10 05:27:22 +00:00
|
|
|
untested namespace.exp
|
|
|
|
return -1
|
2000-06-05 20:47:28 +00:00
|
|
|
}
|
|
|
|
|
2003-05-20 03:56:29 +00:00
|
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${objfile1}" object {debug c++}] != "" } {
|
2006-08-10 05:27:22 +00:00
|
|
|
untested namespace.exp
|
|
|
|
return -1
|
2003-05-20 03:56:29 +00:00
|
|
|
}
|
2000-06-05 20:47:28 +00:00
|
|
|
|
2003-05-20 03:56:29 +00:00
|
|
|
if { [gdb_compile "${objfile} ${objfile1}" "${binfile}" executable {debug c++}] != "" } {
|
2006-08-10 05:27:22 +00:00
|
|
|
untested namespace.exp
|
|
|
|
return -1
|
2003-05-20 03:56:29 +00:00
|
|
|
}
|
2000-06-05 20:47:28 +00:00
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
gdb_start
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
gdb_load ${binfile}
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# set it up at a breakpoint so we can play with the variable values
|
|
|
|
#
|
|
|
|
if ![runto_main] then {
|
|
|
|
perror "couldn't run to breakpoint"
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2001-04-23 17:02:05 +00:00
|
|
|
if ![runto 'marker1'] then {
|
|
|
|
perror "couldn't run to marker1"
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
gdb_test "up" ".*main.*" "up from marker1"
|
2000-06-05 20:47:28 +00:00
|
|
|
|
|
|
|
# Access a data item inside a namespace using colons and
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 16:54:43 +00:00
|
|
|
# single quotes. :-(
|
2000-06-05 20:47:28 +00:00
|
|
|
|
2003-09-25 16:39:39 +00:00
|
|
|
# NOTE: carlton/2003-09-24: the quotes are becoming less necessary (or
|
|
|
|
# even desirable.) For tests where it should still work with quotes,
|
|
|
|
# I'm including versions both with and without quotes; for tests that
|
|
|
|
# shouldn't work with quotes, I'm only including one version.
|
|
|
|
|
2010-06-01 18:18:35 +00:00
|
|
|
gdb_test "print 'AAA::c'" \
|
|
|
|
"\\$\[0-9\]* = 0 '\\\\(0|000)'" \
|
|
|
|
"print 'AAA::c'"
|
2000-06-05 20:47:28 +00:00
|
|
|
|
2010-06-01 18:18:35 +00:00
|
|
|
gdb_test "print AAA::c" \
|
|
|
|
"\\$\[0-9\]* = 0 '\\\\(0|000)'" \
|
|
|
|
"print AAA::c"
|
2003-09-25 16:39:39 +00:00
|
|
|
|
2000-06-05 20:47:28 +00:00
|
|
|
# An object declared using "using".
|
|
|
|
|
2010-06-01 18:18:35 +00:00
|
|
|
gdb_test "print ina" "\\$\[0-9\]+ = {xx = 33}"
|
2000-06-05 20:47:28 +00:00
|
|
|
|
2010-06-01 18:18:35 +00:00
|
|
|
gdb_test_multiple "ptype ina" "ptype ina" {
|
|
|
|
-re "type = class (AAA::|)inA \{\r\n\[ \]*public:\r\n\[ \]*int xx;\r\n\[ \]*\r\n\[ \]*.*int fum\\(int\\);\r\n\}\r\n$gdb_prompt $" {
|
|
|
|
pass "ptype ina"
|
|
|
|
}
|
|
|
|
-re "type = class (AAA::|)inA \{\r\n\[ \]*public:\r\n\[ \]*int xx;\r\n\[ \]*\r\n\[ \]*int fum\\(int\\);\r\n.*\}\r\n$gdb_prompt $" {
|
|
|
|
pass "ptype ina"
|
|
|
|
}
|
2000-06-05 20:47:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Check all functions are known to GDB
|
|
|
|
|
|
|
|
setup_xfail hppa*-*-*11* CLLbs14869
|
2010-06-01 18:18:35 +00:00
|
|
|
gdb_test_multiple "info func xyzq" "info func xyzq" {
|
|
|
|
-re "All functions.*File.*namespace.cc:\r\nint AAA::A_xyzq\\(int\\);\r\nint BBB::B_xyzq\\(int\\);\r\nchar AAA::xyzq\\(char\\);\r\nchar BBB::xyzq\\(char\\);\r\nchar BBB::CCC::xyzq\\(char\\);\r\nchar BBB::Class::xyzq\\(char\\);\r\n$gdb_prompt $" {
|
|
|
|
pass "info func xyzq"
|
|
|
|
}
|
|
|
|
-re "All functions.*File.*namespace.cc:\r\nint AAA::A_xyzq\\(int\\);\r\nchar AAA::xyzq\\(char\\);\r\nint BBB::B_xyzq\\(int\\);\r\nchar BBB::CCC::xyzq\\(char\\);\r\nchar BBB::Class::xyzq\\(char\\);\r\nchar BBB::xyzq\\(char\\);\r\n$gdb_prompt $" {
|
|
|
|
pass "info func xyzq"
|
|
|
|
}
|
2000-06-05 20:47:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Call a function in a namespace
|
|
|
|
|
2010-06-01 18:18:35 +00:00
|
|
|
gdb_test "print 'AAA::xyzq'('x')" \
|
|
|
|
"\\$\[0-9\]* = 97 'a'" \
|
|
|
|
"print 'AAA::xyzq'('x')"
|
|
|
|
|
|
|
|
gdb_test "print AAA::xyzq('x')" \
|
|
|
|
"\\$\[0-9\]* = 97 'a'" \
|
|
|
|
"print AAA::xyzq('x')"
|
2003-09-25 16:39:39 +00:00
|
|
|
|
2000-06-05 20:47:28 +00:00
|
|
|
# Break on a function in a namespace
|
|
|
|
|
2009-11-12 19:54:39 +00:00
|
|
|
gdb_test "break AAA::xyzq" \
|
2010-01-19 18:11:19 +00:00
|
|
|
"Breakpoint.*at $hex: file.*namespace.cc, line 47\\."
|
2000-06-05 20:47:28 +00:00
|
|
|
|
|
|
|
# Call a function in a nested namespace
|
|
|
|
|
2010-06-01 18:18:35 +00:00
|
|
|
gdb_test "print 'BBB::CCC::xyzq'('x')" \
|
|
|
|
"\\$\[0-9\]* = 122 'z'" \
|
|
|
|
"print 'BBB::CCC::xyzq'('x')"
|
|
|
|
|
|
|
|
gdb_test "print BBB::CCC::xyzq('x')" \
|
|
|
|
"\\$\[0-9\]* = 122 'z'" \
|
|
|
|
"print BBB::CCC::xyzq('x')"
|
2003-09-25 16:39:39 +00:00
|
|
|
|
2000-06-05 20:47:28 +00:00
|
|
|
# Break on a function in a nested namespace
|
|
|
|
|
2009-11-12 19:54:39 +00:00
|
|
|
gdb_test "break BBB::CCC::xyzq" \
|
2010-01-19 18:11:19 +00:00
|
|
|
"Breakpoint.*at $hex: file.*namespace.cc, line 63\\."
|
2000-06-05 20:47:28 +00:00
|
|
|
|
|
|
|
# Print address of a function in a class in a namespace
|
|
|
|
|
2010-06-01 18:18:35 +00:00
|
|
|
gdb_test "print 'BBB::Class::xyzq'" \
|
|
|
|
"\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <BBB::Class::xyzq\\(char\\)>" \
|
|
|
|
"print 'BBB::Class::xyzq'"
|
2000-06-05 20:47:28 +00:00
|
|
|
|
2010-06-01 18:18:35 +00:00
|
|
|
gdb_test "print BBB::Class::xyzq" \
|
|
|
|
"\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <BBB::Class::xyzq\\(char\\)>" \
|
|
|
|
"print BBB::Class::xyzq"
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 16:54:43 +00:00
|
|
|
|
2000-06-05 20:47:28 +00:00
|
|
|
# Break on a function in a class in a namespace
|
|
|
|
|
2009-11-12 19:54:39 +00:00
|
|
|
gdb_test "break BBB::Class::xyzq" \
|
2010-01-19 18:11:19 +00:00
|
|
|
"Breakpoint.*at $hex: file.*namespace.cc, line 68\\."
|
2000-06-05 20:47:28 +00:00
|
|
|
|
2010-06-28 20:35:52 +00:00
|
|
|
# Tests accessing static elements in namespace of other file.
|
|
|
|
|
|
|
|
gdb_test "whatis C::cOtherFileType" "type = short"
|
|
|
|
gdb_test "whatis ::C::cOtherFileType" "type = short"
|
|
|
|
gdb_test "whatis C::cOtherFileVar" "type = const C::cOtherFileType"
|
|
|
|
gdb_test "whatis ::C::cOtherFileVar" "type = const C::cOtherFileType"
|
|
|
|
gdb_test "print C::cOtherFileVar" "\\$\[0-9\].* = 319"
|
|
|
|
gdb_test "print ::C::cOtherFileVar" "\\$\[0-9\].* = 319"
|
|
|
|
|
|
|
|
if {[test_compiler_info {gcc-[0-3]-*}]
|
|
|
|
|| [test_compiler_info {gcc-4-[0-4]-*}]} {
|
|
|
|
# The type in class is missing in older GCCs.
|
|
|
|
setup_xfail *-*-*
|
|
|
|
}
|
|
|
|
gdb_test "whatis C::OtherFileClass::cOtherFileClassType" "type = short"
|
|
|
|
if {[test_compiler_info {gcc-[0-3]-*}]
|
|
|
|
|| [test_compiler_info {gcc-4-[0-4]-*}]} {
|
|
|
|
# The type in class is missing in older GCCs.
|
|
|
|
setup_xfail *-*-*
|
|
|
|
}
|
|
|
|
gdb_test "whatis ::C::OtherFileClass::cOtherFileClassType" "type = short"
|
|
|
|
|
|
|
|
set test "print C::OtherFileClass::cOtherFileClassVar"
|
|
|
|
gdb_test_multiple $test $test {
|
|
|
|
-re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" {
|
|
|
|
pass $test
|
|
|
|
}
|
|
|
|
-re "static field cOtherFileClassVar has been optimized out\r\n$gdb_prompt $" {
|
|
|
|
setup_kfail "c++/11702" "*-*-*"
|
|
|
|
fail $test
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# FSF GCC <=4.4 creates unqualified DIE "cOtherFileClassVar" ignoring the
|
|
|
|
# namespace the same way older GDB did.
|
|
|
|
set test "print ::cOtherFileClassVar"
|
|
|
|
set test2 "print ::C::OtherFileClass::cOtherFileClassVar"
|
|
|
|
gdb_test_multiple $test $test {
|
|
|
|
-re "No symbol \"cOtherFileClassVar\" in current context\\.\r\n$gdb_prompt $" {
|
|
|
|
pass $test
|
|
|
|
|
|
|
|
gdb_test_multiple $test2 $test2 {
|
|
|
|
-re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" {
|
|
|
|
pass $test2
|
|
|
|
}
|
|
|
|
-re "static field cOtherFileClassVar has been optimized out\r\n$gdb_prompt $" {
|
|
|
|
setup_kfail "c++/11702" "*-*-*"
|
|
|
|
fail $test2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
-re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" {
|
|
|
|
if {[test_compiler_info {gcc-[0-3]-*}]
|
|
|
|
|| [test_compiler_info {gcc-4-[0-4]-*}]} {
|
|
|
|
# Do not permit to XFAIL on recent GCCs.
|
|
|
|
setup_xfail *-*-*
|
|
|
|
}
|
|
|
|
fail $test
|
|
|
|
|
|
|
|
unresolved $test2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-20 03:56:29 +00:00
|
|
|
# Test to see if the appropriate namespaces are in scope when trying
|
|
|
|
# to print out stuff from within a function defined within a
|
|
|
|
# namespace.
|
|
|
|
|
|
|
|
if ![runto "C::D::marker2"] then {
|
|
|
|
perror "couldn't run to marker2"
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
gdb_test "print c" "\\$\[0-9\].* = 1"
|
|
|
|
gdb_test "print cc" "No symbol \"cc\" in current context."
|
|
|
|
gdb_test "print 'C::cc'" "\\$\[0-9\].* = 2"
|
2003-09-25 16:39:39 +00:00
|
|
|
gdb_test "print C::cc" "\\$\[0-9\].* = 2"
|
2003-05-20 03:56:29 +00:00
|
|
|
gdb_test "print cd" "\\$\[0-9\].* = 3"
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 16:54:43 +00:00
|
|
|
gdb_test "print C::D::cd" "No type \"D\" within class or namespace \"C::C\"."
|
2003-05-20 03:56:29 +00:00
|
|
|
gdb_test "print 'E::cde'" "\\$\[0-9\].* = 5"
|
2003-09-25 16:39:39 +00:00
|
|
|
gdb_test "print E::cde" "\\$\[0-9\].* = 5"
|
2003-05-20 03:56:29 +00:00
|
|
|
gdb_test "print shadow" "\\$\[0-9\].* = 13"
|
2003-09-25 16:39:39 +00:00
|
|
|
gdb_test "print E::ce" "No symbol \"ce\" in namespace \"C::D::E\"."
|
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
|
|
|
gdb_test "ptype C" "type = namespace C::C"
|
|
|
|
gdb_test "ptype E" "type = namespace C::D::E"
|
2003-05-20 03:56:29 +00:00
|
|
|
|
2004-08-01 01:03:47 +00:00
|
|
|
gdb_test "ptype CClass" "type = (class C::CClass \{\r\n public:|struct C::CClass \{)\r\n int x;\r\n\}"
|
|
|
|
gdb_test "ptype CClass::NestedClass" "type = (class C::CClass::NestedClass \{\r\n public:|struct C::CClass::NestedClass \{)\r\n int y;\r\n\}"
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 16:54:43 +00:00
|
|
|
gdb_test "ptype NestedClass" "No symbol \"NestedClass\" in current context."
|
|
|
|
gdb_test "ptype ::C::CClass" "type = class C::CClass \{\r\n public:\r\n int x;\r\n\}"
|
|
|
|
gdb_test "ptype ::C::CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n public:\r\n int y;\r\n\}"
|
|
|
|
gdb_test "ptype ::C::NestedClass" "No symbol \"NestedClass\" in namespace \"C\"."
|
|
|
|
gdb_test "ptype C::CClass" "No symbol \"CClass\" in namespace \"C::C\"."
|
|
|
|
gdb_test "ptype C::CClass::NestedClass" "No type \"CClass\" within class or namespace \"C::C\"."
|
|
|
|
gdb_test "ptype C::NestedClass" "No symbol \"NestedClass\" in namespace \"C::C\"."
|
|
|
|
|
|
|
|
# Tests involving multiple files
|
|
|
|
|
|
|
|
gdb_test "print cOtherFile" "\\$\[0-9\].* = 316"
|
2010-06-28 20:35:52 +00:00
|
|
|
gdb_test "ptype OtherFileClass" "type = (class C::OtherFileClass \{\r\n public:|struct C::OtherFileClass \{)\r\n int z;\r\n.*\}"
|
|
|
|
gdb_test "ptype ::C::OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n.*\}"
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 16:54:43 +00:00
|
|
|
gdb_test "ptype C::OtherFileClass" "No symbol \"OtherFileClass\" in namespace \"C::C\"."
|
|
|
|
|
2003-05-20 03:56:29 +00:00
|
|
|
# Some anonymous namespace tests.
|
|
|
|
|
|
|
|
gdb_test "print cX" "\\$\[0-9\].* = 6"
|
|
|
|
gdb_test "print 'F::cXf'" "\\$\[0-9\].* = 7"
|
2003-09-25 16:39:39 +00:00
|
|
|
gdb_test "print F::cXf" "\\$\[0-9\].* = 7"
|
|
|
|
gdb_test "print F::cXfX" "\\$\[0-9\].* = 8"
|
2003-05-20 03:56:29 +00:00
|
|
|
gdb_test "print X" "\\$\[0-9\].* = 9"
|
|
|
|
gdb_test "print 'G::Xg'" "\\$\[0-9\].* = 10"
|
2003-09-25 16:39:39 +00:00
|
|
|
gdb_test "print G::Xg" "\\$\[0-9\].* = 10"
|
|
|
|
gdb_test "print G::XgX" "\\$\[0-9\].* = 11"
|
2003-05-20 03:56:29 +00:00
|
|
|
gdb_test "print cXOtherFile" "No symbol \"cXOtherFile\" in current context."
|
|
|
|
gdb_test "print XOtherFile" "No symbol \"XOtherFile\" in current context."
|
2010-01-19 18:11:19 +00:00
|
|
|
|
|
|
|
# Enum tests.
|
|
|
|
gdb_test "print AAA::ALPHA" "\\$\[0-9\].* = AAA::ALPHA"
|
2010-02-19 20:22:03 +00:00
|
|
|
|
|
|
|
# Regression tests for PR 9496.
|
|
|
|
gdb_test "whatis ::C::CClass::NestedClass" "type = C::CClass::NestedClass"
|
|
|
|
gdb_test "whatis ::C::CClass::NestedClass *" "type = C::CClass::NestedClass \\*"
|