public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-ambiguous-linespec: make multiple-symbols=ask work reasonably in the new model this breaks ranged breakpoints completely, I #if'd them out
@ 2011-08-25 16:49 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2011-08-25 16:49 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-ambiguous-linespec has been updated
       via  6bbd36b44ecd5c6d48e774df0f1d3d00a3a82a39 (commit)
       via  a71e739ae46e9736a1599771bb6578da9b42a4dc (commit)
       via  2037f2cc8d9365280aab4e935ab0493d8ee3c8e3 (commit)
      from  23b786b79fe41fef568c7638947716b59b439cd0 (commit)

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

- Log -----------------------------------------------------------------
commit 6bbd36b44ecd5c6d48e774df0f1d3d00a3a82a39
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu Aug 25 10:30:14 2011 -0600

    make multiple-symbols=ask work reasonably in the new model
    this breaks ranged breakpoints completely, I #if'd them out

commit a71e739ae46e9736a1599771bb6578da9b42a4dc
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Aug 22 14:44:31 2011 -0600

    remove unused argument from symbol_found

commit 2037f2cc8d9365280aab4e935ab0493d8ee3c8e3
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Aug 22 14:36:34 2011 -0600

    consolidate computation of canonical linespecs

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

Summary of changes:
 gdb/breakpoint.c |  254 ++++++++++++------------
 gdb/breakpoint.h |    5 +
 gdb/linespec.c   |  585 ++++++++++++++++++++++++++++++------------------------
 gdb/linespec.h   |   88 +++++++--
 4 files changed, 531 insertions(+), 401 deletions(-)

First 500 lines of diff:
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index d72bba6..77fb092 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -7122,7 +7122,7 @@ bp_loc_is_permanent (struct bp_location *loc)
 static void
 init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
 		     struct symtabs_and_lines sals, char *addr_string,
-		     char *cond_string,
+		     char *filter, char *cond_string,
 		     enum bptype type, enum bpdisp disposition,
 		     int thread, int task, int ignore_count,
 		     const struct breakpoint_ops *ops, int from_tty,
@@ -7242,12 +7242,13 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
        me.  */
     b->addr_string
       = xstrprintf ("*%s", paddress (b->loc->gdbarch, b->loc->address));
+  b->filter = filter;
 }
 
 static void
 create_breakpoint_sal (struct gdbarch *gdbarch,
 		       struct symtabs_and_lines sals, char *addr_string,
-		       char *cond_string,
+		       char *filter, char *cond_string,
 		       enum bptype type, enum bpdisp disposition,
 		       int thread, int task, int ignore_count,
 		       const struct breakpoint_ops *ops, int from_tty,
@@ -7270,7 +7271,7 @@ create_breakpoint_sal (struct gdbarch *gdbarch,
 
   init_breakpoint_sal (b, gdbarch,
 		       sals, addr_string,
-		       cond_string,
+		       filter, cond_string,
 		       type, disposition,
 		       thread, task, ignore_count,
 		       ops, from_tty,
@@ -7429,7 +7430,6 @@ expand_line_sal_maybe (struct symtab_and_line sal)
 
 static void
 create_breakpoints_sal (struct gdbarch *gdbarch,
-			struct symtabs_and_lines sals,
 			struct linespec_result *canonical,
 			char *cond_string,
 			enum bptype type, enum bpdisp disposition,
@@ -7438,31 +7438,26 @@ create_breakpoints_sal (struct gdbarch *gdbarch,
 			int enabled, int internal)
 {
   int i;
+  struct linespec_sals *lsal;
 
   if (canonical->pre_expanded)
-    {
-      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,
-			     canonical->special_display);
-      return;
-    }
-
-  gdb_assert (canonical->addr_string == NULL);
+    gdb_assert (VEC_length (linespec_sals, canonical->sals) == 1);
 
-  for (i = 0; i < sals.nelts; ++i)
+  for (i = 0; VEC_iterate (linespec_sals, canonical->sals, i, lsal); ++i)
     {
-      struct symtabs_and_lines expanded = 
-	expand_line_sal_maybe (sals.sals[i]);
+      char *addr_string = xstrdup (canonical->addr_string);
+      char *filter_string = xstrdup (lsal->canonical);
+      struct cleanup *inner = make_cleanup (xfree, addr_string);
 
-      create_breakpoint_sal (gdbarch, expanded, canonical->canonical[i],
+      make_cleanup (xfree, filter_string);
+      create_breakpoint_sal (gdbarch, lsal->sals,
+			     addr_string,
+			     filter_string,
 			     cond_string, type, disposition,
 			     thread, task, ignore_count, ops,
 			     from_tty, enabled, internal,
 			     canonical->special_display);
+      discard_cleanups (inner);
     }
 }
 
@@ -7476,7 +7471,6 @@ create_breakpoints_sal (struct gdbarch *gdbarch,
 
 static void
 parse_breakpoint_sals (char **address,
-		       struct symtabs_and_lines *sals,
 		       struct linespec_result *canonical)
 {
   char *addr_start = *address;
@@ -7488,10 +7482,11 @@ parse_breakpoint_sals (char **address,
     {
       if (default_breakpoint_valid)
 	{
+	  struct linespec_sals lsal;
 	  struct symtab_and_line sal;
 
 	  init_sal (&sal);		/* Initialize to zeroes.  */
-	  sals->sals = (struct symtab_and_line *)
+	  lsal.sals.sals = (struct symtab_and_line *)
 	    xmalloc (sizeof (struct symtab_and_line));
 	  sal.pc = default_breakpoint_address;
 	  sal.line = default_breakpoint_line;
@@ -7506,8 +7501,11 @@ parse_breakpoint_sals (char **address,
 	     with the same symtab and line.  */
 	  sal.explicit_pc = 1;
 
-	  sals->sals[0] = sal;
-	  sals->nelts = 1;
+	  lsal.sals.sals[0] = sal;
+	  lsal.sals.nelts = 1;
+	  lsal.canonical = NULL;
+
+	  VEC_safe_push (linespec_sals, canonical->sals, &lsal);
 	}
       else
 	error (_("No default breakpoint address now."));
@@ -7528,26 +7526,12 @@ parse_breakpoint_sals (char **address,
 	  && (!cursal.symtab
  	      || ((strchr ("+-", (*address)[0]) != NULL)
  		  && ((*address)[1] != '['))))
-	*sals = decode_line_full (address, 1, default_breakpoint_symtab,
-				  default_breakpoint_line, canonical);
+	decode_line_full (address, 1, default_breakpoint_symtab,
+			  default_breakpoint_line, canonical,
+			  NULL, NULL);
       else
-	*sals = decode_line_full (address, 1, (struct symtab *) NULL, 0,
-				  canonical);
-    }
-  /* For any SAL that didn't have a canonical string, fill one in.  */
-  if (sals->nelts > 0 && canonical->canonical == NULL)
-    canonical->canonical = xcalloc (sals->nelts, sizeof (char *));
-  if (addr_start != (*address))
-    {
-      int i;
-
-      for (i = 0; i < sals->nelts; i++)
-	{
-	  /* Add the string if not present.  */
-	  if (canonical->canonical[i] == NULL)
-	    canonical->canonical[i] = savestring (addr_start, 
-						  (*address) - addr_start);
-	}
+	decode_line_full (address, 1, (struct symtab *) NULL, 0,
+			  canonical, NULL, NULL);
     }
 }
 
@@ -7732,8 +7716,6 @@ create_breakpoint (struct gdbarch *gdbarch,
 		   int from_tty, int enabled, int internal)
 {
   volatile struct gdb_exception e;
-  struct symtabs_and_lines sals;
-  struct symtab_and_line pending_sal;
   char *copy_arg;
   char *addr_start = arg;
   struct linespec_result canonical;
@@ -7746,26 +7728,26 @@ create_breakpoint (struct gdbarch *gdbarch,
 
   gdb_assert (ops != NULL);
 
-  sals.sals = NULL;
-  sals.nelts = 0;
   init_linespec_result (&canonical);
 
   if (type_wanted == bp_static_tracepoint && is_marker_spec (arg))
     {
       int i;
+      struct linespec_sals lsal;
 
-      sals = decode_static_tracepoint_spec (&arg);
+      lsal.sals = decode_static_tracepoint_spec (&arg);
 
       copy_arg = savestring (addr_start, arg - addr_start);
-      canonical.canonical = xcalloc (sals.nelts, sizeof (char *));
-      for (i = 0; i < sals.nelts; i++)
-	canonical.canonical[i] = xstrdup (copy_arg);
+
+      lsal.canonical = xstrdup (copy_arg);
+      VEC_safe_push (linespec_sals, canonical.sals, &lsal);
+
       goto done;
     }
 
   TRY_CATCH (e, RETURN_MASK_ALL)
     {
-      parse_breakpoint_sals (&arg, &sals, &canonical);
+      parse_breakpoint_sals (&arg, &canonical);
     }
 
   /* If caller is interested in rc value from parse, set value.  */
@@ -7797,35 +7779,31 @@ create_breakpoint (struct gdbarch *gdbarch,
 	     a pending breakpoint and selected yes, or pending
 	     breakpoint behavior is on and thus a pending breakpoint
 	     is defaulted on behalf of the user.  */
-	  copy_arg = xstrdup (addr_start);
-	  canonical.canonical = &copy_arg;
-	  sals.nelts = 1;
-	  sals.sals = &pending_sal;
-	  pending_sal.pc = 0;
-	  pending = 1;
+	  {
+	    struct linespec_sals lsal;
+
+	    copy_arg = xstrdup (addr_start);
+	    lsal.canonical = xstrdup (copy_arg);
+	    lsal.sals.nelts = 1;
+	    lsal.sals.sals = XNEW (struct symtab_and_line);
+	    init_sal (&lsal.sals.sals[0]);
+	    pending = 1;
+	    VEC_safe_push (linespec_sals, canonical.sals, &lsal);
+	  }
 	  break;
 	default:
 	  throw_exception (e);
 	}
       break;
     default:
-      if (!sals.nelts)
+      if (VEC_empty (linespec_sals, canonical.sals))
 	return 0;
     }
 
   done:
 
   /* Create a chain of things that always need to be cleaned up.  */
-  old_chain = make_cleanup (null_cleanup, 0);
-
-  if (!pending)
-    {
-      /* Make sure that all storage allocated to SALS gets freed.  */
-      make_cleanup (xfree, sals.sals);
-      
-      /* Cleanup the canonical array but not its contents.  */
-      make_cleanup (xfree, canonical.canonical);
-    }
+  old_chain = make_cleanup_destroy_linespec_result (&canonical);
 
   /* ----------------------------- SNIP -----------------------------
      Anything added to the cleanup chain beyond this point is assumed
@@ -7833,28 +7811,37 @@ create_breakpoint (struct gdbarch *gdbarch,
      then the memory is not reclaimed.  */
   bkpt_chain = make_cleanup (null_cleanup, 0);
 
-  /* Mark the contents of the canonical for cleanup.  These go on
-     the bkpt_chain and only occur if the breakpoint create fails.  */
-  for (i = 0; i < sals.nelts; i++)
-    {
-      if (canonical.canonical[i] != NULL)
-	make_cleanup (xfree, canonical.canonical[i]);
-    }
-
   /* Resolve all line numbers to PC's and verify that the addresses
      are ok for the target.  */
   if (!pending)
-    breakpoint_sals_to_pc (&sals);
+    {
+      int ix;
+      struct linespec_sals *iter;
+
+      for (ix = 0; VEC_iterate (linespec_sals, canonical.sals, ix, iter); ++ix)
+	breakpoint_sals_to_pc (&iter->sals);
+    }
 
   /* Fast tracepoints may have additional restrictions on location.  */
   if (type_wanted == bp_fast_tracepoint)
-    check_fast_tracepoint_sals (gdbarch, &sals);
+    {
+      int ix;
+      struct linespec_sals *iter;
+
+      for (ix = 0; VEC_iterate (linespec_sals, canonical.sals, ix, iter); ++ix)
+	/* FIXME gdbarch */
+	check_fast_tracepoint_sals (gdbarch, &iter->sals);
+    }
 
   /* Verify that condition can be parsed, before setting any
      breakpoints.  Allocate a separate condition expression for each
      breakpoint.  */
   if (!pending)
     {
+      struct linespec_sals *lsal;
+
+      lsal = VEC_index (linespec_sals, canonical.sals, 0);
+
       if (parse_condition_and_thread)
         {
             /* Here we only parse 'arg' to separate condition
@@ -7863,7 +7850,7 @@ create_breakpoint (struct gdbarch *gdbarch,
                re-parse it in context of each sal.  */
             cond_string = NULL;
             thread = -1;
-            find_condition_and_thread (arg, sals.sals[0].pc, &cond_string,
+            find_condition_and_thread (arg, lsal->sals.sals[0].pc, &cond_string,
                                        &thread, &task);
             if (cond_string)
                 make_cleanup (xfree, cond_string);
@@ -7885,24 +7872,26 @@ create_breakpoint (struct gdbarch *gdbarch,
 	 expand multiple locations for each sal, given than SALS
 	 already should contain all sals for MARKER_ID.  */
       if (type_wanted == bp_static_tracepoint
-	  && is_marker_spec (canonical.canonical[0]))
+	  && is_marker_spec (lsal->canonical))
 	{
 	  int i;
 
-	  for (i = 0; i < sals.nelts; ++i)
+	  for (i = 0; i < lsal->sals.nelts; ++i)
 	    {
 	      struct symtabs_and_lines expanded;
 	      struct tracepoint *tp;
 	      struct cleanup *old_chain;
+	      char *addr_string;
 
 	      expanded.nelts = 1;
-	      expanded.sals = xmalloc (sizeof (struct symtab_and_line));
-	      expanded.sals[0] = sals.sals[i];
-	      old_chain = make_cleanup (xfree, expanded.sals);
+	      expanded.sals = &lsal->sals.sals[i];
+
+	      addr_string = xstrdup (canonical.addr_string);
+	      old_chain = make_cleanup (xfree, addr_string);
 
 	      tp = XCNEW (struct tracepoint);
 	      init_breakpoint_sal (&tp->base, gdbarch, expanded,
-				   canonical.canonical[i],
+				   addr_string, NULL,
 				   cond_string, type_wanted,
 				   tempflag ? disp_del : disp_donttouch,
 				   thread, task, ignore_count, ops,
@@ -7918,11 +7907,11 @@ create_breakpoint (struct gdbarch *gdbarch,
 
 	      install_breakpoint (internal, &tp->base);
 
-	      do_cleanups (old_chain);
+	      discard_cleanups (old_chain);
 	    }
 	}
       else
-	create_breakpoints_sal (gdbarch, sals, &canonical, cond_string,
+	create_breakpoints_sal (gdbarch, &canonical, cond_string,
 				type_wanted,
 				tempflag ? disp_del : disp_donttouch,
 				thread, task, ignore_count, ops, from_tty,
@@ -7937,7 +7926,7 @@ create_breakpoint (struct gdbarch *gdbarch,
       b = set_raw_breakpoint_without_location (gdbarch, type_wanted, ops);
       set_breakpoint_number (internal, b);
       b->thread = -1;
-      b->addr_string = canonical.canonical[0];
+      b->addr_string = copy_arg;
       b->cond_string = NULL;
       b->ignore_count = ignore_count;
       b->disposition = tempflag ? disp_del : disp_donttouch;
@@ -7958,7 +7947,7 @@ create_breakpoint (struct gdbarch *gdbarch,
       observer_notify_breakpoint_created (b);
     }
   
-  if (sals.nelts > 1 && !canonical.pre_expanded)
+  if (VEC_length (linespec_sals, canonical.sals) > 1)
     {
       warning (_("Multiple breakpoints were set.\nUse the "
 		 "\"delete\" command to delete unwanted breakpoints."));
@@ -8339,8 +8328,8 @@ break_range_command (char *arg, int from_tty)
   CORE_ADDR end;
   struct breakpoint *b;
   struct symtab_and_line sal_start, sal_end;
-  struct symtabs_and_lines sals_start, sals_end;
   struct cleanup *cleanup_bkpt;
+  struct linespec_sals *lsal_start;
 
   /* We don't support software ranged breakpoints.  */
   if (target_ranged_break_num_registers () < 0)
@@ -8356,26 +8345,30 @@ break_range_command (char *arg, int from_tty)
   if (arg == NULL || arg[0] == '\0')
     error(_("No address range specified."));
 
-  sals_start.sals = NULL;
-  sals_start.nelts = 0;
   init_linespec_result (&canonical_start);
 
   while (*arg == ' ' || *arg == '\t')
     arg++;
 
-  parse_breakpoint_sals (&arg, &sals_start, &canonical_start);
+  parse_breakpoint_sals (&arg, &canonical_start);
 
-  sal_start = sals_start.sals[0];
-  addr_string_start = canonical_start.canonical[0];
-  cleanup_bkpt = make_cleanup (xfree, addr_string_start);
-  xfree (sals_start.sals);
-  xfree (canonical_start.canonical);
+  /* FIXME: cleanups here  */
+  cleanup_bkpt = make_cleanup (null_cleanup, NULL); /* FIXME */
+  /* cleanup_bkpt = make_cleanup (xfree, addr_string_start); */
+  /* xfree (sals_start.sals); */
+  /* xfree (canonical_start.canonical); */
 
   if (arg[0] != ',')
     error (_("Too few arguments."));
-  else if (sals_start.nelts == 0)
+  else if (VEC_empty (linespec_sals, canonical_start.sals))
     error (_("Could not find location of the beginning of the range."));
-  else if (sals_start.nelts != 1)
+
+  lsal_start = VEC_index (linespec_sals, canonical_start.sals, 0); /* FIXME */
+  sal_start = lsal_start->sals.sals[0]; /* FIXME */
+  addr_string_start = lsal_start->canonical; /* FIXME? */
+
+  if (VEC_length (linespec_sals, canonical_start.sals) > 1
+      || lsal_start->sals.nelts != 1)
     error (_("Cannot create a ranged breakpoint with multiple locations."));
 
   resolve_sal_pc (&sal_start);
@@ -8386,8 +8379,6 @@ break_range_command (char *arg, int from_tty)
 
   /* Parse the end location.  */
 
-  sals_end.sals = NULL;
-  sals_end.nelts = 0;
   init_linespec_result (&canonical_end);
   arg_start = arg;
 
@@ -8396,8 +8387,13 @@ break_range_command (char *arg, int from_tty)
      symtab and line as the default symtab and line for the end of the
      range.  This makes it possible to have ranges like "foo.c:27, +14",
      where +14 means 14 lines from the start location.  */
-  sals_end = decode_line_full (&arg, 1, sal_start.symtab, sal_start.line,
-			       &canonical_end);
+  decode_line_full (&arg, 1, sal_start.symtab, sal_start.line,
+		    &canonical_end, NULL, NULL);
+
+#if 1
+  error ("Hey, I didn't fix this yet");
+
+#else
 
   /* canonical_end can be NULL if it was of the form "*0xdeadbeef".  */
   if (canonical_end.canonical == NULL)
@@ -8453,6 +8449,7 @@ break_range_command (char *arg, int from_tty)
   mention (b);
   observer_notify_breakpoint_created (b);
   update_global_location_list (1);
+#endif
 }
 
 /*  Return non-zero if EXP is verified as constant.  Returned zero
@@ -10739,6 +10736,7 @@ base_breakpoint_dtor (struct breakpoint *self)
   decref_counted_command_line (&self->commands);
   xfree (self->cond_string);
   xfree (self->addr_string);
+  xfree (self->filter);
   xfree (self->addr_string_range_end);
 }
 
@@ -11739,14 +11737,12 @@ update_breakpoint_locations (struct breakpoint *b,
    On return, FOUND will be 1 if any SaL was found, zero otherwise.  */
 
 static struct symtabs_and_lines
-addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found,
-		     int *pre_expanded)
+addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found)
 {
   char *s;
   int marker_spec;
   struct symtabs_and_lines sals = {0};
-  struct gdb_exception e;
-  int my_pre_expanded = 0;
+  volatile struct gdb_exception e;
 
   s = addr_string;
   marker_spec = b->type == bp_static_tracepoint && is_marker_spec (s);
@@ -11758,6 +11754,7 @@ addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found,
 	  struct tracepoint *tp = (struct tracepoint *) b;
 
 	  sals = decode_static_tracepoint_spec (&s);
+	  /* FIXME wrong cleanups in the caller here.  */
 	  if (sals.nelts > tp->static_trace_marker_id_idx)
 	    {
 	      sals.sals[0] = sals.sals[tp->static_trace_marker_id_idx];
@@ -11771,22 +11768,25 @@ addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found,
 	  struct linespec_result canonical;
 
 	  init_linespec_result (&canonical);
-	  sals = decode_line_full (&s, 1, (struct symtab *) NULL, 0,
-				   &canonical);
+	  decode_line_full (&s, 1, (struct symtab *) NULL, 0,
+			    &canonical, multiple_symbols_all,
+			    b->filter);
 
-	  /* We don't need the contents.  */
-	  if (canonical.canonical)
+	  /* We should get 0 or 1 resulting SALs.  */
+	  gdb_assert (VEC_length (linespec_sals, canonical.sals) < 2);


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


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

only message in thread, other threads:[~2011-08-25 16:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-25 16:49 [SCM] archer-tromey-ambiguous-linespec: make multiple-symbols=ask work reasonably in the new model this breaks ranged breakpoints completely, I #if'd them out 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).