public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-swagiaal-using-directive: Correctly set up import destination for using directives.
@ 2008-11-05 16:00 swagiaal
  0 siblings, 0 replies; only message in thread
From: swagiaal @ 2008-11-05 16:00 UTC (permalink / raw)
  To: archer-commits

The branch, archer-swagiaal-using-directive has been updated
       via  ffe76bc7287c5fb6ab510e6b569ad8a0dc80d24f (commit)
       via  fe51b14c8e1a7b7ca461461aa04aeeab117b4833 (commit)
       via  644cb97dbea475fc2249260e8b637a5cdcbf88e7 (commit)
       via  a1afa6aa0fcbd9554d6b1aba5b25f5b5159aafc4 (commit)
       via  544c1a707f73f7db527359d395ec7c90255101ec (commit)
      from  d4a7b9767cb269666dcc77ad274f8f3eb8d6ae4a (commit)

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

- Log -----------------------------------------------------------------
commit ffe76bc7287c5fb6ab510e6b569ad8a0dc80d24f
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Nov 4 16:41:27 2008 -0500

    Correctly set up import destination for using directives.
    
    +2008-11-04  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* cp-namespace.c (lookup_namespace_scope): Use
    +	cp_lookup_symbol_namespace_incremental.
    +	* dwarf2read.c (read_import_statement): Correctly set the import
    +	location.
    +	* symtab.c (lookup_symbol_aux_local): Removed call to
    +	lookup_namespace_scope.
    +

commit fe51b14c8e1a7b7ca461461aa04aeeab117b4833
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Nov 4 13:16:42 2008 -0500

    Added new test case to namespace-using.exp test suite.
    
    +2008-11-04  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* gdb.cp/namespace-using.exp: New test.
    +	* gdb.cp/namespace-using.cc (marker8): new function for new test.
    +	(marker9): Ditto.
    +

commit 644cb97dbea475fc2249260e8b637a5cdcbf88e7
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Nov 4 12:21:54 2008 -0500

    Removed extraneous print statement in cp_lookup_symbol_namespace_incremental.
    
    +2008-11-04  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* cp-namespace.c (cp_lookup_symbol_namespace_incremental): Removed
    +	extraneous print statement.
    +

commit a1afa6aa0fcbd9554d6b1aba5b25f5b5159aafc4
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Nov 4 12:13:05 2008 -0500

    using_direct structs now have and 'alias' element.
    
    +2008-11-04  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* cp-support.h: Added char* alias element to using_direct data struct.
    +	(cp_add_using): Added char* alias argument.
    +	(cp_add_using_directive): Ditto.
    +	* cp-namespace.c: Updated with the above changes.
    +	* dwarf2read.c (read_import_statement): Ditto.
    +	(read_namespace): Ditto.
    +

commit 544c1a707f73f7db527359d395ec7c90255101ec
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Mon Nov 3 15:45:36 2008 -0500

    add_using_directive functions now take char* outer char* inner arguments.
    
    +2008-11-03  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* cp-namespace.h (cp_add_using_directive): Now takes char
    +	and char* outer arguments.
    +	(cp_add_using): Ditto.
    +	(cp_add_using_directive): Updated with the above changes.
    +	* cp-namespace.c (cp_add_using): ditto.
    +	(cp_scan_for_anonymous_namespaces): Ditto.
    +	* dwarf2read.c (read_namespace): Ditto.
    +

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

Summary of changes:
 gdb/ChangeLog                            |   33 ++++++++++++++++++
 gdb/cp-namespace.c                       |   55 +++++++++++++----------------
 gdb/cp-support.h                         |   24 ++++++++-----
 gdb/dwarf2read.c                         |   11 +++---
 gdb/symtab.c                             |    6 ---
 gdb/testsuite/ChangeLog                  |    6 +++
 gdb/testsuite/gdb.cp/namespace-using.cc  |   23 ++++++++++++-
 gdb/testsuite/gdb.cp/namespace-using.exp |   16 +++++++++
 8 files changed, 122 insertions(+), 52 deletions(-)

First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 59658b4..be655ff 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,36 @@
+2008-11-04  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* cp-namespace.c (lookup_namespace_scope): Use 
+	cp_lookup_symbol_namespace_incremental.
+	* dwarf2read.c (read_import_statement): Correctly set the import 
+	location.
+	* symtab.c (lookup_symbol_aux_local): Removed call to 
+	lookup_namespace_scope.
+
+2008-11-04  Sami Wagiaalla  <swagiaal@redhat.com>
+	
+	* cp-namespace.c (cp_lookup_symbol_namespace_incremental): Removed 
+	extraneous print statement. 
+	
+2008-11-04  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* cp-support.h: Added char* alias element to using_direct data struct.
+	(cp_add_using): Added char* alias argument.
+	(cp_add_using_directive): Ditto. 
+	* cp-namespace.c: Updated with the above changes.
+	* dwarf2read.c (read_import_statement): Ditto.
+	(read_namespace): Ditto.
+	
+2008-11-03  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* cp-namespace.h (cp_add_using_directive): Now takes char
+	and char* outer arguments.
+	(cp_add_using): Ditto.
+	(cp_add_using_directive): Updated with the above changes.
+	* cp-namespace.c (cp_add_using): ditto.
+	(cp_scan_for_anonymous_namespaces): Ditto.
+	* dwarf2read.c (read_namespace): Ditto.
+
 2008-10-30  Sami Wagiaalla  <swagiaal@redhat.com>
 
 	* cp-support.h: Added prototype for 
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 05ac367..885af88 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -98,14 +98,17 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
 			  "(anonymous namespace)",
 			  ANONYMOUS_NAMESPACE_LEN) == 0)
 	    {
+	      int outer_len = (previous_component == 0 ? 0 : previous_component - 2);
+	      char outer[outer_len+1];
+	      
+	      strncpy(outer, name, outer_len);
+	      
+	      outer[outer_len] = '\0';
 	      /* We've found a component of the name that's an
 		 anonymous namespace.  So add symbols in it to the
 		 namespace given by the previous component if there is
 		 one, or to the global namespace if there isn't.  */
-	      cp_add_using_directive (name,
-				      previous_component == 0
-				      ? 0 : previous_component - 2,
-				      next_component);
+	      cp_add_using_directive (outer, name, "");
 	    }
 	  /* The "+ 2" is for the "::".  */
 	  previous_component = next_component + 2;
@@ -116,16 +119,11 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
     }
 }
 
-/* Add a using directive to using_list.  NAME is the start of a string
-   that should contain the namespaces we want to add as initial
-   substrings, OUTER_LENGTH is the end of the outer namespace, and
-   INNER_LENGTH is the end of the inner namespace.  If the using
-   directive in question has already been added, don't add it
-   twice.  */
+/* Add a using directive to using_list. If the using directive in question
+   has already been added, don't add it twice.  */
 
 void
-cp_add_using_directive (const char *name, unsigned int outer_length,
-			unsigned int inner_length)
+cp_add_using_directive (const char *outer, const char *inner, const char* alias)
 {
   struct using_direct *current;
   struct using_direct *new;
@@ -134,13 +132,12 @@ cp_add_using_directive (const char *name, unsigned int outer_length,
 
   for (current = using_directives; current != NULL; current = current->next)
     {
-      if ((strncmp (current->inner, name, inner_length) == 0)
-	  && (strlen (current->inner) == inner_length)
-	  && (strlen (current->outer) == outer_length))
+      if (strcmp (current->inner, inner) == 0
+	  && strcmp (current->outer, outer) == 0)
 	return;
     }
 
-  using_directives = cp_add_using (name, inner_length, outer_length,
+  using_directives = cp_add_using (outer, inner, alias,
       using_directives);
 }
 
@@ -192,26 +189,27 @@ cp_is_anonymous (const char *namespace)
 	  != NULL);
 }
 
-/* Create a new struct using direct whose inner namespace is the
-   initial substring of NAME of leng INNER_LEN and whose outer
-   namespace is the initial substring of NAME of length OUTER_LENGTH.
+/* Create a new struct using direct whose inner namespace is INNER 
+   and whose outer namespace is OUTER. ALIAS is the name of the imported
+   namespace in the current scope. If ALIAS is an empty string  then the
+   namespace is known by its original name.
    Set its next member in the linked list to NEXT; allocate all memory
    using xmalloc.  It copies the strings, so NAME can be a temporary
    string.  */
 
 struct using_direct *
-cp_add_using (const char *name,
-	      unsigned int inner_len,
-	      unsigned int outer_len,
+cp_add_using (const char *outer,
+              const char *inner,
+              const char *alias,
 	      struct using_direct *next)
 {
   struct using_direct *retval;
 
-  gdb_assert (outer_len < inner_len);
-
   retval = xmalloc (sizeof (struct using_direct));
-  retval->inner = savestring (name, inner_len);
-  retval->outer = savestring (name, outer_len);
+  retval->inner = savestring (inner, strlen(inner));
+  retval->outer = savestring (outer, strlen(outer));
+  retval->alias = savestring (alias, strlen(alias));
+    
   retval->next = next;
 
   return retval;
@@ -322,7 +320,7 @@ lookup_namespace_scope (const char *name,
   namespace = alloca (scope_len + 1);
   strncpy (namespace, scope, scope_len);
   namespace[scope_len] = '\0';
-  return cp_lookup_symbol_namespace (namespace, name, linkage_name,
+  return cp_lookup_symbol_namespace_incremental (namespace, name, linkage_name,
 				     block, domain);
 }
 
@@ -338,7 +336,6 @@ cp_lookup_symbol_namespace_incremental (const char *namespace,
   struct symbol *sym;
   const struct block *global_block = block_global_block (block);
 
-  printf("cp_lookup_symbol_namespace_incremental name %s\n", name);
   /* Check if either no block is specified or it's a global block.  */
 
   if (global_block == NULL)
@@ -346,8 +343,6 @@ cp_lookup_symbol_namespace_incremental (const char *namespace,
 
   while (block != global_block)
     {
-      printf("  cp_lookup_symbol_namespace_incremental name %s in block %p [%p - %p]\n", name, block, (void*)block->startaddr, (void*)block->endaddr);
-      
       sym = cp_lookup_symbol_namespace (namespace, name, linkage_name, block, domain);
 
       if (sym != NULL)
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index bd30c3d..fe9794e 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -38,14 +38,19 @@ struct demangle_component;
 
 /* This struct is designed to store data from using directives.  It
    says that names from namespace INNER should be visible within
-   namespace OUTER.  OUTER should always be a strict initial substring
-   of INNER.  These form a linked list; NEXT is the next element of
-   the list.  */
+   namespace OUTER These form a linked list; NEXT is the next element of
+   the list. ALIAS is set to a non empty string if the imported namespace
+   has been aliased.Eg:
+       namespace C=A::B; 
+*/
 
 struct using_direct
 {
   char *inner;
   char *outer;
+  
+  char *alias;
+  
   struct using_direct *next;
 };
 
@@ -54,6 +59,7 @@ struct using_direct
 
 extern char *cp_canonicalize_string (const char *string);
 
+
 extern char *cp_class_name_from_physname (const char *physname);
 
 extern char *method_name_from_physname (const char *physname);
@@ -76,13 +82,13 @@ extern struct type *cp_lookup_rtti_type (const char *name,
 
 extern int cp_is_anonymous (const char *namespace);
 
-extern void cp_add_using_directive (const char *name,
-				    unsigned int outer_length,
-				    unsigned int inner_length);
+extern void cp_add_using_directive (const char *outer,
+                                    const char *inner,
+                                    const char *alias);
 
-extern struct using_direct *cp_add_using (const char *name,
-					  unsigned int inner_len,
-					  unsigned int outer_len,
+extern struct using_direct *cp_add_using (const char *outer,
+                                          const char *inner,
+                                          const char *alias,
 					  struct using_direct *next);
 
 extern void cp_initialize_namespace (void);
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 7200c3f..e244655 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2844,6 +2844,9 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
 
   /* FIXME: dwarf2_name (die); for the local name after import.  */
   
+  /* Figure out where the statement is being imported to */
+  import_prefix = determine_prefix (die, cu);
+
   /*
    Figure out what the scope of the imported die is and prepend it
    to the name of the imported die
@@ -2861,9 +2864,7 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
     strcpy (canonical_name, imported_name);
   }
   
-  using_directives = cp_add_using (canonical_name, strlen (canonical_name),
-      0,
-      using_directives);
+  using_directives = cp_add_using (import_prefix,canonical_name, "", using_directives);
 }
 
 static void
@@ -4735,9 +4736,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu)
       if (is_anonymous)
 	{
 	  const char *previous_prefix = determine_prefix (die, cu);
-	  cp_add_using_directive (TYPE_NAME (type),
-				  strlen (previous_prefix),
-				  strlen (TYPE_NAME (type)));
+	  cp_add_using_directive (previous_prefix, TYPE_NAME (type), "");
 	}
     }
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 3cf0b04..9f91930 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1373,12 +1373,6 @@ lookup_symbol_aux_local (const char *name, const char *linkage_name,
       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);
     }
 
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index f454a35..d1c1375 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2008-11-04  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* gdb.cp/namespace-using.exp: New test.
+	* gdb.cp/namespace-using.cc (marker8): new function for new test.
+	(marker9): Ditto.
+	
 2008-10-28  Sami Wagiaalla  <swagiaal@redhat.com>
 
 	* gdb.cp/namespace-using.exp: New test.
diff --git a/gdb/testsuite/gdb.cp/namespace-using.cc b/gdb/testsuite/gdb.cp/namespace-using.cc
index b1bfd82..cfe0477 100644
--- a/gdb/testsuite/gdb.cp/namespace-using.cc
+++ b/gdb/testsuite/gdb.cp/namespace-using.cc
@@ -1,4 +1,25 @@
 //--------------------------
+namespace J {
+    int jx = 44;
+}
+
+namespace K{
+  int marker9(){
+    //x;
+    return 10;
+  }
+}
+
+namespace L{
+  using namespace J;
+  int marker8(){
+    jx;
+    return K::marker9();
+  }
+}
+//--------------------------
+
+//--------------------------
 namespace G{
   namespace H  {
     int ghx = 6;
@@ -10,7 +31,7 @@ namespace I{
   int marker7(){
     using namespace G::H;
     ghx;
-    return 0;
+    return L::marker8();
   }
 }
 //--------------------------
diff --git a/gdb/testsuite/gdb.cp/namespace-using.exp b/gdb/testsuite/gdb.cp/namespace-using.exp
index 8710249..70564bf 100644
--- a/gdb/testsuite/gdb.cp/namespace-using.exp
+++ b/gdb/testsuite/gdb.cp/namespace-using.exp
@@ -147,3 +147,19 @@ if ![runto I::marker7] then {
 }
 
 gdb_test "print ghx" "\\$\[0-9\].* = 6"
+
+############################################
+# Test that variables are not printed in a namespace
+# that is sibling to the namespace containing an import
+
+if ![runto L::marker8] then {
+    perror "couldn't run to breakpoint L::marker8"
+    continue
+}
+
+gdb_test "print jx" "\\$\[0-9\].* = 44"
+
+gdb_breakpoint "K::marker9"
+gdb_continue_to_breakpoint "K::marker9"
+
+gdb_test "print jx" "No symbol \"jx\" in current context."


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


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

only message in thread, other threads:[~2008-11-05 16:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-05 16:00 [SCM] archer-swagiaal-using-directive: Correctly set up import destination for using directives 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).