This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Re: [rfc] patch to search applicable namespaces at each block level
- From: Sami Wagiaalla <swagiaal at redhat dot com>
- To: Project Archer <archer at sourceware dot org>
- Date: Mon, 20 Oct 2008 15:59:17 -0400
- Subject: Re: [rfc] patch to search applicable namespaces at each block level
- References: <48EBCB0A.4000500@redhat.com>
I have reverted the previous patch on this topic and committed a better
one to my branch.
The previous patch caused one test to fail. This one removes the global
search performed by cp_lookup_symbol_namespace, and fixes a some other
issues with the old one.
The problem with this patch is that it adds a call to
cp_lookup_symbol_namespace to symtab.c, and I got the feeling that
symtab.c tries to remain language neutral. If that is cool then so be
it. If not maybe I put the call in an 'if (lang == language_cplus)'
statement. As it stands the patch introduces no new failures and fixes
the stated problem.
Sami
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 991aa65..f388500 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,15 @@
+2008-10-20 Sami Wagiaalla <swagiaal@redhat.com>
+
+ * symtab.c (lookup_symbol_aux_local): Search continues through static
+ and stops at global block.
+ Now does a namespace at each block level via lookup_namespace_scope.
+ * cp-support.h: Added extern lookup_namespace_scope prototype.
+ * cp-namespace.c (lookup_namespace_scope): Removed static qualifier.
+ (cp_lookup_symbol_nonlocal): Now calls lookup_symbol_file if call to
+ lookup_namespace_scope fails.
+ (cp_lookup_symbol_namespace): Reuturn NULL if no namespace is
+ specified.
+
2008-09-09 Sami Wagiaalla <swagiaal@redhat.com>
* dwarf2read.c (process_die): Added call to
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 5830af6..d3ffcb7 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -38,13 +38,6 @@ static struct using_direct *using_list;
static struct using_direct *cp_copy_usings (struct using_direct *using,
struct obstack *obstack);
-static struct symbol *lookup_namespace_scope (const char *name,
- const char *linkage_name,
- const struct block *block,
- const domain_enum domain,
- const char *scope,
- int scope_len);
-
static struct symbol *lookup_symbol_file (const char *name,
const char *linkage_name,
const struct block *block,
@@ -294,8 +287,14 @@ cp_lookup_symbol_nonlocal (const char *name,
const struct block *block,
const domain_enum domain)
{
- return lookup_namespace_scope (name, linkage_name, block, domain,
- block_scope (block), 0);
+
+ struct symbol* sym = lookup_namespace_scope(name, linkage_name, block,
+ domain, block_scope(block), 0);
+
+ if (sym != NULL)
+ return sym;
+
+ return lookup_symbol_file(name, linkage_name, block, domain, 0);
}
/* Lookup NAME at namespace scope (or, in C terms, in static and
@@ -313,7 +312,7 @@ cp_lookup_symbol_nonlocal (const char *name,
"A::x", and if that call fails, then the first call looks for
"x". */
-static struct symbol *
+struct symbol *
lookup_namespace_scope (const char *name,
const char *linkage_name,
const struct block *block,
@@ -393,8 +392,7 @@ cp_lookup_symbol_namespace (const char *namespace,
if (namespace[0] == '\0')
{
- return lookup_symbol_file (name, linkage_name, block,
- domain, 0);
+ return NULL;
}
else
{
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index ce34022..b288ea3 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -103,6 +103,13 @@ extern struct symbol *cp_lookup_symbol_nonlocal (const char *name,
const struct block *block,
const domain_enum domain);
+extern struct symbol *lookup_namespace_scope (const char *name,
+ const char *linkage_name,
+ const struct block *block,
+ const domain_enum domain,
+ const char *scope,
+ int scope_len);
+
extern struct symbol *cp_lookup_symbol_namespace (const char *namespace,
const char *name,
const char *linkage_name,
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 1a0dcba..3cf0b04 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -42,6 +42,7 @@
#include "ada-lang.h"
#include "p-lang.h"
#include "addrmap.h"
+#include "cp-support.h"
#include "hashtab.h"
@@ -1359,22 +1360,29 @@ lookup_symbol_aux_local (const char *name, const char *linkage_name,
const domain_enum domain)
{
struct symbol *sym;
- const struct block *static_block = block_static_block (block);
+ const struct block *global_block = block_global_block (block);
/* Check if either no block is specified or it's a global block. */
- if (static_block == NULL)
+ if (global_block == NULL)
return NULL;
- while (block != static_block)
+ while (block != global_block)
{
sym = lookup_symbol_aux_block (name, linkage_name, block, domain);
if (sym != NULL)
return sym;
+
+ sym = lookup_namespace_scope (name, linkage_name, block, domain,
+ block_scope (block), 0);
+
+ if (sym != NULL)
+ return sym;
+
block = BLOCK_SUPERBLOCK (block);
}
- /* We've reached the static block without finding a result. */
+ /* We've reached the global block without finding a result. */
return NULL;
}