public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-swagiaal-using-directive: read_func_scope now explore abstract origins.
@ 2008-10-28 17:47 swagiaal
  0 siblings, 0 replies; only message in thread
From: swagiaal @ 2008-10-28 17:47 UTC (permalink / raw)
  To: archer-commits

The branch, archer-swagiaal-using-directive has been updated
       via  1de38657622396795ce681e64b03fb74e81e6c3d (commit)
       via  321e8d42c746b41634d809e735dabb7b92df4d54 (commit)
       via  ad38fc410c72184efa56e3f8c6a05346b720bafe (commit)
       via  027622cf5c5cda322f73d23aa4ac95dc33c820cc (commit)
      from  c5b878390428438a6cd43518c9a202a10d960db7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 1de38657622396795ce681e64b03fb74e81e6c3d
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Oct 28 13:45:55 2008 -0400

    read_func_scope now explore abstract origins.
    
    +2008-10-28  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* dwarf2read.c (explore_children): New function.
    +	(explore_abstract_origin): New function.
    +	(read_func_scope): Added call to explore_abstract_origin.
    +

commit 321e8d42c746b41634d809e735dabb7b92df4d54
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Oct 28 12:01:02 2008 -0400

    Added new test to namespace-using test suite.
    
    +2008-10-28  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* gdb.cp/namespace-using.exp: New test.
    +	* gdb.cp/namespace-using.cc (marker7): Added function for new test.
    +

commit ad38fc410c72184efa56e3f8c6a05346b720bafe
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Mon Oct 27 13:06:59 2008 -0400

    Properly construct prefix of imported namespace.
    
    +2008-10-27  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* dwarf2read.c (read_import_statement): Properly construct
    +	prefix of imported namespace.
    +
     2008-10-22  Sami Wagiaalla  <swagiaal@redhat.com>
    
     	* buildsym.c (start_symtab): Removed call to cp_initialize_namespace.

commit 027622cf5c5cda322f73d23aa4ac95dc33c820cc
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Mon Oct 27 12:22:46 2008 -0400

    Added new test to namespace-using test case.
    
    +2008-10-27  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* gdb.cp/namespace-using.cc (marker6): Added function for new test.
    +	* gdb.cp/namespace-using.exp: Added new test.
    +

-----------------------------------------------------------------------

Summary of changes:
 gdb/ChangeLog                            |   11 ++++
 gdb/dwarf2read.c                         |   91 +++++++++++++++++++++++++++++-
 gdb/testsuite/ChangeLog                  |   10 +++
 gdb/testsuite/gdb.cp/namespace-using.cc  |   32 ++++++++++-
 gdb/testsuite/gdb.cp/namespace-using.exp |   21 +++++++
 5 files changed, 161 insertions(+), 4 deletions(-)

First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e611e94..610c6bc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+2008-10-28  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* dwarf2read.c (explore_children): New function.
+	(explore_abstract_origin): New function.
+	(read_func_scope): Added call to explore_abstract_origin.
+
+2008-10-27  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* dwarf2read.c (read_import_statement): Properly construct
+	prefix of imported namespace.
+
 2008-10-22  Sami Wagiaalla  <swagiaal@redhat.com>
 
 	* buildsym.c (start_symtab): Removed call to cp_initialize_namespace.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 1d82944..ef189b6 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -898,6 +898,8 @@ static char *typename_concat (struct obstack *,
 
 static void read_file_scope (struct die_info *, struct dwarf2_cu *);
 
+static void explore_children (struct die_info *, struct dwarf2_cu *);
+
 static void read_func_scope (struct die_info *, struct dwarf2_cu *);
 
 static void read_lexical_block_scope (struct die_info *, struct dwarf2_cu *);
@@ -2817,6 +2819,11 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
   struct attribute *import_attr;
   struct die_info *imported_die;
   const char *imported_name;
+  const char *imported_name_prefix;
+  char *canonical_name;
+  
+  const char *import_prefix;
+    
   int is_anonymous = 0;
   
   import_attr = dwarf2_attr (die, DW_AT_import, cu);
@@ -2837,8 +2844,26 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
 
   /* FIXME: dwarf2_name (die); for the local name after import.  */
   
-  using_directives = cp_add_using (imported_name, strlen (imported_name), 0,
-                                   using_directives);
+  /*
+   Figure out what the scope of the imported die is and prepend it
+   to the name of the imported die
+   */
+  imported_name_prefix = determine_prefix (imported_die, cu);
+  
+  
+  if(strlen (imported_name_prefix) > 0){
+    canonical_name = alloca (strlen (imported_name_prefix) + 2 + strlen (imported_name) + 1);
+    strcpy (canonical_name, imported_name_prefix);
+    strcat (canonical_name, "::");
+    strcat (canonical_name, imported_name);
+  }else{
+    canonical_name = alloca (strlen (imported_name) + 1);
+    strcpy (canonical_name, imported_name);
+  }
+  
+  using_directives = cp_add_using (canonical_name, strlen (canonical_name),
+      0,
+      using_directives);
 }
 
 static void
@@ -2997,6 +3022,61 @@ add_to_cu_func_list (const char *name, CORE_ADDR lowpc, CORE_ADDR highpc,
   cu->last_fn = thisfn;
 }
 
+/*
+   If the given die has an abstract origin explore it, and its' absract
+   origins.
+ */
+static void
+explore_abstract_origin (struct die_info *die, struct dwarf2_cu *cu)
+{
+  struct attribute *abstract_origin;
+  struct die_info *abstract_origin_die;
+  
+  /* If this die has an abstract origin then explore that as well
+       it might contain useful information such as import statements. */
+    abstract_origin = dwarf2_attr (die, DW_AT_specification, cu);
+    if(abstract_origin == NULL){
+      abstract_origin = dwarf2_attr (die, DW_AT_abstract_origin, cu);
+    }
+
+    if(abstract_origin != NULL){
+      abstract_origin_die = follow_die_ref (die, abstract_origin, &cu);
+
+      if(abstract_origin_die != NULL){
+        explore_children(abstract_origin_die, cu);
+        explore_abstract_origin(abstract_origin_die, cu);
+      }
+    }  
+}
+
+/*
+ Explore the children of the given die, calling process_die on
+ each.
+ */ 
+static void
+explore_children (struct die_info *die, struct dwarf2_cu *cu)
+{
+  struct context_stack *new;
+  CORE_ADDR lowpc;
+  CORE_ADDR highpc;
+  struct die_info *child_die;
+  struct attribute *attr;
+  char *name;
+  CORE_ADDR baseaddr;
+  struct block *block;
+
+  if (die->child != NULL)
+    {
+      child_die = die->child;
+      while (child_die && child_die->tag)
+        {
+          process_die (child_die, cu);
+          child_die = sibling_die (child_die);
+        }
+    }
+
+}
+
 static void
 read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
 {
@@ -3018,7 +3098,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
      missing or invalid low and high pc attributes.  */
   if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu))
     return;
-
+  
   lowpc += baseaddr;
   highpc += baseaddr;
 
@@ -3055,6 +3135,11 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
 	}
     }
 
+  /* If this die has abstact origins explore them. They might
+     contain useful information such as import statements. 
+   */
+  explore_abstract_origin(die, cu);
+  
   new = pop_context ();
   /* Make a block for the local symbols within.  */
   block = finish_block (new->name, &local_symbols, new->old_blocks,
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 2492f5e..f454a35 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2008-10-28  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* gdb.cp/namespace-using.exp: New test.
+	* gdb.cp/namespace-using.cc (marker7): Added function for new test.
+
+2008-10-27  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* gdb.cp/namespace-using.cc (marker6): Added function for new test.
+	* gdb.cp/namespace-using.exp: Added new test.
+
 2008-10-22  Sami Wagiaalla  <swagiaal@redhat.com> 
 
 	* gdb.cp/namespace-multiple-imports.cc: New test program.
diff --git a/gdb/testsuite/gdb.cp/namespace-using.cc b/gdb/testsuite/gdb.cp/namespace-using.cc
index 831bd2b..b1bfd82 100644
--- a/gdb/testsuite/gdb.cp/namespace-using.cc
+++ b/gdb/testsuite/gdb.cp/namespace-using.cc
@@ -1,3 +1,33 @@
+//--------------------------
+namespace G{
+  namespace H  {
+    int ghx = 6;
+  }
+}
+
+namespace I{
+  
+  int marker7(){
+    using namespace G::H;
+    ghx;
+    return 0;
+  }
+}
+//--------------------------
+
+//--------------------------
+namespace E{
+  namespace F{
+    int efx = 5;
+  }
+}
+using namespace E::F;
+int marker6(){
+  efx;
+  return I::marker7();
+}
+//--------------------------
+
 namespace A
 {
   int a = 1;
@@ -18,7 +48,7 @@ using namespace C;
 int marker5()
 {
   cc;
-  return 0;
+  return marker6();
 }
 
 int marker4()
diff --git a/gdb/testsuite/gdb.cp/namespace-using.exp b/gdb/testsuite/gdb.cp/namespace-using.exp
index e476f9b..8710249 100644
--- a/gdb/testsuite/gdb.cp/namespace-using.exp
+++ b/gdb/testsuite/gdb.cp/namespace-using.exp
@@ -126,3 +126,24 @@ if ![runto marker4] then {
 }
 
 gdb_test "print dx" "\\$\[0-9\].* = 4"
+
+############################################
+# Test printing of namespace aliases
+
+if ![runto marker6] then {
+    perror "couldn't run to breakpoint marker6"
+    continue
+}
+
+gdb_test "print efx" "\\$\[0-9\].* = 5"
+
+############################################
+# Test printing of variables imported from
+# nested namespaces
+
+if ![runto I::marker7] then {
+    perror "couldn't run to breakpoint I::marker7"
+    continue
+}
+
+gdb_test "print ghx" "\\$\[0-9\].* = 6"


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-10-28 17:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-28 17:47 [SCM] archer-swagiaal-using-directive: read_func_scope now explore abstract origins swagiaal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).