public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-ambiguous-linespec: reject some minsyms with un-useful types sort of reverts 0d0fafeba297c6c7531d62af313407d92efb8609
@ 2011-10-17 20:26 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2011-10-17 20:26 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-ambiguous-linespec has been updated
       via  2d52015123db39559d5f423d075ff0ba24b6f6c0 (commit)
       via  7cb21f4612a1f63cfebb4f6d29ba92fb8a6284cf (commit)
       via  06e15be71dc1ac523d76d9358ad4f3fa6e10f38b (commit)
       via  baaf3866b5fbb614e15fd2c81e038b10aac87083 (commit)
       via  cf2fa46cf5dda29f67b64aca82e3ae651018e055 (commit)
       via  31551830d4fca8b7a8f78ed4a7f65333c470b0a6 (commit)
      from  5759f8fdd605669534876526146843931d8d7bcc (commit)

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

- Log -----------------------------------------------------------------
commit 2d52015123db39559d5f423d075ff0ba24b6f6c0
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Oct 17 14:25:03 2011 -0600

    reject some minsyms with un-useful types
    sort of reverts 0d0fafeba297c6c7531d62af313407d92efb8609

commit 7cb21f4612a1f63cfebb4f6d29ba92fb8a6284cf
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Oct 17 13:23:29 2011 -0600

    fix sepdebug.exp
    again -- perhaps we should fix the error message in linespec

commit 06e15be71dc1ac523d76d9358ad4f3fa6e10f38b
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Oct 17 12:58:10 2011 -0600

    fix label.exp
    inline relevant part of symbol_found into its only caller;
    remove symbol_found

commit baaf3866b5fbb614e15fd2c81e038b10aac87083
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Oct 17 12:39:42 2011 -0600

    fix included.exp
    this needed a better filtering approach for 'list' and 'edit'

commit cf2fa46cf5dda29f67b64aca82e3ae651018e055
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Oct 17 12:07:10 2011 -0600

    fix expand-psymtabs.exp
    make symtab hash use pointer comparison
    refactor some code to a helper function for reuse

commit 31551830d4fca8b7a8f78ed4a7f65333c470b0a6
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Oct 17 11:38:55 2011 -0600

    rename to symtabs_from_filename; more accurate now

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

Summary of changes:
 gdb/cli/cli-cmds.c                  |   66 +++++++++++-
 gdb/linespec.c                      |  200 +++++++++++++----------------------
 gdb/testsuite/gdb.base/sepdebug.exp |    3 +-
 3 files changed, 138 insertions(+), 131 deletions(-)

First 500 lines of diff:
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 4a8a5ff..80db30c 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1459,27 +1459,83 @@ ambiguous_line_spec (struct symtabs_and_lines *sals)
 		     sals->sals[i].symtab->filename, sals->sals[i].line);
 }
 
-/* Remove any SALs that do not match the current program space.  */
+/* Sort function for filter_sals.  */
+
+static int
+compare_symtabs (const void *a, const void *b)
+{
+  const struct symtab_and_line *sala = a;
+  const struct symtab_and_line *salb = b;
+  int r;
+
+  if (!sala->symtab->dirname)
+    {
+      if (salb->symtab->dirname)
+	return -1;
+    }
+  else if (!salb->symtab->dirname)
+    {
+      if (sala->symtab->dirname)
+	return 1;
+    }
+  else
+    {
+      r = filename_cmp (sala->symtab->dirname, salb->symtab->dirname);
+      if (r)
+	return r;
+    }
+
+  r = filename_cmp (sala->symtab->filename, salb->symtab->filename);
+  if (r)
+    return r;
+
+  if (sala->line < salb->line)
+    return -1;
+  return sala->line == salb->line ? 0 : 1;
+}
+
+/* Remove any SALs that do not match the current program space, or
+   which appear to be "file:line" duplicates.  */
 
 static void
 filter_sals (struct symtabs_and_lines *sals)
 {
-  int i, out;
+  int i, out, prev;
 
   out = 0;
   for (i = 0; i < sals->nelts; ++i)
     {
-      if (sals->sals[i].pspace == current_program_space)
+      if (sals->sals[i].pspace == current_program_space
+	  || sals->sals[i].symtab == NULL)
 	{
 	  sals->sals[out] = sals->sals[i];
 	  ++out;
 	}
     }
+  sals->nelts = out;
 
-  if (out == 0)
-    xfree (sals->sals);
+  qsort (sals->sals, sals->nelts, sizeof (struct symtab_and_line),
+	 compare_symtabs);
 
+  out = 1;
+  prev = 0;
+  for (i = 1; i < sals->nelts; ++i)
+    {
+      if (compare_symtabs (&sals->sals[prev], &sals->sals[i]))
+	{
+	  /* Symtabs differ.  */
+	  sals->sals[out] = sals->sals[i];
+	  prev = out;
+	  ++out;
+	}
+    }
   sals->nelts = out;
+
+  if (sals->nelts == 0)
+    {
+      xfree (sals->sals);
+      sals->sals = NULL;
+    }
 }
 
 static void
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 178e5bd..5a185f0 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -150,9 +150,9 @@ static char *find_toplevel_char (char *s, char c);
 
 static int is_objc_method_format (const char *s);
 
-static VEC (symtab_p) *symtab_from_filename (char **argptr,
-					     char *p, int is_quote_enclosed,
-					     char **user_filename);
+static VEC (symtab_p) *symtabs_from_filename (char **argptr,
+					      char *p, int is_quote_enclosed,
+					      char **user_filename);
 
 static VEC (symbolp) *find_function_symbols (char **argptr, char *p,
 					     int is_quote_enclosed,
@@ -176,12 +176,6 @@ static struct symtabs_and_lines decode_variable (struct linespec_state *self,
 static int symbol_to_sal (struct symtab_and_line *result,
 			  int funfirstline, struct symbol *sym);
 
-static struct
-symtabs_and_lines symbol_found (struct linespec_state *self,
-				char *copy,
-				struct symbol *sym,
-				struct symbol *function_symbol);
-
 static void add_matching_symbols_to_info (const char *name,
 					  struct collect_info *info,
 					  struct program_space *pspace);
@@ -875,8 +869,8 @@ decode_line_internal (struct linespec_state *self, char **argptr)
      symtab and strip the filename from ARGPTR.  */
   TRY_CATCH (file_exception, RETURN_MASK_ERROR)
     {
-      self->file_symtabs = symtab_from_filename (argptr, p, is_quote_enclosed,
-						 &self->user_filename);
+      self->file_symtabs = symtabs_from_filename (argptr, p, is_quote_enclosed,
+						  &self->user_filename);
     }
 
   if (VEC_empty (symtab_p, self->file_symtabs))
@@ -2044,38 +2038,17 @@ find_method (struct linespec_state *self, char *saved_arg,
 
 \f
 
+/* This object is used when collecting all matching symtabs.  */
+
 struct symtab_collector
 {
+  /* The result vector of symtabs.  */
   VEC (symtab_p) *symtabs;
 
+  /* This is used to ensure the symtabs are unique.  */
   htab_t symtab_table;
 };
 
-/* Hash function for a symtab.  */
-
-static hashval_t
-hash_symtab (const void *a)
-{
-  struct symtab *s = (struct symtab *) a;
-  char *fullname;
-
-  fullname = symtab_to_fullname (s);
-  return htab_hash_string (fullname ? fullname : s->filename);
-}
-
-/* Equality function for a symtab.  */
-
-static int
-eq_symtab (const void *a, const void *b)
-{
-  struct symtab *sa = (struct symtab *) a;
-  struct symtab *sb = (struct symtab *) b;
-  char *fa = symtab_to_fullname (sa);
-  char *fb = symtab_to_fullname (sb);
-
-  return strcmp (fa ? fa : sa->filename, fb ? fb : sb->filename) == 0;
-}
-
 /* Callback for iterate_over_symtabs.  */
 
 static int
@@ -2094,18 +2067,43 @@ add_symtabs_to_list (struct symtab *symtab, void *d)
   return 0;
 }
 
-/* Return the symtab associated to the filename given by the substring
-   of *ARGPTR ending at P, and advance ARGPTR past that filename.  */
+/* Given a file name, return a VEC of all matching symtabs.  */
 
 static VEC (symtab_p) *
-symtab_from_filename (char **argptr, char *p, int is_quote_enclosed,
-		      char **user_filename)
+collect_symtabs_from_filename (const char *file)
 {
-  char *p1;
-  char *copy;
   struct symtab_collector collector;
-  struct cleanup *cleanups, *outer;
+  struct cleanup *cleanups;
   struct program_space *pspace;
+
+  collector.symtabs = NULL;
+  collector.symtab_table = htab_create (1, htab_hash_pointer, htab_eq_pointer,
+					NULL);
+  cleanups = make_cleanup (cleanup_htab, collector.symtab_table);
+
+  /* Find that file's data.  */
+  ALL_PSPACES (pspace)
+  {
+    set_current_program_space (pspace);
+    iterate_over_symtabs (file, add_symtabs_to_list, &collector);
+  }
+
+  do_cleanups (cleanups);
+  return collector.symtabs;
+}
+
+/* Return all the symtabs associated to the filename given by the
+   substring of *ARGPTR ending at P, and advance ARGPTR past that
+   filename.  */
+
+static VEC (symtab_p) *
+symtabs_from_filename (char **argptr, char *p, int is_quote_enclosed,
+		       char **user_filename)
+{
+  char *p1;
+  char *copy;
+  struct cleanup *outer;
+  VEC (symtab_p) *result;
   
   p1 = p;
   while (p != *argptr && p[-1] == ' ')
@@ -2122,17 +2120,9 @@ symtab_from_filename (char **argptr, char *p, int is_quote_enclosed,
   else
     copy[p - *argptr] = 0;
 
-  collector.symtabs = NULL;
-  collector.symtab_table = htab_create (1, hash_symtab, eq_symtab, NULL);
-  cleanups = make_cleanup (cleanup_htab, collector.symtab_table);
+  result = collect_symtabs_from_filename (copy);
 
-  /* Find that file's data.  */
-  ALL_PSPACES (pspace)
-  {
-    set_current_program_space (pspace);
-    iterate_over_symtabs (copy, add_symtabs_to_list, &collector);
-  }
-  if (collector.symtabs == NULL)
+  if (VEC_empty (symtab_p, result))
     {
       if (!have_full_symbols () && !have_partial_symbols ())
 	throw_error (NOT_FOUND_ERROR,
@@ -2147,10 +2137,9 @@ symtab_from_filename (char **argptr, char *p, int is_quote_enclosed,
   else
     *argptr = skip_spaces (p1 + 1);
 
-  do_cleanups (cleanups);
   discard_cleanups (outer);
   *user_filename = copy;
-  return collector.symtabs;
+  return result;
 }
 
 /* A callback used by iterate_over_all_matching_symtabs that collects
@@ -2261,15 +2250,15 @@ decode_all_digits (struct linespec_state *self,
   if (VEC_length (symtab_p, self->file_symtabs) == 1
       && VEC_index (symtab_p, self->file_symtabs, 0) == NULL)
     {
-      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);
       VEC_pop (symtab_p, self->file_symtabs);
-      VEC_safe_push (symtab_p, self->file_symtabs, self->default_symtab);
+      VEC_free (symtab_p, self->file_symtabs);
+      self->file_symtabs
+	= collect_symtabs_from_filename (self->default_symtab->filename);
       use_default = 1;
     }
 
@@ -2458,6 +2447,11 @@ decode_label (struct linespec_state *self,
     {
       struct block *block;
       struct symbol *sym;
+      struct symtab_and_line sal;
+      struct symtabs_and_lines values;
+
+      values.nelts = 0;
+      values.sals = NULL;
 
       set_current_program_space (self->program_space);
       block = get_selected_block (0);
@@ -2475,7 +2469,21 @@ decode_label (struct linespec_state *self,
       if (sym == NULL)
 	return 0;
 
-      *result = symbol_found (self, copy, sym, fn_sym);
+      symbol_to_sal (&sal, self->funfirstline, sym);
+      add_sal_to_sals (self, &values, &sal,
+		       SYMBOL_NATURAL_NAME (fn_sym));
+
+      if (self->canonical)
+	{
+	  self->canonical->special_display = 1;
+	  self->canonical->addr_string
+	    /* FIXME? */
+	    = xstrprintf ("%s:%s", SYMBOL_NATURAL_NAME (fn_sym),
+			  copy);
+	}
+
+      *result = values;
+
       return 1;
     }
 
@@ -2581,8 +2589,14 @@ check_minsym (struct minimal_symbol *minsym, void *d)
 {
   struct collect_info *info = d;
 
-  if (maybe_add_address (info->state->addr_set, info->objfile->pspace,
-			 SYMBOL_VALUE_ADDRESS (minsym)))
+  if (MSYMBOL_TYPE (minsym) == mst_unknown
+      || MSYMBOL_TYPE (minsym) == mst_slot_got_plt
+      || MSYMBOL_TYPE (minsym) == mst_solib_trampoline)
+    {
+      /* Reject some odd ones.  */
+    }
+  else if (maybe_add_address (info->state->addr_set, info->objfile->pspace,
+			      SYMBOL_VALUE_ADDRESS (minsym)))
     minsym_found (info->state, info->objfile, minsym, &info->result);
 }
 
@@ -2743,70 +2757,6 @@ symbol_to_sal (struct symtab_and_line *result,
   return 0;
 }
 
-/* We've found a symbol SYM to associate with our linespec; build a
-   corresponding struct symtabs_and_lines.  */
-
-static struct symtabs_and_lines
-symbol_found (struct linespec_state *self, char *copy,
-	      struct symbol *sym, struct symbol *function_symbol)
-{
-  struct symtabs_and_lines values;
-
-  values.nelts = 0;
-  values.sals = NULL;
-  
-  if (SYMBOL_CLASS (sym) == LOC_BLOCK)
-    {
-      struct symtab_and_line sal;
-
-      symbol_to_sal (&sal, self->funfirstline, sym);
-      add_sal_to_sals (self, &values, &sal, SYMBOL_NATURAL_NAME (sym));
-
-      return values;
-    }
-  else
-    {
-      if (SYMBOL_CLASS (sym) == LOC_LABEL && SYMBOL_VALUE_ADDRESS (sym) != 0)
-	{
-	  struct symtab_and_line sal;
-
-	  symbol_to_sal (&sal, self->funfirstline, sym);
-	  add_sal_to_sals (self, &values, &sal,
-			   SYMBOL_NATURAL_NAME (function_symbol));
-
-	  if (self->canonical)
-	    self->canonical->special_display = 1;
-
-	  return values;
-	}
-      else if (self->funfirstline)
-	{
-	  /* NOT_FOUND_ERROR is not correct but it ensures COPY will be
-	     searched also as a minimal symbol.  */
-
-	  throw_error (NOT_FOUND_ERROR, _("\"%s\" is not a function"), copy);
-	}
-      else if (SYMBOL_LINE (sym) != 0)
-	{
-	  struct symtab_and_line sal;
-
-	  symbol_to_sal (&sal, self->funfirstline, sym);
-	  add_sal_to_sals (self, &values, &sal,
-			   SYMBOL_NATURAL_NAME (sym));
-
-	  return values;
-	}
-      else
-	/* This can happen if it is compiled with a compiler which doesn't
-	   put out line numbers for variables.  */
-	/* FIXME: Shouldn't we just set .line and .symtab to zero
-	   and return?  For example, "info line foo" could print
-	   the address.  */
-	/* FIXME: shouldn't this throw NOT_FOUND_ERROR?  */
-	error (_("Line number not known for symbol \"%s\""), copy);
-    }
-}
-
 /* See the comment in linespec.h.  */
 
 void
diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp
index 1a9072d..bb0b914 100644
--- a/gdb/testsuite/gdb.base/sepdebug.exp
+++ b/gdb/testsuite/gdb.base/sepdebug.exp
@@ -337,7 +337,8 @@ gdb_test_multiple "catch exec" $name {
 # on a nonexistent source line.
 #
 
-gdb_test "break 999" "No line 999 in file .*" \
+gdb_test_no_output "set breakpoint pending off"
+gdb_test "break 999" "No line 999 in the current file." \
     "break on non-existent source line"
 
 # Run to the desired default location. If not positioned here, the


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


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

only message in thread, other threads:[~2011-10-17 20:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-17 20:26 [SCM] archer-tromey-ambiguous-linespec: reject some minsyms with un-useful types sort of reverts 0d0fafeba297c6c7531d62af313407d92efb8609 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).