]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2002-10-22 David Carlton <carlton@math.stanford.edu>
authorDavid Carlton <carlton@bactrian.org>
Tue, 22 Oct 2002 23:22:56 +0000 (23:22 +0000)
committerDavid Carlton <carlton@bactrian.org>
Tue, 22 Oct 2002 23:22:56 +0000 (23:22 +0000)
* 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.

gdb/ChangeLog
gdb/buildsym.c
gdb/dwarf2read.c
gdb/symtab.c

index 2dc13c24d738260282b8907a3d4120e4032c17aa..95c6998356d648cb1bf032fbeac8e261f836c70f 100644 (file)
@@ -1,3 +1,13 @@
+2002-10-22  David Carlton  <carlton@math.stanford.edu>
+
+       * 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  <carlton@math.stanford.edu>
 
        * buildsym.c (add_symbol_to_list): Expand comment.
index a912108f91c1fd67cbc7be61e4490959840434fb..789c6c658871e12ee0997c344a7d3fffe5b7d67e 100644 (file)
@@ -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 "::"-.  */
index c5ddc535465e9f1b2cc17e2b2bed913b20e42f90..1105a68ae186d18196fb8eace67fe3eafd3324a0 100644 (file)
@@ -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;
index b397440eecc012e0aff7b3afba7db85bdb57aba7..640cf6f9999a5db87795065d892bfedd4e762f97 100644 (file)
@@ -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;
 }