This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
RFA: Breakpoint infrastructure cleanups [5/8] - add section to impl_breakpoint
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 8 Oct 2003 13:14:41 -0400
- Subject: RFA: Breakpoint infrastructure cleanups [5/8] - add section to impl_breakpoint
This patch moves something I missed in the first pass: the section is
intimately tied to the address, and therefore belongs in the
impl_breakpoint. Purely mechanical.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2003-10-08 Daniel Jacobowitz <drow@mvista.com>
* breakpoint.h (struct impl_breakpoint): Add section.
(struct breakpoint): Remove section.
* breakpoint.c (insert_breakpoints, remove_breakpoint)
(breakpoint_here_p, breakpoint_inserted_here_p)
(breakpoint_thread_match, bpstat_stop_status, print_one_breakpoint)
(describe_other_breakpoints, check_duplicates, set_raw_breakpoint)
(clear_command, delete_breakpoint, breakpoint_re_set_one): Access
section through impl.
Index: gdb/breakpoint.c
===================================================================
--- gdb.orig/breakpoint.c 2003-10-08 12:42:11.000000000 -0400
+++ gdb/breakpoint.c 2003-10-08 12:42:11.000000000 -0400
@@ -798,8 +798,8 @@ insert_breakpoints (void)
/* First check to see if we have to handle an overlay. */
if (overlay_debugging == ovly_off
- || b->section == NULL
- || !(section_is_overlay (b->section)))
+ || b->impl->section == NULL
+ || !(section_is_overlay (b->impl->section)))
{
/* No overlay handling: just set the breakpoint. */
@@ -824,7 +824,7 @@ insert_breakpoints (void)
else
{
CORE_ADDR addr = overlay_unmapped_address (b->impl->address,
- b->section);
+ b->impl->section);
/* Set a software (trap) breakpoint at the LMA. */
val = target_insert_breakpoint (addr, b->impl->shadow_contents);
if (val != 0)
@@ -834,7 +834,7 @@ insert_breakpoints (void)
}
}
/* Shall we set a breakpoint at the VMA? */
- if (section_is_mapped (b->section))
+ if (section_is_mapped (b->impl->section))
{
/* Yes. This overlay section is mapped into memory. */
if (b->type == bp_hardware_breakpoint)
@@ -1379,8 +1379,8 @@ remove_breakpoint (struct breakpoint *b,
/* First check to see if we have to handle an overlay. */
if (overlay_debugging == ovly_off
- || b->section == NULL
- || !(section_is_overlay (b->section)))
+ || b->impl->section == NULL
+ || !(section_is_overlay (b->impl->section)))
{
/* No overlay handling: just remove the breakpoint. */
@@ -1400,7 +1400,7 @@ remove_breakpoint (struct breakpoint *b,
should have set a breakpoint at the LMA. Remove it.
*/
CORE_ADDR addr = overlay_unmapped_address (b->impl->address,
- b->section);
+ b->impl->section);
/* Ignore any failures: if the LMA is in ROM, we will
have already warned when we failed to insert it. */
if (b->type != bp_hardware_breakpoint)
@@ -1652,8 +1652,8 @@ breakpoint_here_p (CORE_ADDR pc)
&& b->impl->address == pc) /* bp is enabled and matches pc */
{
if (overlay_debugging
- && section_is_overlay (b->section)
- && !section_is_mapped (b->section))
+ && 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;
@@ -1679,8 +1679,8 @@ breakpoint_inserted_here_p (CORE_ADDR pc
&& b->impl->address == pc) /* bp is inserted and matches pc */
{
if (overlay_debugging
- && section_is_overlay (b->section)
- && !section_is_mapped (b->section))
+ && section_is_overlay (b->impl->section)
+ && !section_is_mapped (b->impl->section))
continue; /* unmapped overlay -- can't be a match */
else
return 1;
@@ -1739,8 +1739,8 @@ breakpoint_thread_match (CORE_ADDR pc, p
&& (b->thread == -1 || b->thread == thread))
{
if (overlay_debugging
- && section_is_overlay (b->section)
- && !section_is_mapped (b->section))
+ && section_is_overlay (b->impl->section)
+ && !section_is_mapped (b->impl->section))
continue; /* unmapped overlay -- can't be a match */
else
return 1;
@@ -2549,8 +2549,8 @@ bpstat_stop_status (CORE_ADDR *pc, int n
if (b->impl->address != bp_addr) /* address doesn't match */
continue;
if (overlay_debugging /* unmapped overlay section */
- && section_is_overlay (b->section)
- && !section_is_mapped (b->section))
+ && section_is_overlay (b->impl->section)
+ && !section_is_mapped (b->impl->section))
continue;
}
@@ -2559,8 +2559,8 @@ bpstat_stop_status (CORE_ADDR *pc, int n
if (b->impl->address != (*pc - DECR_PC_AFTER_HW_BREAK))
continue;
if (overlay_debugging /* unmapped overlay section */
- && section_is_overlay (b->section)
- && !section_is_mapped (b->section))
+ && section_is_overlay (b->impl->section)
+ && !section_is_mapped (b->impl->section))
continue;
}
@@ -3422,7 +3422,7 @@ print_one_breakpoint (struct breakpoint
*last_addr = b->impl->address;
if (b->source_file)
{
- sym = find_pc_sect_function (b->impl->address, b->section);
+ sym = find_pc_sect_function (b->impl->address, b->impl->section);
if (sym)
{
ui_out_text (uiout, "in ");
@@ -3702,14 +3702,14 @@ describe_other_breakpoints (CORE_ADDR pc
ALL_BREAKPOINTS (b)
if (b->impl->address == pc) /* address match / overlay match */
- if (!overlay_debugging || b->section == section)
+ if (!overlay_debugging || b->impl->section == section)
others++;
if (others > 0)
{
printf_filtered ("Note: breakpoint%s ", (others > 1) ? "s" : "");
ALL_BREAKPOINTS (b)
if (b->impl->address == pc) /* address match / overlay match */
- if (!overlay_debugging || b->section == section)
+ if (!overlay_debugging || b->impl->section == section)
{
others--;
printf_filtered ("%d%s%s ",
@@ -3790,7 +3790,7 @@ check_duplicates (struct breakpoint *bpt
int count = 0;
struct breakpoint *perm_bp = 0;
CORE_ADDR address = bpt->impl->address;
- asection *section = bpt->section;
+ asection *section = bpt->impl->section;
if (! breakpoint_address_is_meaningful (bpt))
return;
@@ -3800,7 +3800,7 @@ check_duplicates (struct breakpoint *bpt
&& b->enable_state != bp_shlib_disabled
&& b->enable_state != bp_call_disabled
&& b->impl->address == address /* address / overlay match */
- && (!overlay_debugging || b->section == section)
+ && (!overlay_debugging || b->impl->section == section)
&& breakpoint_address_is_meaningful (b))
{
/* Have we found a permanent breakpoint? */
@@ -3839,7 +3839,7 @@ check_duplicates (struct breakpoint *bpt
&& b->enable_state != bp_shlib_disabled
&& b->enable_state != bp_call_disabled
&& b->impl->address == address /* address / overlay match */
- && (!overlay_debugging || b->section == section)
+ && (!overlay_debugging || b->impl->section == section)
&& breakpoint_address_is_meaningful (b))
b->impl->duplicate = 1;
}
@@ -3940,7 +3940,7 @@ set_raw_breakpoint (struct symtab_and_li
else
b->source_file = savestring (sal.symtab->filename,
strlen (sal.symtab->filename));
- b->section = sal.section;
+ b->impl->section = sal.section;
b->type = bptype;
b->language = current_language->la_language;
b->input_radix = input_radix;
@@ -6492,8 +6492,8 @@ clear_command (char *arg, int from_tty)
&& b->type != bp_access_watchpoint
/* Not if b is a watchpoint of any sort... */
&& (((sal.pc && (b->impl->address == sal.pc))
- && (!section_is_overlay (b->section)
- || b->section == sal.section))
+ && (!section_is_overlay (b->impl->section)
+ || b->impl->section == sal.section))
/* Yes, if sal.pc matches b (modulo overlays). */
|| ((default_match || (0 == sal.pc))
&& b->source_file != NULL
@@ -6662,7 +6662,7 @@ delete_breakpoint (struct breakpoint *bp
{
ALL_BREAKPOINTS (b)
if (b->impl->address == bpt->impl->address
- && b->section == bpt->section
+ && b->impl->section == bpt->impl->section
&& !b->impl->duplicate
&& b->enable_state != bp_disabled
&& b->enable_state != bp_shlib_disabled
@@ -6928,7 +6928,7 @@ breakpoint_re_set_one (void *bint)
rather than once for every breakpoint. */
breakpoints_changed ();
}
- b->section = sals.sals[i].section;
+ b->impl->section = sals.sals[i].section;
b->enable_state = save_enable; /* Restore it, this worked. */
Index: gdb/breakpoint.h
===================================================================
--- gdb.orig/breakpoint.h 2003-10-08 12:42:10.000000000 -0400
+++ gdb/breakpoint.h 2003-10-08 12:42:11.000000000 -0400
@@ -231,6 +231,10 @@ struct impl_breakpoint
impl_bp_other. */
CORE_ADDR address;
+ /* For any breakpoint type with an address, this is the BFD section
+ associated with the address. Used primarily for overlay debugging. */
+ asection *section;
+
/* "Real" contents of byte where breakpoint has been inserted.
Valid only when breakpoints are in the program. Under the complete
control of the target insert_breakpoint and remove_breakpoint routines.
@@ -365,8 +369,6 @@ struct breakpoint
triggered. */
char *exec_pathname;
- asection *section;
-
/* Methods associated with this breakpoint. */
struct breakpoint_ops *ops;
};