public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-ambiguous-linespec: make "break function" work when "function" is ambiguous adds addr_string to the linespec result so that we don't just pick the first canonical form
@ 2011-08-03 14:30 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2011-08-03 14:30 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-ambiguous-linespec has been updated
       via  08c801ec3b550dc84aaf57798b327dbc84417509 (commit)
      from  22f6851aae5dff720e202b0c91344e75114a3ead (commit)

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

- Log -----------------------------------------------------------------
commit 08c801ec3b550dc84aaf57798b327dbc84417509
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Aug 3 08:30:12 2011 -0600

    make "break function" work when "function" is ambiguous
    adds addr_string to the linespec result so that we don't just
    pick the first canonical form

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

Summary of changes:
 gdb/breakpoint.c |    6 +++-
 gdb/linespec.c   |   74 ++++++++++++++++++++++++++++++++++++++++++++++-------
 gdb/linespec.h   |    5 +++
 3 files changed, 74 insertions(+), 11 deletions(-)

First 500 lines of diff:
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 0085fc0..b10c5c1 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -7410,7 +7410,9 @@ create_breakpoints_sal (struct gdbarch *gdbarch,
 
   if (canonical->pre_expanded)
     {
-      create_breakpoint_sal (gdbarch, sals, canonical->canonical[0],
+      gdb_assert (canonical->addr_string != NULL);
+
+      create_breakpoint_sal (gdbarch, sals, canonical->addr_string,
 			     cond_string, type, disposition,
 			     thread, task, ignore_count, ops,
 			     from_tty, enabled, internal,
@@ -7418,6 +7420,8 @@ create_breakpoints_sal (struct gdbarch *gdbarch,
       return;
     }
 
+  gdb_assert (canonical->addr_string == NULL);
+
   for (i = 0; i < sals.nelts; ++i)
     {
       struct symtabs_and_lines expanded = 
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 68634e7..8e79eee 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -118,7 +118,8 @@ symtabs_and_lines decode_all_digits (char **argptr,
 				     int default_line,
 				     struct linespec_result *canonical,
 				     VEC (symtab_p) *file_symtabs,
-				     char *q);
+				     char *q,
+				     const char *user_filename);
 
 static struct symtabs_and_lines decode_dollar (char *copy,
 					       int funfirstline,
@@ -1046,7 +1047,8 @@ decode_line_internal (char **argptr, int funfirstline,
   if (q != *argptr && (*q == 0 || *q == ' ' || *q == '\t' || *q == ',')
       && function_symbol == NULL)
     /* We found a token consisting of all digits -- at least one digit.  */
-    return decode_all_digits (argptr, default_line, canonical, file_symtabs, q);
+    return decode_all_digits (argptr, default_line, canonical, file_symtabs, q,
+			      user_filename);
 
   /* Arg token is not digits => try it as a variable name
      Find the next token (everything up to end or next whitespace).  */
@@ -2032,7 +2034,8 @@ find_function_symbol (char **argptr, char *p, int is_quote_enclosed)
 static struct symtabs_and_lines
 decode_all_digits (char **argptr,
 		   int default_line, struct linespec_result *canonical,
-		   VEC (symtab_p) *file_symtabs, char *q)
+		   VEC (symtab_p) *file_symtabs, char *q,
+		   const char *user_filename)
 
 {
   struct symtabs_and_lines values;
@@ -2054,7 +2057,22 @@ decode_all_digits (char **argptr,
   values.nelts = 0;
 
   if (canonical)
-    canonical->pre_expanded = 1;
+    {
+      int len = q - *argptr;
+      char *copy = xmalloc (len + 1);
+
+      canonical->pre_expanded = 1;
+
+      memcpy (copy, *argptr, len);
+      copy[len] = '\0';
+      if (user_filename)
+	{
+	  canonical->addr_string = xstrprintf ("%s:%s", user_filename, copy);
+	  xfree (copy);
+	}
+      else
+	canonical->addr_string = copy;
+    }
 
   /* This is where we need to make sure that we have good defaults.
      We must guarantee that this section of code is never executed
@@ -2281,6 +2299,34 @@ collect_symbols (struct symbol *sym, void *data)
   return 1;
 }
 
+/* A helper for decode_variable that walks over all matching symtabs
+   in all objfiles.  */
+
+static void
+iterate_over_all_matching_symtabs (const char *name,
+				   const domain_enum domain,
+				   int (*callback) (struct symbol *, void *),
+				   void *data)
+{
+  struct objfile *objfile;
+
+  ALL_OBJFILES (objfile)
+  {
+    struct symtab *symtab;
+
+    if (objfile->sf)
+      objfile->sf->qf->expand_symtabs_for_function (objfile, name);
+
+    ALL_OBJFILE_SYMTABS (objfile, symtab)
+      {
+	struct block *block;
+
+	block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
+	iterate_over_symbols (block, name, domain, callback, data);
+      }
+  }
+}
+
 /* Decode a linespec that's a variable.  If FILE_SYMTAB is non-NULL,
    look in that symtab's static variables first.  */ 
 
@@ -2309,17 +2355,25 @@ decode_variable (char *copy, int funfirstline,
     {
       struct symbol *sym;
 
-      elt = maybe_use_global_symtab (elt);
-
-      iterate_over_symbols (get_search_block (elt), lookup_name,
-			    VAR_DOMAIN, collect_symbols,
-			    &info);
+      if (elt == NULL)
+	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);
     }
 
   if (info.result.nelts > 0)
     {
       if (canonical)
-	canonical->pre_expanded = 1;
+	{
+	  canonical->pre_expanded = 1;
+	  if (user_filename)
+	    canonical->addr_string = xstrprintf ("%s:%s", user_filename, copy);
+	  else
+	    canonical->addr_string = xstrdup (copy);
+	}
       build_canonical_line_spec (&info.result, copy, canonical);
       return info.result;
     }
diff --git a/gdb/linespec.h b/gdb/linespec.h
index 23c917b..53e8ac4 100644
--- a/gdb/linespec.h
+++ b/gdb/linespec.h
@@ -34,6 +34,11 @@ struct linespec_result
      "pre-expanded" multi-location linespec.  */
   int pre_expanded;
 
+  /* If PRE_EXPANDED is non-NULL, this is set to the linespec entered
+     by the user.  This is allocated with xmalloc and the caller is
+     responsible for freeing it.  */
+  char *addr_string;
+
   /* If non-NULL, an array of canonical names for returned
      symtab_and_line objects.  The array has as many elements as the
      `nelts' field in the symtabs_and_line returned by decode_line_1.


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


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

only message in thread, other threads:[~2011-08-03 14:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-03 14:30 [SCM] archer-tromey-ambiguous-linespec: make "break function" work when "function" is ambiguous adds addr_string to the linespec result so that we don't just pick the first canonical form 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).