public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-ambiguous-linespec: introduce decode_line_list, to remove the last list.exp regressions
@ 2011-10-25 20:06 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2011-10-25 20:06 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-ambiguous-linespec has been updated
       via  a0f8da6f9ca688c1c2e389d3be5ef7b502f2f3d4 (commit)
       via  bc67e85961b3aae5c56350650f7d2612bbd477e7 (commit)
      from  29ca9995dc71ddf43093a4cc19a1da533d797a64 (commit)

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

- Log -----------------------------------------------------------------
commit a0f8da6f9ca688c1c2e389d3be5ef7b502f2f3d4
Author: Tom Tromey <tromey@redhat.com>
Date:   Tue Oct 25 14:05:31 2011 -0600

    introduce decode_line_list, to remove the last list.exp regressions

commit bc67e85961b3aae5c56350650f7d2612bbd477e7
Author: Tom Tromey <tromey@redhat.com>
Date:   Tue Oct 25 13:24:47 2011 -0600

    update list.exp for output changes

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

Summary of changes:
 gdb/cli/cli-cmds.c              |    6 ++--
 gdb/linespec.c                  |   70 ++++++++++++++++++++++++++++++--------
 gdb/linespec.h                  |    7 ++++
 gdb/testsuite/gdb.base/list.exp |    2 +-
 4 files changed, 66 insertions(+), 19 deletions(-)

First 500 lines of diff:
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 80db30c..22f3057 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -911,7 +911,7 @@ list_command (char *arg, int from_tty)
     dummy_beg = 1;
   else
     {
-      sals = decode_line_1 (&arg1, 0, 0, 0);
+      sals = decode_line_list (&arg1, 0, 0, 0);
 
       filter_sals (&sals);
       if (!sals.nelts)
@@ -945,9 +945,9 @@ list_command (char *arg, int from_tty)
       else
 	{
 	  if (dummy_beg)
-	    sals_end = decode_line_1 (&arg1, 0, 0, 0);
+	    sals_end = decode_line_list (&arg1, 0, 0, 0);
 	  else
-	    sals_end = decode_line_1 (&arg1, 0, sal.symtab, sal.line);
+	    sals_end = decode_line_list (&arg1, 0, sal.symtab, sal.line);
 	  filter_sals (&sals);
 	  if (sals_end.nelts == 0)
 	    return;
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 758752b..dac4759 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -95,6 +95,9 @@ struct linespec_state
      decode_line_full.  */
   int funfirstline;
 
+  /* Nonzero if we are running in 'list' mode; see decode_line_list.  */
+  int list_mode;
+
   /* The 'canonical' value passed to decode_line_full, or NULL.  */
   struct linespec_result *canonical;
 
@@ -1226,6 +1229,28 @@ decode_line_1 (char **argptr, int funfirstline,
   return result;
 }
 
+/* See linespec.h.  */
+
+struct symtabs_and_lines
+decode_line_list (char **argptr, int funfirstline,
+		  struct symtab *default_symtab,
+		  int default_line)
+{
+  struct symtabs_and_lines result;
+  struct linespec_state state;
+  struct cleanup *cleanups;
+
+  linespec_state_constructor (&state, funfirstline, default_symtab,
+			      default_line, NULL);
+  state.list_mode = 1;
+  cleanups = make_cleanup (linespec_state_destructor, &state);
+  save_current_program_space ();
+
+  result = decode_line_internal (&state, argptr);
+  do_cleanups (cleanups);
+  return result;
+}
+
 \f
 
 /* Now, more helper functions for decode_line_1.  Some conventions
@@ -2295,32 +2320,47 @@ decode_all_digits (struct linespec_state *self,
 
   for (ix = 0; VEC_iterate (symtab_p, self->file_symtabs, ix, elt); ++ix)
     {
-      int pcix;
-      CORE_ADDR pc;
-      VEC (CORE_ADDR) *pcs;
-
       /* 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 (VEC_empty (CORE_ADDR, pcs))
-	continue;
-
-      for (pcix = 0; VEC_iterate (CORE_ADDR, pcs, pcix, pc); ++pcix)
+      if (self->list_mode)
 	{
-	  val.symtab = elt;
-	  val.pspace = SYMTAB_PSPACE (val.symtab);
-	  val.pc = pc;
+	  /* Simplistic search just for the list command.  */
+	  val.symtab = find_line_symtab (elt, val.line, NULL, NULL);
+	  if (val.symtab == NULL)
+	    val.symtab = elt;
+	  val.pspace = SYMTAB_PSPACE (elt);
+	  val.pc = 0;
 	  val.explicit_line = 1;
 
-	  skip_prologue_sal (&val);
-
 	  add_sal_to_sals (self, &values, &val, NULL);
 	}
+      else
+	{
+	  int pcix;
+	  CORE_ADDR pc;
+	  VEC (CORE_ADDR) *pcs;
 
-      VEC_free (CORE_ADDR, pcs);
+	  pcs = find_pcs_for_symtab_line (elt, val.line);
+	  if (VEC_empty (CORE_ADDR, pcs))
+	    continue;
+
+	  for (pcix = 0; VEC_iterate (CORE_ADDR, pcs, pcix, pc); ++pcix)
+	    {
+	      val.symtab = elt;
+	      val.pspace = SYMTAB_PSPACE (val.symtab);
+	      val.pc = pc;
+	      val.explicit_line = 1;
+
+	      skip_prologue_sal (&val);
+
+	      add_sal_to_sals (self, &values, &val, NULL);
+	    }
+
+	  VEC_free (CORE_ADDR, pcs);
+	}
     }
 
   if (values.nelts == 0)
diff --git a/gdb/linespec.h b/gdb/linespec.h
index fe78b9e..bd9fa14 100644
--- a/gdb/linespec.h
+++ b/gdb/linespec.h
@@ -81,6 +81,13 @@ extern struct symtabs_and_lines
 	decode_line_1 (char **argptr, int funfirstline,
 		       struct symtab *default_symtab, int default_line);
 
+/* Like decode_line_1, but useful only for the 'list' command.  With
+   this variant, a "file:line" linespec will always return a result.  */
+
+extern struct symtabs_and_lines
+	decode_line_list (char **argptr, int funfirstline,
+			  struct symtab *default_symtab, int default_line);
+
 /* Parse *ARGPTR as a linespec and return results.  This is the "full"
    interface to this module, which handles multiple results
    properly.
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 5b9fe15..d4935ee 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -489,7 +489,7 @@ proc test_list_filename_and_function {} {
 
     gdb_test "list foobar.c:main" "No source file named foobar.c.|Location not found" "list filename:function; nonexistant file"
 
-    gdb_test "list list0.h:foobar" "Function \"foobar\" not defined.|Location not found" "list filename:function; nonexistant function"
+    gdb_test "list list0.h:foobar" "Function \"foobar\" not defined in \"list0.h\"." "list filename:function; nonexistant function"
 
 }
 


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


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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-25 20:06 [SCM] archer-tromey-ambiguous-linespec: introduce decode_line_list, to remove the last list.exp regressions 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).