diff options
author | David Carlton <carlton@bactrian.org> | 2003-05-20 03:56:29 +0000 |
---|---|---|
committer | David Carlton <carlton@bactrian.org> | 2003-05-20 03:56:29 +0000 |
commit | 1fcb515536dbda348515162ccdb82cb102928798 (patch) | |
tree | 025f43d1ac23661032fceed14c7ed49de57c2f09 /gdb/block.c | |
parent | 916f5d137a4e411facadf4ade434a6eba27b6ea5 (diff) | |
download | gdb-1fcb515536dbda348515162ccdb82cb102928798.zip gdb-1fcb515536dbda348515162ccdb82cb102928798.tar.gz gdb-1fcb515536dbda348515162ccdb82cb102928798.tar.bz2 |
2003-05-19 David Carlton <carlton@bactrian.org>
Partial fix for PR c++/827.
* cp-support.h: Include symtab.h.
Declare cp_lookup_symbol_nonlocal, cp_lookup_symbol_namespace.
* cp-namespace.c: Update contributors.
(cp_lookup_symbol_nonlocal): New.
(lookup_namespace_scope, cp_lookup_symbol_namespace)
(lookup_symbol_file): Ditto.
* c-lang.c (cplus_language_defn): Use cp_lookup_symbol_nonlocal.
* block.h: Declare block_scope, block_using, block_global_block.
* block.c (block_scope): New.
(block_using, block_global_block): Ditto.
* Makefile.in (cp_support_h): Depend on symtab_h.
* config/djgpp/fnchange.lst: Add testsuite/gdb.c++/namespace1.cc.
2003-05-19 David Carlton <carlton@bactrian.org>
* gdb.c++/namespace.exp: Add namespace scope and anonymous
namespace tests.
Bump copyright date.
* gdb.c++/namespace.cc: Add anonymous namespace and namespace C.
(main): Call C::D::marker2.
* gdb.c++/namespace1.cc: New file.
Diffstat (limited to 'gdb/block.c')
-rw-r--r-- | gdb/block.c | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/gdb/block.c b/gdb/block.c index 1360a15..3396c8a 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -155,8 +155,25 @@ block_for_pc (register CORE_ADDR pc) return block_for_pc_sect (pc, find_pc_mapped_section (pc)); } -/* Now come some functions designed to deal with C++ namespace - issues. */ +/* Now come some functions designed to deal with C++ namespace issues. + The accessors are safe to use even in the non-C++ case. */ + +/* This returns the namespace that BLOCK is enclosed in, or "" if it + isn't enclosed in a namespace at all. This travels the chain of + superblocks looking for a scope, if necessary. */ + +const char * +block_scope (const struct block *block) +{ + for (; block != NULL; block = BLOCK_SUPERBLOCK (block)) + { + if (BLOCK_NAMESPACE (block) != NULL + && BLOCK_NAMESPACE (block)->scope != NULL) + return BLOCK_NAMESPACE (block)->scope; + } + + return ""; +} /* Set BLOCK's scope member to SCOPE; if needed, allocate memory via OBSTACK. (It won't make a copy of SCOPE, however, so that already @@ -171,6 +188,27 @@ block_set_scope (struct block *block, const char *scope, BLOCK_NAMESPACE (block)->scope = scope; } +/* This returns the first using directives associated to BLOCK, if + any. */ + +/* FIXME: carlton/2003-04-23: This uses the fact that we currently + only have using directives in static blocks, because we only + generate using directives from anonymous namespaces. Eventually, + when we support using directives everywhere, we'll want to replace + this by some iterator functions. */ + +struct using_direct * +block_using (const struct block *block) +{ + const struct block *static_block = block_static_block (block); + + if (static_block == NULL + || BLOCK_NAMESPACE (static_block) == NULL) + return NULL; + else + return BLOCK_NAMESPACE (static_block)->using; +} + /* Set BLOCK's using member to USING; if needed, allocate memory via OBSTACK. (It won't make a copy of USING, however, so that already has to be allocated correctly.) */ @@ -214,3 +252,18 @@ block_static_block (const struct block *block) return block; } + +/* Return the static block associated to BLOCK. Return NULL if block + is NULL. */ + +const struct block * +block_global_block (const struct block *block) +{ + if (block == NULL) + return NULL; + + while (BLOCK_SUPERBLOCK (block) != NULL) + block = BLOCK_SUPERBLOCK (block); + + return block; +} |