public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-ambiguous-linespec: add maint print linespec command for debugging
@ 2011-10-27 18:31 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2011-10-27 18:31 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-ambiguous-linespec has been updated
       via  bfaf00b650b34a497553fbf5026a54b715feb645 (commit)
       via  8f9f822c9bc957553915b32272fc14b3a971580e (commit)
       via  9c34e7dddd415f1be3c4311665ffd5b5dde162c4 (commit)
      from  ee645d36d4ab940d15a0c10311420251acdb20bc (commit)

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

- Log -----------------------------------------------------------------
commit bfaf00b650b34a497553fbf5026a54b715feb645
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu Oct 27 12:31:22 2011 -0600

    add maint print linespec command for debugging

commit 8f9f822c9bc957553915b32272fc14b3a971580e
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Oct 26 12:41:16 2011 -0600

    various minor cleanups needed before submission

commit 9c34e7dddd415f1be3c4311665ffd5b5dde162c4
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Oct 26 10:43:42 2011 -0600

    add comment for multiple-symbols=ask behavior

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

Summary of changes:
 gdb/dwarf2read.c |    5 +++
 gdb/linespec.c   |   84 ++++++++++++++++++++++++++++++++++++++++++++++-------
 gdb/psymtab.c    |    5 +++
 gdb/symfile.h    |   18 ++++++------
 gdb/symtab.c     |   11 +++++++
 gdb/utils.c      |    1 +
 6 files changed, 104 insertions(+), 20 deletions(-)

First 500 lines of diff:
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index a6840f6..145c8d0 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2438,6 +2438,9 @@ dw2_forget_cached_source_info (struct objfile *objfile)
 			  dw2_free_cached_file_names, NULL);
 }
 
+/* Helper function for dw2_map_symtabs_matching_filename that expands
+   the symtabs and calls the iterator.  */
+
 static int
 dw2_map_expand_apply (struct objfile *objfile,
 		      struct dwarf2_per_cu_data *per_cu,
@@ -2460,6 +2463,8 @@ dw2_map_expand_apply (struct objfile *objfile,
 				    objfile->symtabs, last_made);
 }
 
+/* Implementation of the map_symtabs_matching_filename method.  */
+
 static int
 dw2_map_symtabs_matching_filename (struct objfile *objfile, const char *name,
 				   const char *full_path, const char *real_path,
diff --git a/gdb/linespec.c b/gdb/linespec.c
index dac4759..c61215b 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -43,6 +43,7 @@
 #include "arch-utils.h"
 #include <ctype.h>
 #include "cli/cli-utils.h"
+#include "gdbcmd.h"
 
 typedef struct symtab *symtab_p;
 DEF_VEC_P (symtab_p);
@@ -109,12 +110,18 @@ struct linespec_state
   htab_t addr_set;
 };
 
+/* This is a helper object that is used when collecting symbols into a
+   result.  */
+
 struct collect_info
 {
+  /* The linespec object in use.  */
   struct linespec_state *state;
+
+  /* The result being accumulated.  */
   struct symtabs_and_lines result;
 
-  /* The current objfile; used only by the minimal symbol code below.  */
+  /* The current objfile; used only by the minimal symbol code.  */
   struct objfile *objfile;
 };
 
@@ -189,6 +196,8 @@ static void add_all_symbol_names_from_pspace (struct collect_info *info,
 
 /* Helper functions.  */
 
+/* Add SAL to SALS.  */
+
 static void
 add_sal_to_sals_basic (struct symtabs_and_lines *sals,
 		       struct symtab_and_line *sal)
@@ -198,6 +207,10 @@ add_sal_to_sals_basic (struct symtabs_and_lines *sals,
   sals->sals[sals->nelts - 1] = *sal;
 }
 
+/* Add SAL to SALS, and also update SELF->CANONICAL_NAMES to reflect
+   the new sal, if needed.  If not NULL, SYMNAME is the name of the
+   symbol to use when constructing the new canonical name.  */
+
 static void
 add_sal_to_sals (struct linespec_state *self,
 		 struct symtabs_and_lines *sals,
@@ -640,6 +653,12 @@ decode_line_2 (struct linespec_state *self,
 	error (_("canceled"));
       else if (num == 1)
 	{
+	  /* We intentionally make this result in a single breakpoint,
+	     contrary to what older versions of gdb did.  The
+	     rationale is that this lets a user get the
+	     multiple_symbols_all behavior even with the 'ask'
+	     setting; and he can get separate breakpoints by entering
+	     "2-57" at the query.  */
 	  do_cleanups (old_chain);
 	  convert_results_to_lsals (self, result);
 	  return;
@@ -1135,6 +1154,8 @@ linespec_state_destructor (void *arg)
   htab_delete (self->addr_set);
 }
 
+/* See linespec.h.  */
+
 void
 decode_line_full (char **argptr, int funfirstline,
 		  struct symtab *default_symtab,
@@ -1760,14 +1781,6 @@ struct decode_compound_collector
   htab_t unique_syms;
 };
 
-/* A cleanup function for an htab_t.  */
-
-static void
-cleanup_htab (void *arg)
-{
-  htab_delete (arg);
-}
-
 /* A callback for iterate_over_symbols that is used by
    lookup_prefix_sym to collect type symbols.  */
 
@@ -1842,7 +1855,7 @@ lookup_prefix_sym (char **argptr, char *p, VEC (symtab_p) *file_symtabs,
   collector.unique_syms = htab_create_alloc (1, htab_hash_pointer,
 					     htab_eq_pointer, NULL,
 					     xcalloc, xfree);
-  cleanup = make_cleanup (cleanup_htab, collector.unique_syms);
+  cleanup = make_cleanup_htab_delete (collector.unique_syms);
 
   for (ix = 0; VEC_iterate (symtab_p, file_symtabs, ix, elt); ++ix)
     {
@@ -2104,7 +2117,7 @@ collect_symtabs_from_filename (const char *file)
   collector.symtabs = NULL;
   collector.symtab_table = htab_create (1, htab_hash_pointer, htab_eq_pointer,
 					NULL);
-  cleanups = make_cleanup (cleanup_htab, collector.symtab_table);
+  cleanups = make_cleanup_htab_delete (collector.symtab_table);
 
   /* Find that file's data.  */
   ALL_PSPACES (pspace)
@@ -2589,6 +2602,8 @@ decode_label (struct linespec_state *self,
   return result->nelts > 0;
 }
 
+/* A callback used to possibly add a symbol to the results.  */
+
 static int
 collect_symbols (struct symbol *sym, void *data)
 {
@@ -2874,3 +2889,50 @@ make_cleanup_destroy_linespec_result (struct linespec_result *ls)
 {
   return make_cleanup (cleanup_linespec_result, ls);
 }
+
+\f
+
+static void
+maint_print_linespec (char *arg, int from_tty)
+{
+  struct linespec_result result;
+  struct cleanup *cleanup;
+  struct linespec_sals *lsal;
+  int i;
+
+  init_linespec_result (&result);
+  cleanup = make_cleanup_destroy_linespec_result (&result);
+
+  decode_line_full (&arg, 0, NULL, 0, &result, multiple_symbols_all, NULL);
+
+  gdb_assert (VEC_length (linespec_sals, result.sals) == 1);
+  lsal = VEC_index (linespec_sals, result.sals, 0);
+
+  printf_filtered (_("Address string: %s\n"), result.addr_string);
+  printf_filtered (_("Canonical form of SAL: %s\n"), lsal->canonical);
+  printf_filtered (_("   note: prologue skipping not done here\n"));
+  for (i = 0; i < lsal->sals.nelts; ++i)
+    {
+      struct symtab_and_line *sal = &lsal->sals.sals[i];
+      
+      printf (_("[%d]  symtab %s\n"), i, (sal->symtab
+					  ? sal->symtab->filename
+					  : _("<no file name>")));
+      printf (_("      line %d, explicit_line %d\n"), sal->line,
+	      sal->explicit_line);
+      printf (_("      PC %s, explicit_pc %d\n"), paddress (get_current_arch (),
+							    sal->pc),
+	      sal->explicit_pc);
+    }
+
+  do_cleanups (cleanup);
+}
+
+void
+_initialize_linespec (void)
+{
+  add_cmd ("linespec", class_maintenance, maint_print_linespec,
+	   _("Decode a linespec and print all the results.\n\
+Usage: maint print linespec LINESPEC"),
+	   &maintenanceprintlist);
+}
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 2fc3fd5..7e74449 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -125,6 +125,9 @@ require_partial_symbols (struct objfile *objfile, int verbose)
   ALL_OBJFILES (objfile)	 \
     ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p)
 
+/* Helper function for partial_map_symtabs_matching_filename that
+   expands the symtabs and calls the iterator.  */
+
 static int
 partial_map_expand_apply (struct objfile *objfile,
 			  const char *name,
@@ -148,6 +151,8 @@ partial_map_expand_apply (struct objfile *objfile,
 				    objfile->symtabs, last_made);
 }
 
+/* Implementation of the map_symtabs_matching_filename method.  */
+
 static int
 partial_map_symtabs_matching_filename (struct objfile *objfile,
 				       const char *name,
diff --git a/gdb/symfile.h b/gdb/symfile.h
index cb22e4b..d45a226 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -152,17 +152,17 @@ struct quick_symbol_functions
   /* Forget all cached full file names for OBJFILE.  */
   void (*forget_cached_source_info) (struct objfile *objfile);
 
-  /* Look up the symbol table, in OBJFILE, of a source file named
-     NAME.  If there is no '/' in the name, a match after a '/' in the
-     symbol table's file name will also work.  FULL_PATH is the
-     absolute file name, and REAL_PATH is the same, run through
-     gdb_realpath.
+  /* Expand and iterate over each "partial" symbol table in OBJFILE
+     where the source file is named NAME.
 
-     If no such symbol table can be found, returns 0.
+     If there is no '/' in the name, a match after a '/' in the symbol
+     table's file name will also work.  FULL_PATH is the absolute file
+     name, and REAL_PATH is the same, run through gdb_realpath.
 
-     Otherwise, sets *RESULT to the symbol table and returns 1.  This
-     might return 1 and set *RESULT to NULL if the requested file is
-     an include file that does not have a symtab of its own.  */
+     If a match is found, the "partial" symbol table is expanded.
+     Then, this calls iterate_over_some_symtabs (or equivalent) over
+     all newly-created symbol tables, passing CALLBACK and DATA to it.
+     The result of this call is returned.  */
   int (*map_symtabs_matching_filename) (struct objfile *objfile,
 					const char *name,
 					const char *full_path,
diff --git a/gdb/symtab.c b/gdb/symtab.c
index eec5478..68b80be 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1815,6 +1815,17 @@ lookup_block_symbol (const struct block *block, const char *name,
     }
 }
 
+/* Iterate over the symbols named NAME, matching DOMAIN, starting with
+   BLOCK.
+   
+   For each symbol that matches, CALLBACK is called.  The symbol and
+   DATA are passed to the callback.
+   
+   If CALLBACK returns zero, the iteration ends.  Otherwise, the
+   search continues.  This function iterates upward through blocks.
+   When the outermost block has been finished, the function
+   returns.  */
+
 void
 iterate_over_symbols (const struct block *block, const char *name,
 		      const domain_enum domain,
diff --git a/gdb/utils.c b/gdb/utils.c
index f874b38..ee96562 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3685,6 +3685,7 @@ compare_positive_ints (const void *ap, const void *bp)
 }
 
 /* String compare function for qsort.  */
+
 int
 compare_strings (const void *arg1, const void *arg2)
 {


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


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

only message in thread, other threads:[~2011-10-27 18:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-27 18:31 [SCM] archer-tromey-ambiguous-linespec: add maint print linespec command for debugging 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).