From: David Carlton Date: Tue, 22 Oct 2002 23:22:56 +0000 (+0000) Subject: 2002-10-22 David Carlton X-Git-Tag: newlib-1_11_0~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7a60da36149940f6b260b184c2913866dd1c0ff2;p=thirdparty%2Fbinutils-gdb.git 2002-10-22 David Carlton * dwarf2read.c (scan_partial_symbols): Clarify some comments. * symtab.c (lookup_symbol_aux): Always call lookup_symbol_aux_using to search global symtabs/psymtabs. (lookup_symbol_aux_local): Add static_block argument. * buildsym.c (add_symbol_to_list): Do a quick scan for "(anonymous namespace)" before calling scan_for_anonymous_namespaces. (scan_for_anonymous_namespaces): Delete FIXME comment. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2dc13c24d73..95c6998356d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2002-10-22 David Carlton + + * dwarf2read.c (scan_partial_symbols): Clarify some comments. + * symtab.c (lookup_symbol_aux): Always call + lookup_symbol_aux_using to search global symtabs/psymtabs. + (lookup_symbol_aux_local): Add static_block argument. + * buildsym.c (add_symbol_to_list): Do a quick scan for "(anonymous + namespace)" before calling scan_for_anonymous_namespaces. + (scan_for_anonymous_namespaces): Delete FIXME comment. + 2002-10-21 David Carlton * buildsym.c (add_symbol_to_list): Expand comment. diff --git a/gdb/buildsym.c b/gdb/buildsym.c index a912108f91c..789c6c65887 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -162,7 +162,9 @@ add_symbol_to_list (struct symbol *symbol, struct pending **listhead) if (SYMBOL_LANGUAGE (symbol) == language_cplus && !processing_has_namespace_info - && SYMBOL_CPLUS_DEMANGLED_NAME (symbol) != NULL) + && SYMBOL_CPLUS_DEMANGLED_NAME (symbol) != NULL + && strstr (SYMBOL_CPLUS_DEMANGLED_NAME (symbol), + "(anonymous namespace)") != NULL) scan_for_anonymous_namespaces (symbol); } @@ -179,10 +181,6 @@ scan_for_anonymous_namespaces (struct symbol *symbol) const char *name = SYMBOL_CPLUS_DEMANGLED_NAME (symbol); const char *beginning, *end; - /* FIXME: carlton/2002-10-14: Should we do some sort of fast search - first to see if the substring "(anonymous namespace)" occurs in - name at all? */ - for (beginning = name, end = cp_find_first_component (name); *end == ':'; /* The "+ 2" is for the "::"-. */ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index c5ddc535465..1105a68ae18 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1342,8 +1342,14 @@ 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. */ + /* We only want to read in symbols corresponding to variables or + other similar objects that are global or static. Normally, these + are all children of the DW_TAG_compile_unit die, so are all at + level 1. But C++ namespaces give ries to DW_TAG_namespace dies + whose children are global objects. So we keep track of what + level we currently think of as referring to file scope; this + should always equal 1 plus the number of namespaces that we are + currently nested within. */ int file_scope_level = 1; @@ -1389,8 +1395,10 @@ scan_partial_symbols (char *info_ptr, struct objfile *objfile, } break; case DW_TAG_enumerator: - /* File scope enumerators are added to the partial symbol - table. */ + /* File scope enumerators are added to the partial + symbol table. They're children of the enumeration + type die, so they occur at a level one higher than we + normally look for. */ if (nesting_level == file_scope_level + 1) add_partial_symbol (&pdi, objfile, cu_header); break; diff --git a/gdb/symtab.c b/gdb/symtab.c index b397440eecc..640cf6f9999 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -91,11 +91,13 @@ static struct symbol *lookup_symbol_aux (const char *name, int *is_a_field_of_this, struct symtab **symtab); -static struct symbol *lookup_symbol_aux_local (const char *name, - const char *mangled_name, - const struct block *block, - const namespace_enum namespace, - struct symtab **symtab); +static +struct symbol *lookup_symbol_aux_local (const char *name, + const char *mangled_name, + const struct block *block, + const namespace_enum namespace, + struct symtab **symtab, + const struct block **static_block); static struct symbol *lookup_symbol_aux_nonlocal (int block_index, @@ -779,11 +781,13 @@ lookup_symbol_aux (const char *name, const char *mangled_name, int *is_a_field_of_this, struct symtab **symtab) { struct symbol *sym; + const struct block *static_block; - /* Search specified block and its superiors. */ + /* Search specified block and its superiors. Don't search + STATIC_BLOCK or GLOBAL_BLOCK. */ sym = lookup_symbol_aux_local (name, mangled_name, block, namespace, - symtab); + symtab, &static_block); if (sym != NULL) return sym; @@ -803,31 +807,34 @@ lookup_symbol_aux (const char *name, const char *mangled_name, } } + /* If there's a static block to search, search it next. */ + + if (static_block != NULL) + { + sym = lookup_block_symbol (static_block, name, mangled_name, namespace); + if (sym != NULL) + return sym; + } + /* Now search all global blocks. Do the symtab's first, then check the psymtab's. If a psymtab indicates the existence of the desired name as a global, then do psymtab-to-symtab - conversion on the fly and return the found symbol. */ - - sym = lookup_symbol_aux_nonlocal (GLOBAL_BLOCK, name, mangled_name, - namespace, symtab); - if (sym != NULL) - return sym; + conversion on the fly and return the found symbol. - /* If we're in the C++ case, check to see if the symbol is defined - in a namespace accessible via a "using" declaration. */ + We do this from within lookup_symbol_aux_using: that will apply + appropriate using directives in the C++ case. But it works fine + in the non-C++ case, too. */ - /* FIXME: carlton/2002-10-10: is "is_a_field_of_this" always - non-NULL if we're in the C++ case? Maybe we should always do - this, and delete the two previous searches: this will always - search the global namespace, after all. */ + /* NOTE: carlton/2002-10-22: Is it worthwhile to try to figure out + whether or not we're in the C++ case? Doing + lookup_symbol_aux_using won't slow things down much at all in the + general case, though: other parts of this function are much, much + more expensive. */ - if (is_a_field_of_this) - { - sym = lookup_symbol_aux_using (name, mangled_name, block, namespace, - symtab); - if (sym != NULL) - return sym; - } + sym = lookup_symbol_aux_using (name, mangled_name, block, namespace, + symtab); + if (sym != NULL) + return sym; #ifndef HPUXHPPA @@ -886,22 +893,32 @@ lookup_symbol_aux (const char *name, const char *mangled_name, return NULL; } -/* Check to see if the symbol is defined in BLOCK or its - superiors. */ +/* Check to see if the symbol is defined in BLOCK or its superiors. + Don't search STATIC_BLOCK or GLOBAL_BLOCK. If we don't find a + match, store the address of STATIC_BLOCK in static_block. */ static struct symbol * lookup_symbol_aux_local (const char *name, const char *mangled_name, const struct block *block, const namespace_enum namespace, - struct symtab **symtab) + struct symtab **symtab, + const struct block **static_block) { struct symbol *sym; struct objfile *objfile = NULL; struct blockvector *bv; struct block *b; struct symtab *s = NULL; - - while (block != 0) + + /* Either no block is specified or it's a global block. */ + + if (block == NULL || BLOCK_SUPERBLOCK (block) == NULL) + { + *static_block = NULL; + return NULL; + } + + while (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) != NULL) { sym = lookup_block_symbol (block, name, mangled_name, namespace); if (sym) @@ -928,6 +945,9 @@ lookup_symbol_aux_local (const char *name, const char *mangled_name, block = BLOCK_SUPERBLOCK (block); } + /* We've reached the static block. */ + + *static_block = block; return NULL; }