2003-05-19 David Carlton <carlton@bactrian.org>
authorDavid Carlton <carlton@bactrian.org>
Tue, 20 May 2003 01:26:58 +0000 (01:26 +0000)
committerDavid Carlton <carlton@bactrian.org>
Tue, 20 May 2003 01:26:58 +0000 (01:26 +0000)
* block.h: Declare block_static_block.
* block.c (block_static_block): New.
* symtab.c (lookup_symbol_aux): Remove 'static_block' argument to
lookup_symbol_aux_local, calling block_static_block instead.
(lookup_symbol_aux_local): Delete 'static_block' argument.

gdb/ChangeLog
gdb/block.c
gdb/block.h
gdb/symtab.c

index b12cc7b58e47e5317c0ef5f26602667dc300f433..3dd4a52d2bac59874c52e6b0af14145c89f666a2 100644 (file)
@@ -1,3 +1,11 @@
+2003-05-19  David Carlton  <carlton@bactrian.org>
+
+       * block.h: Declare block_static_block.
+       * block.c (block_static_block): New.
+       * symtab.c (lookup_symbol_aux): Remove 'static_block' argument to
+       lookup_symbol_aux_local, calling block_static_block instead.
+       (lookup_symbol_aux_local): Delete 'static_block' argument.
+
 2003-05-19  David Carlton  <carlton@bactrian.org>
 
        * symtab.c (lookup_symbol_aux): Delete #if 0 hunk.
index 7bfd866384860cc6010dedeb8fd8c67c04c2559f..1360a1589d0f36fa079d7f688f5d7bdff71ebccf 100644 (file)
@@ -199,3 +199,18 @@ block_initialize_namespace (struct block *block, struct obstack *obstack)
       BLOCK_NAMESPACE (block)->using = NULL;
     }
 }
+
+/* Return the static block associated to BLOCK.  Return NULL if block
+   is NULL or if block is a global block.  */
+
+const struct block *
+block_static_block (const struct block *block)
+{
+  if (block == NULL || BLOCK_SUPERBLOCK (block) == NULL)
+    return NULL;
+
+  while (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) != NULL)
+    block = BLOCK_SUPERBLOCK (block);
+
+  return block;
+}
index 2fef52adc968f8748c1c1deee21a789337a25cb5..17c726dc17f954e7ef1e0897de9eae98d2d117a9 100644 (file)
@@ -207,4 +207,6 @@ extern void block_set_using (struct block *block,
                             struct using_direct *using,
                             struct obstack *obstack);
 
+extern const struct block *block_static_block (const struct block *block);
+
 #endif /* BLOCK_H */
index 9b01d45f7bb1a0d7a2bc47a11adb51046ded4246..62e37b8f46886bc7efa38b3ac776b2e51042425c 100644 (file)
@@ -93,8 +93,7 @@ struct symbol *lookup_symbol_aux_local (const char *name,
                                        const char *linkage_name,
                                        const struct block *block,
                                        const domain_enum domain,
-                                       struct symtab **symtab,
-                                       const struct block **static_block);
+                                       struct symtab **symtab);
 
 static
 struct symbol *lookup_symbol_aux_block (const char *name,
@@ -964,7 +963,7 @@ lookup_symbol_aux (const char *name, const char *linkage_name,
      STATIC_BLOCK or GLOBAL_BLOCK.  */
 
   sym = lookup_symbol_aux_local (name, linkage_name, block, domain,
-                                symtab, &static_block);
+                                symtab);
   if (sym != NULL)
     return sym;
 
@@ -1008,6 +1007,7 @@ lookup_symbol_aux (const char *name, const char *linkage_name,
      than that one, so I don't think we should worry about that for
      now.  */
 
+  static_block = block_static_block (block);
   if (static_block != NULL)
     {
       sym = lookup_symbol_aux_block (name, linkage_name, static_block,
@@ -1053,27 +1053,23 @@ lookup_symbol_aux (const char *name, const char *linkage_name,
 }
 
 /* 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.  */
+   Don't search STATIC_BLOCK or GLOBAL_BLOCK.  */
 
 static struct symbol *
 lookup_symbol_aux_local (const char *name, const char *linkage_name,
                         const struct block *block,
                         const domain_enum domain,
-                        struct symtab **symtab,
-                        const struct block **static_block)
+                        struct symtab **symtab)
 {
   struct symbol *sym;
-  
+  const struct block *static_block = block_static_block (block);
+
   /* Check if either no block is specified or it's a global block.  */
 
-  if (block == NULL || BLOCK_SUPERBLOCK (block) == NULL)
-    {
-      *static_block = NULL;
-      return NULL;
-    }
+  if (static_block == NULL)
+    return NULL;
 
-  while (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) != NULL)
+  while (block != static_block)
     {
       sym = lookup_symbol_aux_block (name, linkage_name, block, domain,
                                     symtab);
@@ -1082,9 +1078,8 @@ lookup_symbol_aux_local (const char *name, const char *linkage_name,
       block = BLOCK_SUPERBLOCK (block);
     }
 
-  /* We've reached the static block.  */
+  /* We've reached the static block without finding a result.  */
 
-  *static_block = block;
   return NULL;
 }