diff options
author | David Carlton <carlton@bactrian.org> | 2002-10-18 00:00:19 +0000 |
---|---|---|
committer | David Carlton <carlton@bactrian.org> | 2002-10-18 00:00:19 +0000 |
commit | 956685462c0fa2fd21c26afd2a0b0db2bbe60f71 (patch) | |
tree | 0c38f522d5424144b3fd3dad6fe75a15ea7f8c91 | |
parent | bcc187da038a3b880c90508d2129567899575911 (diff) | |
download | gdb-956685462c0fa2fd21c26afd2a0b0db2bbe60f71.tar.gz |
2002-10-16 David Carlton <carlton@math.stanford.edu>
* dwarf2read.c (dwarf_tag_name): Add DWARF 3 names.
(dwarf_attr_name): Ditto.
(dwarf_type_encoding_name): Ditto.
(scan_partial_symbols): Descend into DW_TAG_namespace entries.
(process_die): Handle DW_TAG_namespace,
DW_TAG_imported_declaration, DW_TAG_imported_module.
(read_namespace): New function.
2002-10-17 David Carlton <carlton@math.stanford.edu>
* gdb.c++/namespace.cc: Add namespace renaming, using directives,
and using declarations.
* gdb.c++/namespace.exp: Add some xfails, including namespace
renaming, using directives, and using declarations.
-rw-r--r-- | gdb/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/dwarf2read.c | 119 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.c++/namespace.cc | 66 | ||||
-rw-r--r-- | gdb/testsuite/gdb.c++/namespace.exp | 52 |
5 files changed, 238 insertions, 16 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 505e69d1b5f..e0c59bf81a6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2002-10-16 David Carlton <carlton@math.stanford.edu> + + * dwarf2read.c (dwarf_tag_name): Add DWARF 3 names. + (dwarf_attr_name): Ditto. + (dwarf_type_encoding_name): Ditto. + (scan_partial_symbols): Descend into DW_TAG_namespace entries. + (process_die): Handle DW_TAG_namespace, + DW_TAG_imported_declaration, DW_TAG_imported_module. + (read_namespace): New function. + 2002-10-15 David Carlton <carlton@math.stanford.edu> * symtab.c (lookup_symbol_aux_using_loop): prefix_len should be <= diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index d3ff19053f8..9bb2526c291 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -838,6 +838,9 @@ static void read_structure_scope (struct die_info *, struct objfile *, static void read_common_block (struct die_info *, struct objfile *, const struct comp_unit_head *); +static void read_namespace (struct die_info *die, struct objfile *objfile, + const struct comp_unit_head *cu_header); + static void read_enumeration (struct die_info *, struct objfile *, const struct comp_unit_head *); @@ -1328,6 +1331,11 @@ scan_partial_symbols (char *info_ptr, struct objfile *objfile, int nesting_level = 1; + /* What level do we consider to be file scope? This is normally 1, + but can get pushed up by DW_TAG_namespace entries. */ + + int file_scope_level = 1; + *lowpc = ((CORE_ADDR) -1); *highpc = ((CORE_ADDR) 0); @@ -1350,7 +1358,7 @@ scan_partial_symbols (char *info_ptr, struct objfile *objfile, { *highpc = pdi.highpc; } - if ((pdi.is_external || nesting_level == 1) + if ((pdi.is_external || nesting_level == file_scope_level) && !pdi.is_declaration) { add_partial_symbol (&pdi, objfile, cu_header); @@ -1363,7 +1371,7 @@ scan_partial_symbols (char *info_ptr, struct objfile *objfile, case DW_TAG_structure_type: case DW_TAG_union_type: case DW_TAG_enumeration_type: - if ((pdi.is_external || nesting_level == 1) + if ((pdi.is_external || nesting_level == file_scope_level) && !pdi.is_declaration) { add_partial_symbol (&pdi, objfile, cu_header); @@ -1372,37 +1380,51 @@ scan_partial_symbols (char *info_ptr, struct objfile *objfile, case DW_TAG_enumerator: /* File scope enumerators are added to the partial symbol table. */ - if (nesting_level == 2) + if (nesting_level == file_scope_level + 1) add_partial_symbol (&pdi, objfile, cu_header); break; case DW_TAG_base_type: /* File scope base type definitions are added to the partial symbol table. */ - if (nesting_level == 1) + if (nesting_level == file_scope_level) add_partial_symbol (&pdi, objfile, cu_header); break; + case DW_TAG_namespace: + /* FIXME: carlton/2002-10-16: we're not yet doing + anything useful with this, but for now make sure that + these tags at least don't cause us to miss any + important symbols. */ + if (pdi.has_children) + file_scope_level++; default: break; } } - /* If the die has a sibling, skip to the sibling. - Do not skip enumeration types, we want to record their - enumerators. */ - if (pdi.sibling && pdi.tag != DW_TAG_enumeration_type) + /* If the die has a sibling, skip to the sibling. Do not skip + enumeration types, we want to record their enumerators. Do + not skip namespaces, we want to record symbols inside + them. */ + if (pdi.sibling + && pdi.tag != DW_TAG_enumeration_type + && pdi.tag != DW_TAG_namespace) { info_ptr = pdi.sibling; } else if (pdi.has_children) { - /* Die has children, but the optional DW_AT_sibling attribute - is missing. */ + /* Die has children, but either the optional DW_AT_sibling + attribute is missing or we want to look at them. */ nesting_level++; } if (pdi.tag == 0) { nesting_level--; + /* If this is the end of a DW_TAG_namespace entry, then + decrease the file_scope_level, too. */ + if (nesting_level < file_scope_level) + file_scope_level--; } } @@ -1701,6 +1723,19 @@ process_die (struct die_info *die, struct objfile *objfile, break; case DW_TAG_common_inclusion: break; + case DW_TAG_namespace: + read_namespace (die, objfile, cu_header); + break; + case DW_TAG_imported_declaration: + case DW_TAG_imported_module: + /* FIXME: carlton/2002-10-16: Eventually, we should use the + information contained in these. DW_TAG_imported_declaration + dies shouldn't have children; DW_TAG_imported_module dies + shouldn't in the C++ case, but conceivably could in the + Fortran case, so we'll have to replace this gdb_assert if + Fortran compilers start generating that info. */ + gdb_assert (!die->has_children); + break; default: new_symbol (die, NULL, objfile, cu_header); break; @@ -2916,6 +2951,27 @@ read_common_block (struct die_info *die, struct objfile *objfile, } } +/* Read a C++ namespace. */ + +/* FIXME: carlton/2002-10-16: For now, we don't actually do anything + useful with the namespace data: we just process its children. */ + +static void +read_namespace (struct die_info *die, struct objfile *objfile, + const struct comp_unit_head *cu_header) +{ + if (die->has_children) + { + struct die_info *child_die = die->next; + + while (child_die && child_die->tag) + { + process_die (child_die, objfile, cu_header); + child_die = sibling_die (child_die); + } + } +} + /* Extract all information from a DW_TAG_pointer_type DIE and add to the user defined type vector. */ @@ -5459,6 +5515,22 @@ dwarf_tag_name (register unsigned tag) return "DW_TAG_variable"; case DW_TAG_volatile_type: return "DW_TAG_volatile_type"; + case DW_TAG_dwarf_procedure: + return "DW_TAG_dwarf_procedure"; + case DW_TAG_restrict_type: + return "DW_TAG_restrict_type"; + case DW_TAG_interface_type: + return "DW_TAG_interface_type"; + case DW_TAG_namespace: + return "DW_TAG_namespace"; + case DW_TAG_imported_module: + return "DW_TAG_imported_module"; + case DW_TAG_unspecified_type: + return "DW_TAG_unspecified_type"; + case DW_TAG_partial_unit: + return "DW_TAG_partial_unit"; + case DW_TAG_imported_unit: + return "DW_TAG_imported_unit"; case DW_TAG_MIPS_loop: return "DW_TAG_MIPS_loop"; case DW_TAG_format_label: @@ -5603,7 +5675,30 @@ dwarf_attr_name (register unsigned attr) return "DW_AT_virtuality"; case DW_AT_vtable_elem_location: return "DW_AT_vtable_elem_location"; - + case DW_AT_allocated: + return "DW_AT_allocated"; + case DW_AT_associated: + return "DW_AT_associated"; + case DW_AT_data_location: + return "DW_AT_data_location"; + case DW_AT_stride: + return "DW_AT_stride"; + case DW_AT_entry_pc: + return "DW_AT_entry_pc"; + case DW_AT_use_UTF8: + return "DW_AT_use_UTF8"; + case DW_AT_extension: + return "DW_AT_extension"; + case DW_AT_ranges: + return "DW_AT_ranges"; + case DW_AT_trampoline: + return "DW_AT_trampoline"; + case DW_AT_call_column: + return "DW_AT_call_column"; + case DW_AT_call_file: + return "DW_AT_call_file"; + case DW_AT_call_line: + return "DW_AT_call_line"; #ifdef MIPS case DW_AT_MIPS_fde: return "DW_AT_MIPS_fde"; @@ -6040,6 +6135,8 @@ dwarf_type_encoding_name (register unsigned enc) return "DW_ATE_unsigned"; case DW_ATE_unsigned_char: return "DW_ATE_unsigned_char"; + case DW_ATE_imaginary_float: + return "DW_ATE_imaginary_float"; default: return "DW_ATE_<unknown>"; } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 5ca6345e15f..073f73c093c 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2002-10-17 David Carlton <carlton@math.stanford.edu> + + * gdb.c++/namespace.cc: Add namespace renaming, using directives, + and using declarations. + * gdb.c++/namespace.exp: Add some xfails, including namespace + renaming, using directives, and using declarations. + 2002-10-15 David Carlton <carlton@math.stanford.edu> * gdb.c++/namespace.exp: Add anonymous namespace tests. diff --git a/gdb/testsuite/gdb.c++/namespace.cc b/gdb/testsuite/gdb.c++/namespace.cc index c5ec895f5ef..6298b91762d 100644 --- a/gdb/testsuite/gdb.c++/namespace.cc +++ b/gdb/testsuite/gdb.c++/namespace.cc @@ -83,9 +83,57 @@ namespace } } +namespace H +{ + int h = 14; +} + +namespace I = H; + +namespace J +{ + int j = 15; +} + +using namespace J; + +namespace K +{ + int k = 16; +} + +namespace L +{ + using namespace K; +} + +namespace O +{ + int o = 18; +} + +namespace P +{ + using namespace O; +} + +namespace Q +{ + using namespace P; +} + +namespace R +{ + int r1 = 19; + int r2 = 20; +} + +using R::r1; + namespace C { int c = 1; + int shadow = 12; namespace { @@ -115,12 +163,20 @@ namespace C namespace D { int cd = 3; + int shadow = 13; namespace E { int cde = 5; } + namespace M + { + int cdm = 17; + } + + using namespace M; + void marker2 (void) { // NOTE: carlton/2002-10-11: I'm listing the expressions that I @@ -132,6 +188,7 @@ namespace C C::cc; cd; E::cde; + shadow; //E::ce; cX; F::cXf; @@ -139,6 +196,15 @@ namespace C X; G::Xg; G::XgX; + I::h; + j; + L::k; + //k; + cdm; + Q::o; + //o; + r1; + //r2; return; } diff --git a/gdb/testsuite/gdb.c++/namespace.exp b/gdb/testsuite/gdb.c++/namespace.exp index 30a68fe2adf..ebe845e16e3 100644 --- a/gdb/testsuite/gdb.c++/namespace.exp +++ b/gdb/testsuite/gdb.c++/namespace.exp @@ -186,8 +186,8 @@ gdb_expect { timeout { fail "(timeout) break BBB::Class::xyzq" } } -# Now, test to see if the appropriate namespaces are in scope when -# trying to print out stuff from within a function defined within a +# 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 { @@ -202,9 +202,20 @@ gdb_test "print cd" "\\$\[0-9\].* = 3" "print cd" gdb_test "print 'C::D::cd'" "\\$\[0-9\].* = 3" "print C::D::cd" gdb_test "print 'E::cde'" "\\$\[0-9\].* = 5" "print E::cde" -# FIXME: carlton/2002-10-11: It would be nice to test printing -# "E::ce", but unfortunately GDB will print it out even though it -# shouldn't. Oops. +# FIXME: carlton/2002-10-17: It's somewhat accidental that we +# currently get this one right. (Delete this comment once namespace +# scope issues have been handled correctly!) + +gdb_test "print shadow" "\\$\[0-9\].* = 13" "print shadow" + + +# NOTE: carlton/2002-10-17: This one won't get fixed until namespaces +# are first-class objects. + +setup_xfail "*-*-*" +gdb_test "print 'E::ce'" "No symbol \"E::ce\" in current context." "print E::ce" + +# Some anonymous namespace tests. gdb_test "print cX" "\\$\[0-9\].* = 6" "print cX" gdb_test "print 'F::cXf'" "\\$\[0-9\].* = 7" "print F::cXf" @@ -212,3 +223,34 @@ gdb_test "print 'F::cXfX'" "\\$\[0-9\].* = 8" "print F::cXfX" gdb_test "print X" "\\$\[0-9\].* = 9" "print X" gdb_test "print 'G::Xg'" "\\$\[0-9\].* = 10" "print G::Xg" gdb_test "print 'G::XgX'" "\\$\[0-9\].* = 11" "print G::XgX" + +# Test namespace renaming. + +setup_xfail "*-*-*" +gdb_test "print 'I::h'" "\\$\[0-9\].* = 14" "print I::h" + +# Test using directives. + +# NOTE: carlton/2002-10-17: Some of these are easy, but some of these +# have unfortunate interactions with namespace scope issues. As of +# this writing, some of these pass, but they pass for the wrong reasons. + +setup_xfail "*-*-*" +gdb_test "print j" "\\$\[0-9\].* = 15" "print j" +setup_xfail "*-*-*" +gdb_test "print 'L::k'" "\\$\[0-9\].* = 16" "print L::k" +setup_xfail "*-*-*" +gdb_test "print k" "No symbol \"k\" in current context." "print k" +setup_xfail "*-*-*" +gdb_test "print cdm" "\\$\[0-9\].* = 17" "print cdm" +setup_xfail "*-*-*" +gdb_test "print 'Q::o'" "\\$\[0-9\].* = 18" "print Q::o" +setup_xfail "*-*-*" +gdb_test "print o" "No symbol \"o\" in current context." "print o" + +# Test using declarations. I should probably test these more. + +setup_xfail "*-*-*" +gdb_test "print r1" "\\$\[0-9\].* = 19" "print r1" +setup_xfail "*-*-*" +gdb_test "print r2" "No symbol \"r2\" in current context." "print r2" |