* breakpoint.h (struct bp_location): Add a chain pointer.
authorDaniel Jacobowitz <drow@false.org>
Thu, 6 Nov 2003 17:26:18 +0000 (17:26 +0000)
committerDaniel Jacobowitz <drow@false.org>
Thu, 6 Nov 2003 17:26:18 +0000 (17:26 +0000)
* breakpoint.c (ALL_BP_LOCATIONS, ALL_BP_LOCATIONS_SAFE): New
macros.
(bp_location_chain): New variable.
(allocate_bp_location): New function.
(set_raw_breakpoint): Use it.
(delete_breakpoint): Remove ->loc from the bp_location_chain.

gdb/ChangeLog
gdb/breakpoint.c
gdb/breakpoint.h

index d340c55590403fe3d6d1e62964cc0be5722f1c6c..787caa9fa0124ad78aa96cbf26757f4a188e2969 100644 (file)
@@ -1,3 +1,13 @@
+2003-11-06  Daniel Jacobowitz  <drow@mvista.com>
+
+       * breakpoint.h (struct bp_location): Add a chain pointer.
+       * breakpoint.c (ALL_BP_LOCATIONS, ALL_BP_LOCATIONS_SAFE): New
+       macros.
+       (bp_location_chain): New variable.
+       (allocate_bp_location): New function.
+       (set_raw_breakpoint): Use it.
+       (delete_breakpoint): Remove ->loc from the bp_location_chain.
+
 2003-11-06  Daniel Jacobowitz  <drow@mvista.com>
 
        * breakpoint.h (enum bp_loc_type, struct bp_location): New.
index cebd877bbe5552c0170c34f4ce3ffb244d643433..6d80d747f676fb3a8f88b0cc2c082070750ef257 100644 (file)
@@ -235,6 +235,15 @@ static int overlay_events_enabled;
             B ? (TMP=B->next, 1): 0;   \
             B = TMP)
 
+/* Similar iterators for the low-level breakpoints.  */
+
+#define ALL_BP_LOCATIONS(B)  for (B = bp_location_chain; B; B = B->next)
+
+#define ALL_BP_LOCATIONS_SAFE(B,TMP)   \
+       for (B = bp_location_chain;     \
+            B ? (TMP=B->next, 1): 0;   \
+            B = TMP)
+
 /* True if SHIFT_INST_REGS defined, false otherwise.  */
 
 int must_shift_inst_regs =
@@ -249,10 +258,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 bp_location *bp_location_chain;
+
 /* Number of last breakpoint made.  */
 
 int breakpoint_count;
@@ -3896,6 +3907,31 @@ adjust_breakpoint_address (CORE_ADDR bpaddr)
     }
 }
 
+/* Allocate a struct bp_location.  */
+
+struct bp_location *
+allocate_bp_location (void)
+{
+  struct bp_location *loc, *loc_p;
+
+  loc = xmalloc (sizeof (struct bp_location));
+  memset (loc, 0, sizeof (*loc));
+
+  /* Add this breakpoint to the end of the chain.  */
+
+  loc_p = bp_location_chain;
+  if (loc_p == 0)
+    bp_location_chain = loc;
+  else
+    {
+      while (loc_p->next)
+       loc_p = loc_p->next;
+      loc_p->next = loc;
+    }
+
+  return loc;
+}
+
 /* 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
@@ -3918,8 +3954,7 @@ set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype)
 
   b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
   memset (b, 0, sizeof (*b));
-  b->loc = (struct bp_location *) xmalloc (sizeof (struct bp_location));
-  memset (b->loc, 0, sizeof (*b->loc));
+  b->loc = allocate_bp_location ();
   b->loc->requested_address = sal.pc;
   b->loc->address = adjust_breakpoint_address (b->loc->requested_address);
   if (sal.symtab == NULL)
@@ -6569,6 +6604,7 @@ delete_breakpoint (struct breakpoint *bpt)
 {
   struct breakpoint *b;
   bpstat bs;
+  struct bp_location *loc;
 
   if (bpt == NULL)
     error ("Internal error (attempted to delete a NULL breakpoint)");
@@ -6600,6 +6636,9 @@ delete_breakpoint (struct breakpoint *bpt)
   if (breakpoint_chain == bpt)
     breakpoint_chain = bpt->next;
 
+  if (bp_location_chain == bpt->loc)
+    bp_location_chain = bpt->loc->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
@@ -6629,6 +6668,13 @@ delete_breakpoint (struct breakpoint *bpt)
       break;
     }
 
+  ALL_BP_LOCATIONS (loc)
+    if (loc->next == bpt->loc)
+      {
+       loc->next = bpt->loc->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 0716e9c79b1b0eada9f3cb808b02b7b6302cc638..2dde3c9b4ff63bd66ff26280729f65d09715b346 100644 (file)
@@ -207,6 +207,9 @@ enum bp_loc_type
 
 struct bp_location
 {
+  /* Chain pointer to the next breakpoint location.  */
+  struct bp_location *next;
+
   /* Type of this breakpoint location.  */
   enum bp_loc_type loc_type;
 
This page took 0.045021 seconds and 4 git commands to generate.