public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-ambiguous-linespec: fix canonicalization buglet in "function:label" support
@ 2011-08-15 17:28 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2011-08-15 17:28 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-ambiguous-linespec has been updated
       via  417683484c90a786dab8c4bd6ef3aef2e91980e6 (commit)
       via  c9e2ef5254dcd6e3540f1793e1051bbae132fee0 (commit)
       via  1178ea8a111a444d9d38626a241e5c026a965538 (commit)
      from  e5795a75c3cac7bb44b2c04579fc105bab2abdc8 (commit)

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

- Log -----------------------------------------------------------------
commit 417683484c90a786dab8c4bd6ef3aef2e91980e6
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Aug 15 11:26:58 2011 -0600

    fix canonicalization buglet in "function:label" support

commit c9e2ef5254dcd6e3540f1793e1051bbae132fee0
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Aug 15 11:19:39 2011 -0600

    iterate over all relevant program spaces

commit 1178ea8a111a444d9d38626a241e5c026a965538
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Aug 15 11:10:43 2011 -0600

    fix cleanup bug in decode_compound

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

Summary of changes:
 gdb/linespec.c                          |  105 ++++++++++++++++++++++---------
 gdb/testsuite/gdb.linespec/linespec.exp |   22 ++++++-
 2 files changed, 96 insertions(+), 31 deletions(-)

First 500 lines of diff:
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 87c0e0f..938075f 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -56,6 +56,9 @@ DEF_VEC_P (symbolp);
 
 struct linespec_state
 {
+  /* The program space as seen when the module was entered.  */
+  struct program_space *program_space;
+
   /* The default symtab to use, if no other symtab is specified.  */
   struct symtab *default_symtab;
 
@@ -241,26 +244,32 @@ iterate_over_all_matching_symtabs (const char *name,
 				   void *data)
 {
   struct objfile *objfile;
+  struct program_space *pspace;
 
-  ALL_OBJFILES (objfile)
+  ALL_PSPACES (pspace)
   {
-    struct symtab *symtab;
+    set_current_program_space (pspace);
 
-    if (objfile->sf)
-      objfile->sf->qf->expand_symtabs_matching (objfile, NULL,
-						iterate_name_matcher,
-						ALL_DOMAIN,
-						&name);
+    ALL_OBJFILES (objfile)
+    {
+      struct symtab *symtab;
 
-    ALL_OBJFILE_SYMTABS (objfile, symtab)
-      {
-	if (symtab->primary)
-	  {
-	    struct block *block;
-	    block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
-	    iterate_over_symbols (block, name, domain, callback, data);
-	  }
-      }
+      if (objfile->sf)
+	objfile->sf->qf->expand_symtabs_matching (objfile, NULL,
+						  iterate_name_matcher,
+						  ALL_DOMAIN,
+						  &name);
+
+      ALL_OBJFILE_SYMTABS (objfile, symtab)
+	{
+	  if (symtab->primary)
+	    {
+	      struct block *block;
+	      block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
+	      iterate_over_symbols (block, name, domain, callback, data);
+	    }
+	}
+    }
   }
 }
 
@@ -1160,6 +1169,7 @@ linespec_state_constructor (struct linespec_state *self,
   self->default_symtab = default_symtab;
   self->default_line = default_line;
   self->canonical = canonical;
+  self->program_space = current_program_space;
 }
 
 /* A destructor for linespec_state.  */
@@ -1186,6 +1196,7 @@ decode_line_full (char **argptr, int funfirstline,
   linespec_state_constructor (&state, funfirstline, default_symtab,
 			      default_line, canonical);
   cleanups = make_cleanup (linespec_state_destructor, &state);
+  save_current_program_space ();
 
   gdb_assert (canonical != NULL);
   result = decode_line_internal (&state, argptr);
@@ -1205,6 +1216,7 @@ decode_line_1 (char **argptr, int funfirstline,
   linespec_state_constructor (&state, funfirstline, default_symtab,
 			      default_line, NULL);
   cleanups = make_cleanup (linespec_state_destructor, &state);
+  save_current_program_space ();
 
   result = decode_line_internal (&state, argptr);
   do_cleanups (cleanups);
@@ -1716,8 +1728,10 @@ decode_compound (struct linespec_state *self,
 	 here, we return.  If not, and we are at the and of the string,
 	 we'll lookup the whole string in the symbol tables.  */
 
+      values = find_method (self, saved_arg, copy, sym_classes);
+
       do_cleanups (cleanup);
-      return find_method (self, saved_arg, copy, sym_classes);
+      return values;
     } /* End if symbol found.  */
 
 
@@ -1844,8 +1858,10 @@ lookup_prefix_sym (char **argptr, char *p, VEC (symtab_p) *file_symtabs)
 	}
       else
 	{
-	  struct block *search_block = get_search_block (elt);
+	  struct block *search_block;
 
+	  set_current_program_space (SYMTAB_PSPACE (elt));
+	  search_block = get_search_block (elt);
 	  iterate_over_symbols (search_block, copy, STRUCT_DOMAIN,
 				collect_one_symbol, &collector);
 	  iterate_over_symbols (search_block, copy, VAR_DOMAIN,
@@ -1897,8 +1913,10 @@ find_method (struct linespec_state *self, char *saved_arg,
   i1 = 0;
   for (ix = 0; VEC_iterate (symbolp, sym_classes, ix, sym); ++ix)
     {
-      struct type *t = check_typedef (SYMBOL_TYPE (sym));
+      struct type *t;
 
+      set_current_program_space (SYMTAB_PSPACE (SYMBOL_SYMTAB (sym)));
+      t = check_typedef (SYMBOL_TYPE (sym));
       i1 = find_methods (t, copy, SYMBOL_LANGUAGE (sym), sym_arr + i1,
 			 SYMBOL_SYMTAB (sym));
     }
@@ -1913,6 +1931,8 @@ find_method (struct linespec_state *self, char *saved_arg,
 
       if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
 	{
+	  set_current_program_space (SYMTAB_PSPACE (SYMBOL_SYMTAB (sym)));
+
 	  values.sals = (struct symtab_and_line *)
 	    xmalloc (sizeof (struct symtab_and_line));
 	  values.nelts = 1;
@@ -1960,6 +1980,8 @@ find_method (struct linespec_state *self, char *saved_arg,
 	    {
 	      if (strcmp_iw (name, SYMBOL_LINKAGE_NAME (sym_arr[i])) == 0)
 		{
+		  set_current_program_space (SYMTAB_PSPACE (SYMBOL_SYMTAB (sym_arr[i])));
+
 		  values.sals = (struct symtab_and_line *)
 		    xmalloc (sizeof (struct symtab_and_line));
 		  values.nelts = 1;
@@ -2054,6 +2076,7 @@ symtab_from_filename (char **argptr, char *p, int is_quote_enclosed,
   char *copy;
   struct symtab_collector collector;
   struct cleanup *cleanups, *outer;
+  struct program_space *pspace;
   
   p1 = p;
   while (p != *argptr && p[-1] == ' ')
@@ -2075,7 +2098,11 @@ symtab_from_filename (char **argptr, char *p, int is_quote_enclosed,
   cleanups = make_cleanup (cleanup_htab, collector.symtab_table);
 
   /* Find that file's data.  */
-  iterate_over_symtabs (copy, add_symtabs_to_list, &collector);
+  ALL_PSPACES (pspace)
+  {
+    set_current_program_space (pspace);
+    iterate_over_symtabs (copy, add_symtabs_to_list, &collector);
+  }
   if (collector.symtabs == NULL)
     {
       if (!have_full_symbols () && !have_partial_symbols ())
@@ -2206,6 +2233,8 @@ decode_all_digits (struct linespec_state *self,
     {
       struct symtab *default_symtab;
 
+      set_current_program_space (self->program_space);
+
       /* Make sure we have at least a default source file.  */
       set_default_source_symtab_and_line ();
       initialize_defaults (&self->default_symtab, &self->default_line);
@@ -2251,6 +2280,8 @@ decode_all_digits (struct linespec_state *self,
       /* The logic above should ensure this.  */
       gdb_assert (elt != NULL);
 
+      set_current_program_space (SYMTAB_PSPACE (elt));
+
       pcs = find_pcs_for_symtab_line (elt, val.line);
       if (pcs == NULL)
 	continue;
@@ -2258,8 +2289,7 @@ decode_all_digits (struct linespec_state *self,
       for (pcix = 0; VEC_iterate (CORE_ADDR, pcs, pcix, pc); ++pcix)
 	{
 	  val.symtab = elt;
-	  val.pspace = (val.symtab ? SYMTAB_PSPACE (val.symtab)
-			: current_program_space);
+	  val.pspace = SYMTAB_PSPACE (val.symtab);
 	  val.pc = pc;
 	  val.explicit_line = 1;
 
@@ -2340,7 +2370,12 @@ decode_dollar (struct linespec_state *self, char *copy)
   for (ix = 0; VEC_iterate (symtab_p, self->file_symtabs, ix, elt); ++ix)
     {
       if (elt == NULL)
-	elt = self->default_symtab;
+	{
+	  elt = self->default_symtab;
+	  set_current_program_space (self->program_space);
+	}
+      else
+	set_current_program_space (SYMTAB_PSPACE (elt));
 
       /* Either history value or convenience value from above, in valx.  */
       val.symtab = elt;
@@ -2379,9 +2414,12 @@ decode_label (struct linespec_state *self,
 
   if (function_symbols == NULL)
     {
-      struct block *block = get_selected_block (0);
+      struct block *block;
       struct symbol *sym;
 
+      set_current_program_space (self->program_space);
+      block = get_selected_block (0);
+
       for (;
 	   block && !BLOCK_FUNCTION (block);
 	   block = BLOCK_SUPERBLOCK (block))
@@ -2403,8 +2441,12 @@ decode_label (struct linespec_state *self,
 
   for (ix = 0; VEC_iterate (symbolp, function_symbols, ix, fn_sym); ++ix)
     {
-      struct block *block = SYMBOL_BLOCK_VALUE (fn_sym);
-      struct symbol *sym = lookup_symbol (copy, block, LABEL_DOMAIN, 0);
+      struct block *block;
+      struct symbol *sym;
+
+      set_current_program_space (SYMTAB_PSPACE (SYMBOL_SYMTAB (fn_sym)));
+      block = SYMBOL_BLOCK_VALUE (fn_sym);
+      sym = lookup_symbol (copy, block, LABEL_DOMAIN, 0);
 
       if (sym != NULL)
 	{
@@ -2420,7 +2462,7 @@ decode_label (struct linespec_state *self,
       self->canonical->pre_expanded = 1;
       self->canonical->special_display = 1;
 
-      if (self->user_filename)
+      if (self->user_function)
 	self->canonical->addr_string
 	  = xstrprintf ("%s:%s", self->user_function, copy);
       else
@@ -2488,9 +2530,12 @@ decode_variable (struct linespec_state *self, char *copy)
 	iterate_over_all_matching_symtabs (lookup_name, VAR_DOMAIN,
 					   collect_symbols, &info);
       else
-	iterate_over_symbols (get_search_block (elt), lookup_name,
-			      VAR_DOMAIN, collect_symbols,
-			      &info);
+	{
+	  set_current_program_space (SYMTAB_PSPACE (elt));
+	  iterate_over_symbols (get_search_block (elt), lookup_name,
+				VAR_DOMAIN, collect_symbols,
+				&info);
+	}
     }
 
   if (info.result.nelts > 0)
diff --git a/gdb/testsuite/gdb.linespec/linespec.exp b/gdb/testsuite/gdb.linespec/linespec.exp
index 4b0e531..af55af5 100644
--- a/gdb/testsuite/gdb.linespec/linespec.exp
+++ b/gdb/testsuite/gdb.linespec/linespec.exp
@@ -58,7 +58,7 @@ gdb_test "break dupname" \
     "multi-location break using duplicate function name"
 
 gdb_test "break dupname:label" \
-    "Breakpoint 3 at $hex: label. \[(\]2 locations\[)\]" \
+    "Breakpoint 3 at $hex: dupname:label. \[(\]2 locations\[)\]" \
     "multi-location break using duplicate function name and label"
 
 gdb_test_no_output "set breakpoint pending off" \
@@ -84,3 +84,23 @@ gdb_test "break lspec.cc:NameSpace::overload(double)" \
 gdb_test "break NameSpace::overload()" \
     "Breakpoint \[0-9\]+ at $hex: NameSpace::overload\\(\\)." \
     "set breakpoint at specific instance of NameSpace::overload"
+
+#
+# Multi-inferior tests.
+#
+
+gdb_test "add-inferior" "Added inferior 2" \
+    "add inferior for linespec tests"
+
+gdb_test "inferior 2" "Switching to inferior 2 .*" \
+    "switch to inferior 2 for linespec tests"
+
+# Note that in particular this should not cause errors when re-setting
+# breakpoints.
+gdb_test "file $binfile" \
+    "Reading symbols from .*done." \
+    "set the new inferior file for linespec tests"
+
+gdb_test "break main" \
+    "Breakpoint \[0-9\]+ at $hex: main. .2 locations." \
+    "set breakpoint at main in both inferiors"


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


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

only message in thread, other threads:[~2011-08-15 17:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-15 17:28 [SCM] archer-tromey-ambiguous-linespec: fix canonicalization buglet in "function:label" support tromey

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).