summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Carlton <carlton@bactrian.org>2002-11-16 00:16:57 +0000
committerDavid Carlton <carlton@bactrian.org>2002-11-16 00:16:57 +0000
commita630cbb0771534d19a07e8099899d3a7c4c8d12a (patch)
tree2f4be5439060e3dc0421f85727f66581c4b7692e
parent111a4444749ee1570694eb9b1542cdf4112fba4e (diff)
downloadgdb-a630cbb0771534d19a07e8099899d3a7c4c8d12a.tar.gz
2002-11-15 David Carlton <carlton@math.stanford.edu>
* symtab.c (lookup_symbol_aux): Get at static block via block_static_block. (lookup_symbol_aux_local): Delete static_block argument, and use block_static_block. * block.h: Declare block_static_block. * block.c (block_static_block): New function. * linespec.c (decode_all_digits): Move up definition of need_canonical.
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/block.c15
-rw-r--r--gdb/block.h2
-rw-r--r--gdb/linespec.c4
-rw-r--r--gdb/symtab.c23
5 files changed, 38 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d71c0887857..e4540a172e1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,14 @@
2002-11-15 David Carlton <carlton@math.stanford.edu>
+ * symtab.c (lookup_symbol_aux): Get at static block via
+ block_static_block.
+ (lookup_symbol_aux_local): Delete static_block argument, and use
+ block_static_block.
+ * block.h: Declare block_static_block.
+ * block.c (block_static_block): New function.
+ * linespec.c (decode_all_digits): Move up definition of
+ need_canonical.
+
* Merge from mainline; tag is carlton_dictionary-20021115-merge.
2002-11-14 Andrew Cagney <ac131313@redhat.com>
diff --git a/gdb/block.c b/gdb/block.c
index 7becf2e9f94..2566a4ab8aa 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -140,3 +140,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;
+}
diff --git a/gdb/block.h b/gdb/block.h
index d0700c1fb61..1848b6b55be 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -149,3 +149,5 @@ extern const char *block_scope (const struct block *block);
extern void block_set_scope (struct block *block, const char *scope,
struct obstack *obstack);
+
+extern const struct block *block_static_block (const struct block *block);
diff --git a/gdb/linespec.c b/gdb/linespec.c
index df1d1b36d57..4b0af38ceb9 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1324,11 +1324,11 @@ decode_all_digits (char **argptr, struct symtab *default_symtab,
}
sign = none;
- init_sal (&val);
-
/* We might need a canonical line spec if no file was specified. */
int need_canonical = (file_symtab == NULL) ? 1 : 0;
+ init_sal (&val);
+
/* This is where we need to make sure that we have good defaults.
We must guarantee that this section of code is never executed
when we are called with just a function name, since
diff --git a/gdb/symtab.c b/gdb/symtab.c
index e267190a48c..c465506f254 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -92,8 +92,7 @@ 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);
+ struct symtab **symtab);
static
struct symbol *lookup_symbol_aux_block (const char *name,
@@ -840,7 +839,7 @@ lookup_symbol_aux (const char *name, const char *mangled_name,
STATIC_BLOCK or GLOBAL_BLOCK. */
sym = lookup_symbol_aux_local (name, mangled_name, block, namespace,
- symtab, &static_block);
+ symtab);
if (sym != NULL)
return sym;
@@ -921,6 +920,8 @@ lookup_symbol_aux (const char *name, const char *mangled_name,
seems best: it's cleanest, it's correct, and it might be useful
for handling namespace scope issues completely correctly. */
+ static_block = block_static_block (block);
+
if (static_block != NULL)
{
sym = lookup_symbol_aux_block (name, mangled_name, static_block,
@@ -976,20 +977,17 @@ 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)
+ struct symtab **symtab)
{
struct symbol *sym;
+ const struct block *static_block = block_static_block (block);
/* 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, mangled_name, block, namespace,
symtab);
@@ -998,9 +996,8 @@ lookup_symbol_aux_local (const char *name, const char *mangled_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;
}