This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFA: Breakpoint infrastructure cleanups [2/8] - chain impl_breakpoints


Chain impl_breakpoints together.  I suspect that the implementation of this
will change in the future with one-to-many, to be something nested like:
  ALL_BREAKPOINTS (user_b)
    ALL_BREAKPOINTS_IMPLS (b, user_b)

But this at least puts the idiom in place, and gives us the macro we'll need
to use when operating on impl breakpoints instead of user breakpoints.  This
patch is exactly parallel to the existing breakpoint chain.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2003-10-08  Daniel Jacobowitz  <drow@mvista.com>

	* breakpoint.h (struct impl_breakpoint): Add a chain pointer.
	* breakpoint.c (ALL_IMPL_BREAKPOINTS, ALL_IMPL_BREAKPOINTS_SAFE): New
	macros.
	(impl_breakpoint_chain): New variable.
	(allocate_impl_breakpoint): New function.
	(set_raw_breakpoint): Use it.
	(delete_breakpoint): Remove ->impl from the impl_breakpoint_chain.

Index: gdb/breakpoint.c
===================================================================
--- gdb.orig/breakpoint.c	2003-10-08 12:42:09.000000000 -0400
+++ gdb/breakpoint.c	2003-10-08 12:42:10.000000000 -0400
@@ -231,6 +231,15 @@ static int overlay_events_enabled;
 	     B ? (TMP=B->next, 1): 0;	\
 	     B = TMP)
 
+/* Similar iterators for the low-level breakpoints.  */
+
+#define ALL_IMPL_BREAKPOINTS(B)  for (B = impl_breakpoint_chain; B; B = B->next)
+
+#define ALL_IMPL_BREAKPOINTS_SAFE(B,TMP)	\
+	for (B = impl_breakpoint_chain;	\
+	     B ? (TMP=B->next, 1): 0;	\
+	     B = TMP)
+
 /* True if SHIFT_INST_REGS defined, false otherwise.  */
 
 int must_shift_inst_regs =
@@ -245,10 +254,12 @@ int must_shift_inst_regs =
 
 int show_breakpoint_hit_counts = 1;
 
-/* Chain of all breakpoints defined.  */
+/* Chains of all breakpoints defined.  */
 
 struct breakpoint *breakpoint_chain;
 
+struct impl_breakpoint *impl_breakpoint_chain;
+
 /* Number of last breakpoint made.  */
 
 int breakpoint_count;
@@ -3840,6 +3851,31 @@ check_duplicates (struct breakpoint *bpt
     }
 }
 
+/* Allocate a struct impl_breakpoint.  */
+
+struct impl_breakpoint *
+allocate_impl_breakpoint (void)
+{
+  struct impl_breakpoint *impl, *impl_p;
+
+  impl = xmalloc (sizeof (struct impl_breakpoint));
+  memset (impl, 0, sizeof (*impl));
+
+  /* Add this breakpoint to the end of the chain.  */
+
+  impl_p = impl_breakpoint_chain;
+  if (impl_p == 0)
+    impl_breakpoint_chain = impl;
+  else
+    {
+      while (impl_p->next)
+	impl_p = impl_p->next;
+      impl_p->next = impl;
+    }
+
+  return impl;
+}
+
 /* set_raw_breakpoint() is a low level routine for allocating and
    partially initializing a breakpoint of type BPTYPE.  The newly
    created breakpoint's address, section, source file name, and line
@@ -3862,8 +3898,7 @@ set_raw_breakpoint (struct symtab_and_li
 
   b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
   memset (b, 0, sizeof (*b));
-  b->impl = (struct impl_breakpoint *) xmalloc (sizeof (struct impl_breakpoint));
-  memset (b->impl, 0, sizeof (*b->impl));
+  b->impl = allocate_impl_breakpoint ();
   b->impl->address = sal.pc;
   if (sal.symtab == NULL)
     b->source_file = NULL;
@@ -6508,6 +6543,7 @@ delete_breakpoint (struct breakpoint *bp
 {
   struct breakpoint *b;
   bpstat bs;
+  struct impl_breakpoint *impl;
 
   if (bpt == NULL)
     error ("Internal error (attempted to delete a NULL breakpoint)");
@@ -6539,6 +6575,9 @@ delete_breakpoint (struct breakpoint *bp
   if (breakpoint_chain == bpt)
     breakpoint_chain = bpt->next;
 
+  if (impl_breakpoint_chain == bpt->impl)
+    impl_breakpoint_chain = bpt->impl->next;
+
   /* If we have callback-style exception catchpoints, don't go through
      the adjustments to the C++ runtime library etc. if the inferior
      isn't actually running.  target_enable_exception_callback for a
@@ -6568,6 +6607,13 @@ delete_breakpoint (struct breakpoint *bp
       break;
     }
 
+  ALL_IMPL_BREAKPOINTS (impl)
+    if (impl->next == bpt->impl)
+      {
+	impl->next = bpt->impl->next;
+	break;
+      }
+
   check_duplicates (bpt);
   /* If this breakpoint was inserted, and there is another breakpoint
      at the same address, we need to insert the other breakpoint.  */
Index: gdb/breakpoint.h
===================================================================
--- gdb.orig/breakpoint.h	2003-10-08 12:42:09.000000000 -0400
+++ gdb/breakpoint.h	2003-10-08 12:42:10.000000000 -0400
@@ -201,6 +201,9 @@ enum impl_bptype
 
 struct impl_breakpoint
 {
+  /* Chain pointer to the next implementation breakpoint.  */
+  struct impl_breakpoint *next;
+
   /* Type of this implementation breakpoint.  */
   enum impl_bptype type;
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]