aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/breakpoint.c52
-rw-r--r--gdb/breakpoint.h3
3 files changed, 62 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d340c55..787caa9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,15 @@
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.
(struct breakpoint): Remove address, shadow_contents, inserted,
and duplicate. Add a struct bp_location.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index cebd877..6d80d74 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -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. */
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 0716e9c..2dde3c9 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -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;