public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-swagiaal-using-directive: Add support for imported declarations.
@ 2008-11-06 22:00 swagiaal
  0 siblings, 0 replies; only message in thread
From: swagiaal @ 2008-11-06 22:00 UTC (permalink / raw)
  To: archer-commits

The branch, archer-swagiaal-using-directive has been updated
       via  4c736314fe5bf41d4c63daee24c7e226fa00dfc5 (commit)
       via  96052774aa53563e1738b0ad1f125cde30c2dc70 (commit)
       via  26f0d097891d248fbe184f785c52d04be8312f3e (commit)
      from  4a0d9e9faa4624f280248066977d7d903032b1a4 (commit)

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

- Log -----------------------------------------------------------------
commit 4c736314fe5bf41d4c63daee24c7e226fa00dfc5
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Thu Nov 6 16:55:14 2008 -0500

    Add support for imported declarations.
    
    +2008-11-06  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* dwarf2read.c (read_import_statement): Create using_direc structs
    +	representing imported declarations.
    +	* cp-namespace.c (cp_lookup_symbol_namespace): Check for imported
    +	declarations.
    +
    
    +2008-11-06  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* gdb.cp/namespace-using.exp: Removed kfail; test has been fix.

commit 96052774aa53563e1738b0ad1f125cde30c2dc70
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Thu Nov 6 15:24:51 2008 -0500

    Deleted mi-nonstop.exp. Will revert before merging.

commit 26f0d097891d248fbe184f785c52d04be8312f3e
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Thu Nov 6 15:23:52 2008 -0500

    Added declaration element to using_direct data struct.
    
    +2008-11-06  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* cp-support.h: Added char* declaration element to using_direct data struct.
    +	(cp_add_using): Added char* declaration argument.
    +	(cp_add_using_directive): Ditto.
    +	* cp-namespace.c: Updated with the above changes.
    +	* dwarf2read.c (read_import_statement): Ditto.
    +	(read_namespace): Ditto.
    +	* cp-namespace.c (cp_copy_usings): Copy aliases and declarations
    +
     2008-11-06  Sami Wagiaalla  <swagiaal@redhat.com>
    
     	* cp-namespace.c (cp_lookup_symbol_namespace): Check for aliases.

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

Summary of changes:
 gdb/ChangeLog                            |   17 +++
 gdb/cp-namespace.c                       |   31 ++++-
 gdb/cp-support.h                         |   13 ++-
 gdb/dwarf2read.c                         |   32 +++--
 gdb/testsuite/ChangeLog                  |    4 +
 gdb/testsuite/gdb.cp/namespace-using.exp |    1 -
 gdb/testsuite/gdb.mi/mi-nonstop.exp      |  209 ------------------------------
 7 files changed, 76 insertions(+), 231 deletions(-)
 delete mode 100644 gdb/testsuite/gdb.mi/mi-nonstop.exp

First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 93c26ef..d783c61 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,22 @@
 2008-11-06  Sami Wagiaalla  <swagiaal@redhat.com>
 
+	* dwarf2read.c (read_import_statement): Create using_direc structs
+	representing imported declarations.
+	* cp-namespace.c (cp_lookup_symbol_namespace): Check for imported 
+	declarations.
+
+2008-11-06  Sami Wagiaalla  <swagiaal@redhat.com> 
+ 
+	* cp-support.h: Added char* declaration element to using_direct data struct.
+	(cp_add_using): Added char* declaration argument.
+	(cp_add_using_directive): Ditto. 
+	* cp-namespace.c: Updated with the above changes.
+	* dwarf2read.c (read_import_statement): Ditto.
+	(read_namespace): Ditto.
+	* cp-namespace.c (cp_copy_usings): Copy aliases and declarations 
+
+2008-11-06  Sami Wagiaalla  <swagiaal@redhat.com>
+
 	* cp-namespace.c (cp_lookup_symbol_namespace): Check for aliases.
 	lookup unqualified names without namespace concatenation.
 	* dwarf2read.c (read_import_statement): Figure out local alias for
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index d5db551..4e76b6d 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -108,7 +108,7 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
 		 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 (outer, name, "");
+	      cp_add_using_directive (outer, name, "", "");
 	    }
 	  /* The "+ 2" is for the "::".  */
 	  previous_component = next_component + 2;
@@ -123,7 +123,8 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
    has already been added, don't add it twice.  */
 
 void
-cp_add_using_directive (const char *outer, const char *inner, const char* alias)
+cp_add_using_directive (const char *outer, const char *inner, const char* alias,
+    const char *declaration)
 {
   struct using_direct *current;
   struct using_direct *new;
@@ -137,7 +138,7 @@ cp_add_using_directive (const char *outer, const char *inner, const char* alias)
 	return;
     }
 
-  using_directives = cp_add_using (outer, inner, alias,
+  using_directives = cp_add_using (outer, inner, alias, declaration,
       using_directives);
 }
 
@@ -201,6 +202,7 @@ struct using_direct *
 cp_add_using (const char *outer,
               const char *inner,
               const char *alias,
+              const char *declaration,
 	      struct using_direct *next)
 {
   struct using_direct *retval;
@@ -209,7 +211,8 @@ cp_add_using (const char *outer,
   retval->inner = savestring (inner, strlen(inner));
   retval->outer = savestring (outer, strlen(outer));
   retval->alias = savestring (alias, strlen(alias));
-    
+  retval->declaration = savestring (declaration, strlen(declaration));
+      
   retval->next = next;
 
   return retval;
@@ -234,7 +237,11 @@ cp_copy_usings (struct using_direct *using,
       retval->inner = obsavestring (using->inner, strlen (using->inner),
 				    obstack);
       retval->outer = obsavestring (using->outer, strlen (using->outer),
-				    obstack);
+                                    obstack);
+      retval->alias = obsavestring (using->alias, strlen (using->alias),
+                                    obstack);
+      retval->declaration = obsavestring (using->declaration, strlen (using->declaration),
+                                    obstack);
       retval->next = cp_copy_usings (using->next, obstack);
 
       xfree (using->inner);
@@ -369,7 +376,7 @@ cp_lookup_symbol_namespace (const char *namespace,
 			    const domain_enum domain)
 {
   const struct using_direct *current;
-  struct symbol *sym;
+  struct symbol *sym = NULL;
 
   /* First, go through the using directives.  If any of them add new
      names to the namespace we're searching in, see if we can find a
@@ -383,6 +390,16 @@ cp_lookup_symbol_namespace (const char *namespace,
       if (strcmp (namespace, current->outer) == 0)
 	{
 	  
+	  if(strcmp ("", current->declaration) != 0){
+	    if(strcmp (name, current->declaration) == 0){
+	      sym = cp_lookup_symbol_namespace (current->inner,
+	                                        name,
+	                                        linkage_name,
+	                                        block,
+	                                        domain);
+	    }
+	   
+	  }else{
 	  /* Check for aliases */
 	  if(strcmp (name, current->alias) == 0){
 	    sym = cp_lookup_symbol_namespace (namespace,
@@ -397,7 +414,7 @@ cp_lookup_symbol_namespace (const char *namespace,
 					      block,
 					      domain);
 	  }
-	  
+	  }
 	  if (sym != NULL){
 	    return sym;
 	  }
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index fe9794e..1e60b92 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -41,7 +41,12 @@ struct demangle_component;
    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; 
+       namespace C=A::B;
+   ALIAS = "C"
+   DECLARATION is the name of the imported declaration, if this import 
+   statement represents one. Eg:
+       using A::x;
+   Where x is variable in namespace A. declaration is set to x.  
 */
 
 struct using_direct
@@ -51,6 +56,8 @@ struct using_direct
   
   char *alias;
   
+  char *declaration;
+  
   struct using_direct *next;
 };
 
@@ -84,11 +91,13 @@ extern int cp_is_anonymous (const char *namespace);
 
 extern void cp_add_using_directive (const char *outer,
                                     const char *inner,
-                                    const char *alias);
+                                    const char *alias,
+                                    const char *declaration);
 
 extern struct using_direct *cp_add_using (const char *outer,
                                           const char *inner,
                                           const char *alias,
+                                          const char *declaration,
 					  struct using_direct *next);
 
 extern void cp_initialize_namespace (void);
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b0f7b69..dcc402d 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2821,8 +2821,8 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
   const char *imported_name;
   const char *imported_name_prefix;
   char *canonical_name;
-  char *import_alias;
-  
+  const char *import_alias;
+  const char *imported_declaration = "";
   const char *import_prefix;
     
   int is_anonymous = 0;
@@ -2858,18 +2858,26 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
    */
   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);
+  if(imported_die->tag != DW_TAG_namespace){
+    imported_declaration = imported_name;
+    canonical_name = (char*)imported_name_prefix;
   }else{
-    canonical_name = alloca (strlen (imported_name) + 1);
-    strcpy (canonical_name, imported_name);
+    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 (import_prefix,canonical_name, import_alias, using_directives);
+  using_directives = cp_add_using (import_prefix,
+                                   canonical_name,
+                                   import_alias,
+                                   imported_declaration,
+                                   using_directives);
 }
 
 static void
@@ -4741,7 +4749,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 (previous_prefix, TYPE_NAME (type), "");
+	  cp_add_using_directive (previous_prefix, TYPE_NAME (type), "", "");
 	}
     }
 
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 34d7bb5..4a7cd36 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,6 +1,10 @@
 2008-11-06  Sami Wagiaalla  <swagiaal@redhat.com>
 
 	* gdb.cp/namespace-using.exp: Removed kfail; test has been fix.
+	
+2008-11-06  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* gdb.cp/namespace-using.exp: Removed kfail; test has been fix.
 
 2008-11-04  Sami Wagiaalla  <swagiaal@redhat.com>
 
diff --git a/gdb/testsuite/gdb.cp/namespace-using.exp b/gdb/testsuite/gdb.cp/namespace-using.exp
index fa0010f..98356aa 100644
--- a/gdb/testsuite/gdb.cp/namespace-using.exp
+++ b/gdb/testsuite/gdb.cp/namespace-using.exp
@@ -118,7 +118,6 @@ gdb_load ${binfile}
 ############################################
 # Test printing of namespace aliases
 
-setup_kfail "gdb/381" "*-*-*"
 if ![runto marker4] then {
     perror "couldn't run to breakpoint marker4"
     continue
diff --git a/gdb/testsuite/gdb.mi/mi-nonstop.exp b/gdb/testsuite/gdb.mi/mi-nonstop.exp
deleted file mode 100644
index 4aa3a5a..0000000
--- a/gdb/testsuite/gdb.mi/mi-nonstop.exp
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2002, 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# This only works with native configurations
-if {![isnative]} {
-  return
-}
-
-load_lib mi-support.exp
-set MIFLAGS "-i=mi"
-
-gdb_exit
-if {[mi_gdb_start]} {
-    continue
-}
-
-proc myreverse { list } {
-    if { [llength $list] <= 1 } {
-        return $list
-    }
-    set tail [lrange $list 1 [llength $list]]
-    set rtail [myreverse $tail]
-    lappend rtail [lindex $list 0]
-    return $rtail
-}
-
-proc check_thread_states { xstates test } {
-    global expect_out
-    set states [myreverse $xstates]
-    set pattern "\\^done,threads=\\\["
-    foreach s $states {
-        set pattern "${pattern}(.*)state=\"$s\""
-    }
-    set pattern "$pattern\\\}\\\].*"
-
-    verbose -log "expecting: $pattern"
-    mi_gdb_test "-thread-info" $pattern $test
-}
-
-#
-# Start here
-#
-set testfile "non-stop"
-set srcfile "$testfile.c"
-set binfile "$objdir/$subdir/mi-$testfile"
-
-set options [list debug incdir=$objdir]
-if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
-    return -1
-}
-
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load $binfile
-
-set supported 0
-send_gdb "-gdb-show non-stop\n"
-gdb_expect {
-    -re ".*\\^done,value=\"off\",supported=\"(\[^\"\]+)\"\r\n$mi_gdb_prompt$" {
-        if { $expect_out(1,string) == "1" } {
-            set supported 1
-        }
-    }
-    -re ".$mi_gdb_prompt$" {
-    }
-}
-
-mi_gdb_test "-gdb-set non-stop 1" ".*"
-mi_gdb_test "-gdb-set target-async 1" ".*"
-detect_async
-
-mi_gdb_test "200-break-insert -t main" ".*"
-# Note: presently, we skip this test on non-native targets,
-# so 'run' is OK.  As soon as we start to run this on remote
-# target, the logic from mi_run_cmd will have to be refactored.
-send_gdb "-exec-run\n"
-gdb_expect {
-    -re ".*\\^running.*$mi_gdb_prompt$" {
-    }
-    -re "\\^error,msg=\"The target does not support running in non-stop mode.\"" {
-        verbose -log "Non-stop mode not supported, skipping all tests"
-        return
-    }
-    -re ".*\r\n$mi_gdb_prompt$" {
-        perror "Cannot start target (unknown output after running)"
-        return -1
-    }
-    timeout {
-        perror "Cannot start target (timeout)"
-        return -1
-    }
-}
-mi_expect_stop "breakpoint-hit" main ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "run to main"
-
-mi_create_breakpoint break_at_me 2 keep break_at_me .* .* .* "breakpoint at marker"
-
-mi_send_resuming_command "exec-continue" "resume 1"
-mi_expect_stop "breakpoint-hit" "break_at_me" ".*" "non-stop.c" ".*" {"" "disp=\"keep\""} "w0,i0 stop"
-mi_expect_stop "breakpoint-hit" "break_at_me" ".*" "non-stop.c" ".*" {"" "disp=\"keep\""} "w1,i0 stop"
-
-check_thread_states {"running" "stopped" "stopped"} "thread state, stop 1"
-
-mi_gdb_test "-thread-select 2" "\\^done.*" "select thread 2"
-mi_create_varobj I_W0 "i" "create varobj in first thread"
-mi_gdb_test "-thread-select 3" "\\^done.*" "select thread 3"
-mi_create_varobj I_W1 "i" "create varobj in second thread" 
-
-mi_send_resuming_command "exec-continue --thread 2" "resume 1"
-check_thread_states {"running" "running" "stopped"} "thread state, resume 1"
-mi_expect_stop "breakpoint-hit" "break_at_me" ".*" "non-stop.c" ".*" {"" "disp=\"keep\""} "w0,i1 stop"
-check_thread_states {"running" "stopped" "stopped"} "thread state, stop 2"
-
-mi_send_resuming_command "exec-continue --thread 3" "resume 2"
-check_thread_states {"running" "stopped" "running"} "thread state, resume 2"
-mi_expect_stop "breakpoint-hit" "break_at_me" ".*" "non-stop.c" ".*" {"" "disp=\"keep\""} "w1,i1 stop"
-check_thread_states {"running" "stopped" "stopped"} "thread state, stop 3"
-
-mi_varobj_update * {I_W1 I_W0} "update varobj, 1"
-mi_check_varobj_value I_W0 1 "check varobj, w0, 1"
-mi_check_varobj_value I_W1 1 "check varobj, w1, 1"
-
-send_gdb "-exec-interrupt --thread 1\n" 
-gdb_expect {
-    -re "\\^done\r\n$mi_gdb_prompt\\*stopped\[^\r\n\]+\r\n$" {
-        pass "interrupted"
-    }
-    timeout {
-        fail "interrupted (timeout)"
-    }
-}
-# The interrupt command sends SIGINT to the target, and therefore the
-# thread might not be stopped immediately when we return from the target.
-# So, wait a bit
-sleep 1
-check_thread_states {"stopped" "stopped" "stopped"} "thread state, stop 4"
-
-send_gdb "-exec-continue --all\n"
-gdb_expect {
-    -re ".*\\*running,thread-id=\"3\"\r\n\\*running,thread-id=\"2\"\r\n\\*running,thread-id=\"1\"\r\n$mi_gdb_prompt" {
-        pass "resume all"
-    }
-    timeout {
-        fail "resume all (timeout)"
-    }
-}
-
-check_thread_states {"running" "running" "running"} "thread state, resume all"
-
-mi_expect_stop "breakpoint-hit" "break_at_me" ".*" "non-stop.c" ".*" {"" "disp=\"keep\""} "w0,i2 stop"
-mi_expect_stop "breakpoint-hit" "break_at_me" ".*" "non-stop.c" ".*" {"" "disp=\"keep\""} "w1,i2 stop"
-
-# At this point, thread 1 (main) is running, and worker threads are stopped.
-# Check that we can modify breakpoint condition, even when operating on a 
-# running thread.
-mi_gdb_test "-break-condition --thread 1 2 id==1" "\\^done" "set condition, 1"
-
-mi_send_resuming_command "exec-continue --thread 2" "resume 2"
-mi_send_resuming_command "exec-continue --thread 3" "resume 3"
-
-sleep 2
-mi_expect_stop "breakpoint-hit" "break_at_me" ".*" "non-stop.c" ".*" {"" "disp=\"keep\""} "w0,i3 stop"
-check_thread_states {"running" "running" "stopped"} "thread state, stop on cond breakpoint"
-
-# Check that when we update all varobj, we don't get no error about varobj
-# bound to running thread.
-mi_varobj_update * {I_W1} "update varobj, 2"
-mi_check_varobj_value I_W1 3 "check varobj, w1, 1"
-
-
-# Check that stack commands are allowed on a stopped thread, even if some other threads
-# are running, and produce something sane.  Also check we check error on running thread.
-mi_gdb_test "-stack-list-frames --thread 2" "\\^error,msg=\".*\"" "stacktrace of running thread"
-mi_gdb_test "-stack-list-frames --thread 3" \
-    "\\^done,stack=\\\[frame={level=\"0\",addr=\".*\",func=\"break_at_me\".*" \
-    "stacktrace of stopped thread"
-
-# verify that after thread exit, the thread is reported as exited in -thread-info, and
-# we can still interact with other threads.
-mi_gdb_test "-thread-select 2" "\\^done.*" "select first worker thread"
-# Since thread 2 is running, we need to set variable via another thread.
-mi_gdb_test "-gdb-set --thread 3 variable exit_first_thread=1" ".*\\^done" "ask the second thread to exit"
-gdb_expect {
-    -re ".*=thread-exited,id=\"2\"\r\n$" {
-        pass "wait for thread exit"
-    }
-    timeout {
-        fail "wait for thread exit (timeout)"
-    }
-}
-
-# See that we can still poke other threads.
-mi_gdb_test "-stack-list-frames --thread 3" \
-    "\\^done,stack=\\\[frame={level=\"0\",addr=\".*\",func=\"break_at_me\".*" \
-    "stacktrace of stopped thread"
-
-    
-mi_gdb_exit
-


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


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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-06 22:00 [SCM] archer-swagiaal-using-directive: Add support for imported declarations 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).