* 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.
This commit is contained in:
Daniel Jacobowitz 2003-11-06 17:26:18 +00:00
parent 5cab636d14
commit 7cc221efff
3 changed files with 62 additions and 3 deletions

View 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.

View 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. */

View 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;