This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[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: Tue, 07 Oct 2008 16:48:10 -0400
- Subject: [rfc] patch to search applicable namespaces at each block level
namesapce A{
int x = 11;
}
int main () {
using namespace A;
x; // <-- (gdb) p x here
return 0;
}
With my previous patch the above scenario worked but the following didnt:
using namespace A;
int main () {
x; // <-- (gdb) p x here
return 0;
}
The reason is that gdb didnt perform a search of applicable namespaces
at each level. This patch fixes that, but I am not sure if it will have
negative effects on other languages or if there a better way of
achieving he same effect.
It has been pushed to my branch, and depends on other patches there:
$git branch archer-swagiaal-using-directive
origin/archer-swagiaal-using-directive
--------------------------------------------
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 991aa65..8dc5554 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2008-10-07 Sami Wagiaalla <swagiaal@redhat.com>
+
+ * symtab.c (lookup_symbol_aux_local): Added 'lanuage' argument.
+ Added a call to la_lookup_symbol_nonlocal.
+
2008-09-09 Sami Wagiaalla <swagiaal@redhat.com>
* dwarf2read.c (process_die): Added call to
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 1a0dcba..e6e7e8f 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -92,6 +92,7 @@ static
struct symbol *lookup_symbol_aux_local (const char *name,
const char *linkage_name,
const struct block *block,
+ enum language language,
const domain_enum domain);
static
@@ -1281,7 +1282,7 @@ lookup_symbol_aux (const char *name, const char
*linkage_name,
/* Search specified block and its superiors. Don't search
STATIC_BLOCK or GLOBAL_BLOCK. */
- sym = lookup_symbol_aux_local (name, linkage_name, block, domain);
+ sym = lookup_symbol_aux_local (name, linkage_name, block, language,
domain);
if (sym != NULL)
return sym;
@@ -1356,21 +1357,30 @@ lookup_symbol_aux (const char *name, const char
*linkage_name,
static struct symbol *
lookup_symbol_aux_local (const char *name, const char *linkage_name,
const struct block *block,
+ enum language language,
const domain_enum domain)
{
struct symbol *sym;
const struct block *static_block = block_static_block (block);
-
+ const struct language_defn *langdef;
+
+ langdef = language_def (language);
+
/* Check if either no block is specified or it's a global block. */
if (static_block == NULL)
return NULL;
- while (block != static_block)
+ while (block != NULL)
{
sym = lookup_symbol_aux_block (name, linkage_name, block, domain);
+
+ if(sym == NULL)
+ sym = langdef->la_lookup_symbol_nonlocal (name, linkage_name,
block, domain);
+
if (sym != NULL)
return sym;
+
block = BLOCK_SUPERBLOCK (block);
}