This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
RFA: Breakpoint infrastructure cleanups [7/8] - convert assorted other functions
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 8 Oct 2003 13:20:55 -0400
- Subject: RFA: Breakpoint infrastructure cleanups [7/8] - convert assorted other functions
This patch mechanically converts some more ALL_BREAKPOINTS instances to
ALL_IMPL_BREAKPOINTS; things which are looking for breakpoint addresses or
inserted statuses, mostly.
This also adds some missing checks that a breakpoint has an address - we're
only interested in software or hardware breakpoints in most of these
functions. Probably this bug fix makes no difference unless you have a
breakpoint at address 0. Maybe we should have a simulator target actually
test that somehow?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2003-10-08 Daniel Jacobowitz <drow@mvista.com>
* breakpoint.c (mark_breakpoints_out): Use ALL_IMPL_BREAKPOINTS.
(beakpoint_init_inferior): Likewise.
(breakpoint_here_p): Likewise. Only check addresses for software
or hardware breakpoints.
(breakpoint_inserted_here_p): Likewise.
(breakpoint_thread_match): Likewise. Correct comment.
(bpstat_have_active_hw_watchpoints): Likewise.
(check_duplicates): Likewise.
Index: gdb/breakpoint.c
===================================================================
--- gdb.orig/breakpoint.c 2003-10-08 12:42:12.000000000 -0400
+++ gdb/breakpoint.c 2003-10-08 12:42:12.000000000 -0400
@@ -1570,10 +1570,10 @@ remove_breakpoint (struct breakpoint *b,
void
mark_breakpoints_out (void)
{
- struct breakpoint *b;
+ struct impl_breakpoint *bpt;
- ALL_BREAKPOINTS (b)
- b->impl->inserted = 0;
+ ALL_IMPL_BREAKPOINTS (bpt)
+ bpt->inserted = 0;
}
/* Clear the "inserted" flag in all breakpoints and delete any
@@ -1592,12 +1592,14 @@ void
breakpoint_init_inferior (enum inf_context context)
{
struct breakpoint *b, *temp;
+ struct impl_breakpoint *bpt;
static int warning_needed = 0;
+ ALL_IMPL_BREAKPOINTS (bpt)
+ bpt->inserted = 0;
+
ALL_BREAKPOINTS_SAFE (b, temp)
{
- b->impl->inserted = 0;
-
switch (b->type)
{
case bp_call_dummy:
@@ -1666,23 +1668,29 @@ breakpoint_init_inferior (enum inf_conte
enum breakpoint_here
breakpoint_here_p (CORE_ADDR pc)
{
- struct breakpoint *b;
+ struct impl_breakpoint *bpt;
int any_breakpoint_here = 0;
- ALL_BREAKPOINTS (b)
- if ((b->enable_state == bp_enabled
- || b->enable_state == bp_permanent)
- && b->impl->address == pc) /* bp is enabled and matches pc */
- {
- if (overlay_debugging
- && section_is_overlay (b->impl->section)
- && !section_is_mapped (b->impl->section))
- continue; /* unmapped overlay -- can't be a match */
- else if (b->enable_state == bp_permanent)
- return permanent_breakpoint_here;
- else
- any_breakpoint_here = 1;
- }
+ ALL_IMPL_BREAKPOINTS (bpt)
+ {
+ if (bpt->type != impl_bp_software_breakpoint
+ && bpt->type != impl_bp_hardware_breakpoint)
+ continue;
+
+ if ((bpt->owner->enable_state == bp_enabled
+ || bpt->owner->enable_state == bp_permanent)
+ && bpt->address == pc) /* bp is enabled and matches pc */
+ {
+ if (overlay_debugging
+ && section_is_overlay (bpt->section)
+ && !section_is_mapped (bpt->section))
+ continue; /* unmapped overlay -- can't be a match */
+ else if (bpt->owner->enable_state == bp_permanent)
+ return permanent_breakpoint_here;
+ else
+ any_breakpoint_here = 1;
+ }
+ }
return any_breakpoint_here ? ordinary_breakpoint_here : 0;
}
@@ -1695,18 +1703,24 @@ breakpoint_here_p (CORE_ADDR pc)
int
breakpoint_inserted_here_p (CORE_ADDR pc)
{
- struct breakpoint *b;
+ struct impl_breakpoint *bpt;
- ALL_BREAKPOINTS (b)
- if (b->impl->inserted
- && b->impl->address == pc) /* bp is inserted and matches pc */
+ ALL_IMPL_BREAKPOINTS (bpt)
{
- if (overlay_debugging
- && section_is_overlay (b->impl->section)
- && !section_is_mapped (b->impl->section))
- continue; /* unmapped overlay -- can't be a match */
- else
- return 1;
+ if (bpt->type != impl_bp_software_breakpoint
+ && bpt->type != impl_bp_hardware_breakpoint)
+ continue;
+
+ if (bpt->inserted
+ && bpt->address == pc) /* bp is inserted and matches pc */
+ {
+ if (overlay_debugging
+ && section_is_overlay (bpt->section)
+ && !section_is_mapped (bpt->section))
+ continue; /* unmapped overlay -- can't be a match */
+ else
+ return 1;
+ }
}
return 0;
@@ -1743,30 +1757,35 @@ deprecated_frame_in_dummy (struct frame_
return 0;
}
-/* breakpoint_thread_match (PC, PID) returns true if the breakpoint at
- PC is valid for process/thread PID. */
+/* breakpoint_thread_match (PC, PTID) returns true if the breakpoint at
+ PC is valid for process/thread PTID. */
int
breakpoint_thread_match (CORE_ADDR pc, ptid_t ptid)
{
- struct breakpoint *b;
+ struct impl_breakpoint *bpt;
int thread;
thread = pid_to_thread_id (ptid);
- ALL_BREAKPOINTS (b)
- if (b->enable_state != bp_disabled
- && b->enable_state != bp_shlib_disabled
- && b->enable_state != bp_call_disabled
- && b->impl->address == pc
- && (b->thread == -1 || b->thread == thread))
- {
- if (overlay_debugging
- && section_is_overlay (b->impl->section)
- && !section_is_mapped (b->impl->section))
- continue; /* unmapped overlay -- can't be a match */
- else
- return 1;
+ ALL_IMPL_BREAKPOINTS (bpt)
+ {
+ if (bpt->type != impl_bp_software_breakpoint
+ && bpt->type != impl_bp_hardware_breakpoint)
+ continue;
+
+ if ((bpt->owner->enable_state == bp_enabled
+ || bpt->owner->enable_state == bp_permanent)
+ && bpt->address == pc
+ && (bpt->owner->thread == -1 || bpt->owner->thread == thread))
+ {
+ if (overlay_debugging
+ && section_is_overlay (bpt->section)
+ && !section_is_mapped (bpt->section))
+ continue; /* unmapped overlay -- can't be a match */
+ else
+ return 1;
+ }
}
return 0;
@@ -3167,13 +3186,11 @@ bpstat_should_step (void)
int
bpstat_have_active_hw_watchpoints (void)
{
- struct breakpoint *b;
- ALL_BREAKPOINTS (b)
- if ((b->enable_state == bp_enabled) &&
- (b->impl->inserted) &&
- ((b->type == bp_hardware_watchpoint) ||
- (b->type == bp_read_watchpoint) ||
- (b->type == bp_access_watchpoint)))
+ struct impl_breakpoint *bpt;
+ ALL_IMPL_BREAKPOINTS (bpt)
+ if ((bpt->owner->enable_state == bp_enabled)
+ && bpt->inserted
+ && bpt->type == impl_bp_hardware_watchpoint)
return 1;
return 0;
}
@@ -3809,32 +3826,32 @@ breakpoint_address_is_meaningful (struct
static void
check_duplicates (struct breakpoint *bpt)
{
- struct breakpoint *b;
+ struct impl_breakpoint *b;
int count = 0;
- struct breakpoint *perm_bp = 0;
+ struct impl_breakpoint *perm_bp = 0;
CORE_ADDR address = bpt->impl->address;
asection *section = bpt->impl->section;
if (! breakpoint_address_is_meaningful (bpt))
return;
- ALL_BREAKPOINTS (b)
- if (b->enable_state != bp_disabled
- && b->enable_state != bp_shlib_disabled
- && b->enable_state != bp_call_disabled
- && b->impl->address == address /* address / overlay match */
- && (!overlay_debugging || b->impl->section == section)
- && breakpoint_address_is_meaningful (b))
+ ALL_IMPL_BREAKPOINTS (b)
+ if (b->owner->enable_state != bp_disabled
+ && b->owner->enable_state != bp_shlib_disabled
+ && b->owner->enable_state != bp_call_disabled
+ && b->address == address /* address / overlay match */
+ && (!overlay_debugging || b->section == section)
+ && breakpoint_address_is_meaningful (b->owner))
{
/* Have we found a permanent breakpoint? */
- if (b->enable_state == bp_permanent)
+ if (b->owner->enable_state == bp_permanent)
{
perm_bp = b;
break;
}
count++;
- b->impl->duplicate = count > 1;
+ b->duplicate = count > 1;
}
/* If we found a permanent breakpoint at this address, go over the
@@ -3842,29 +3859,31 @@ check_duplicates (struct breakpoint *bpt
duplicates. */
if (perm_bp)
{
- perm_bp->impl->duplicate = 0;
+ perm_bp->duplicate = 0;
/* Permanent breakpoint should always be inserted. */
- if (! perm_bp->impl->inserted)
+ if (! perm_bp->inserted)
internal_error (__FILE__, __LINE__,
"allegedly permanent breakpoint is not "
"actually inserted");
- ALL_BREAKPOINTS (b)
+ ALL_IMPL_BREAKPOINTS (b)
if (b != perm_bp)
{
- if (b->impl->inserted)
- internal_error (__FILE__, __LINE__,
- "another breakpoint was inserted on top of "
- "a permanent breakpoint");
-
- if (b->enable_state != bp_disabled
- && b->enable_state != bp_shlib_disabled
- && b->enable_state != bp_call_disabled
- && b->impl->address == address /* address / overlay match */
- && (!overlay_debugging || b->impl->section == section)
- && breakpoint_address_is_meaningful (b))
- b->impl->duplicate = 1;
+ if (b->owner->enable_state != bp_disabled
+ && b->owner->enable_state != bp_shlib_disabled
+ && b->owner->enable_state != bp_call_disabled
+ && b->address == address /* address / overlay match */
+ && (!overlay_debugging || b->section == section)
+ && breakpoint_address_is_meaningful (b->owner))
+ {
+ if (b->inserted)
+ internal_error (__FILE__, __LINE__,
+ "another breakpoint was inserted on top of "
+ "a permanent breakpoint");
+
+ b->duplicate = 1;
+ }
}
}
}