This is the mail archive of the archer@sourceware.org mailing list for the Archer project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

using directive patch


the attach patch solves the following problem

namespace A{
  int x;
}

int main{
  using namespace A;
  x;
}

With the patch x is visible when stopped in main, and no where else.

The above is the only variation I test. There is more to come, but I wanted to get some feed back early on.


diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b00b374..e981dba 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,22 @@
+2008-09-03  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* dwarf2read.c (process_die): Added call to 
+	read_import_statement to the appropriate dies.
+	(read_import_statement): New function.
+	(read_func_scope): Resets the using directives from saved
+	context.
+	* cp-namespace.c: Changed cp_adding_using to extern.
+	Moved cp_adding_using prototype from here...
+	* cp-support.h: ...to here.
+	* buildsym.h: Add global variable using_directives.
+	Added using_directives variable to context struct.
+	Added extern prototype for 
+	* buildsym.c (finish_block): Set using directives for
+	the block, and reset the global variable.
+	(push_context): Save and reset using_directives.
+	* block.c (block_using): Return using directives for
+	the given block instead of its owning static block.
+
 2008-07-29  Tom Tromey  <tromey@redhat.com>
 
 	* cli/cli-decode.c (lookup_cmd_1): Use memcpy.
diff --git a/gdb/block.c b/gdb/block.c
index fd96a52..d48f546 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -218,13 +218,12 @@ block_set_scope (struct block *block, const char *scope,
 struct using_direct *
 block_using (const struct block *block)
 {
-  const struct block *static_block = block_static_block (block);
 
-  if (static_block == NULL
-      || BLOCK_NAMESPACE (static_block) == NULL)
+  if (block == NULL
+      || BLOCK_NAMESPACE (block) == NULL)
     return NULL;
   else
-    return BLOCK_NAMESPACE (static_block)->using;
+    return BLOCK_NAMESPACE (block)->using;
 }
 
 /* Set BLOCK's using member to USING; if needed, allocate memory via
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index f3850a2..d80120c 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -396,6 +396,12 @@ finish_block (struct symbol *symbol, struct pending **listhead,
       opblock = pblock;
     }
 
+  block_set_using (block,
+		   using_directives,
+		   &objfile->objfile_obstack);
+  
+  using_directives = NULL;
+
   record_pending_block (objfile, block, opblock);
 
   return block;
@@ -1214,10 +1220,12 @@ push_context (int desc, CORE_ADDR valu)
   new->params = param_symbols;
   new->old_blocks = pending_blocks;
   new->start_addr = valu;
+  new->using_directives = using_directives;
   new->name = NULL;
 
   local_symbols = NULL;
   param_symbols = NULL;
+  using_directives = NULL;
 
   return new;
 }
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 294bc41..0c4c851 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -125,6 +125,10 @@ EXTERN struct pending *local_symbols;
 
 EXTERN struct pending *param_symbols;
 
+/* using directives local to lexical context */
+
+EXTERN struct  using_direct *using_directives;
+
 /* Stack representing unclosed lexical contexts (that will become
    blocks, eventually).  */
 
@@ -138,6 +142,10 @@ struct context_stack
 
     struct pending *params;
 
+    /* Pending using directives at the time we entered */
+
+    struct  using_direct *using_directives;
+    
     /* Pointer into blocklist as of entry */
 
     struct pending_block *old_blocks;
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 9c7ea59..9c629b8 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -61,11 +61,6 @@ const char *processing_current_prefix;
 
 static struct using_direct *using_list;
 
-static struct using_direct *cp_add_using (const char *name,
-					  unsigned int inner_len,
-					  unsigned int outer_len,
-					  struct using_direct *next);
-
 static struct using_direct *cp_copy_usings (struct using_direct *using,
 					    struct obstack *obstack);
 
@@ -269,7 +264,7 @@ cp_is_anonymous (const char *namespace)
    using xmalloc.  It copies the strings, so NAME can be a temporary
    string.  */
 
-static struct using_direct *
+extern struct using_direct *
 cp_add_using (const char *name,
 	      unsigned int inner_len,
 	      unsigned int outer_len,
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index 8c0119e..6f4b8c0 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -82,6 +82,11 @@ extern void cp_add_using_directive (const char *name,
 				    unsigned int outer_length,
 				    unsigned int inner_length);
 
+extern struct using_direct *cp_add_using (const char *name,
+					  unsigned int inner_len,
+					  unsigned int outer_len,
+					  struct using_direct *next);
+
 extern void cp_initialize_namespace (void);
 
 extern void cp_finalize_namespace (struct block *static_block,
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 8f1062d..99d89b9 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -932,6 +932,8 @@ static void read_common_block (struct die_info *, struct dwarf2_cu *);
 
 static void read_namespace (struct die_info *die, struct dwarf2_cu *);
 
+static void read_import_statement (struct die_info *die, struct dwarf2_cu *);
+
 static const char *namespace_name (struct die_info *die,
 				   int *is_anonymous, struct dwarf2_cu *);
 
@@ -2772,6 +2774,7 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
 	 Fortran compilers start generating that info.  */
       processing_has_namespace_info = 1;
       gdb_assert (die->child == NULL);
+      read_import_statement(die, cu);
       break;
     default:
       new_symbol (die, NULL, cu);
@@ -2779,6 +2782,26 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
     }
 }
 
+
+/*
+ * Read the import statement specified by the given die and record it.
+ */ 
+static void read_import_statement(struct die_info *die, struct dwarf2_cu *cu){
+  static struct die_info* imported_die;
+  struct attribute *import_attr = dwarf2_attr (die, DW_AT_import, cu);
+  char* imported_name;
+  
+  imported_die = follow_die_ref (die, import_attr, cu);
+  imported_name = dwarf2_name (imported_die, cu);
+  
+  using_directives = cp_add_using (imported_name,
+		  strlen(imported_name),
+		  0,
+  	    using_directives);
+  
+}
+
+
 static void
 initialize_cu_func_list (struct dwarf2_cu *cu)
 {
@@ -3042,7 +3065,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
      back to building a containing block's symbol lists.  */
   local_symbols = new->locals;
   param_symbols = new->params;
-
+  using_directives = new->using_directives;
   /* If we've finished processing a top-level function, subsequent
      symbols go in the file symbol list.  */
   if (outermost_context_p ())

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]