aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c160
1 files changed, 121 insertions, 39 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index bcb2de9..130b684 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -663,16 +663,10 @@ deprecated_read_memory_nobpt (CORE_ADDR memaddr, gdb_byte *myaddr,
continue;
/* Addresses and length of the part of the breakpoint that
we need to copy. */
- /* XXXX The m68k, sh and h8300 have different local and remote
- breakpoint values. BREAKPOINT_FROM_PC still manages to
- correctly determine the breakpoints memory address and size
- for these targets. */
- bp_addr = b->address;
- bp_size = 0;
- if (BREAKPOINT_FROM_PC (&bp_addr, &bp_size) == NULL)
- continue;
+ bp_addr = b->target_info.placed_address;
+ bp_size = b->target_info.shadow_len;
if (bp_size == 0)
- /* bp isn't valid */
+ /* bp isn't valid, or doesn't shadow memory. */
continue;
if (bp_addr + bp_size <= memaddr)
/* The breakpoint is entirely before the chunk of memory we
@@ -703,7 +697,7 @@ deprecated_read_memory_nobpt (CORE_ADDR memaddr, gdb_byte *myaddr,
}
memcpy (myaddr + bp_addr - memaddr,
- b->shadow_contents + bptoffset, bp_size);
+ b->target_info.shadow_contents + bptoffset, bp_size);
if (bp_addr > memaddr)
{
@@ -793,6 +787,10 @@ insert_bp_location (struct bp_location *bpt,
if (bpt->inserted || bpt->duplicate)
return 0;
+ /* Initialize the target-specific information. */
+ memset (&bpt->target_info, 0, sizeof (bpt->target_info));
+ bpt->target_info.placed_address = bpt->address;
+
if (bpt->loc_type == bp_loc_software_breakpoint
|| bpt->loc_type == bp_loc_hardware_breakpoint)
{
@@ -804,11 +802,9 @@ insert_bp_location (struct bp_location *bpt,
/* No overlay handling: just set the breakpoint. */
if (bpt->loc_type == bp_loc_hardware_breakpoint)
- val = target_insert_hw_breakpoint (bpt->address,
- bpt->shadow_contents);
+ val = target_insert_hw_breakpoint (&bpt->target_info);
else
- val = target_insert_breakpoint (bpt->address,
- bpt->shadow_contents);
+ val = target_insert_breakpoint (&bpt->target_info);
}
else
{
@@ -827,7 +823,9 @@ insert_bp_location (struct bp_location *bpt,
CORE_ADDR addr = overlay_unmapped_address (bpt->address,
bpt->section);
/* Set a software (trap) breakpoint at the LMA. */
- val = target_insert_breakpoint (addr, bpt->shadow_contents);
+ bpt->overlay_target_info = bpt->target_info;
+ bpt->overlay_target_info.placed_address = addr;
+ val = target_insert_breakpoint (&bpt->overlay_target_info);
if (val != 0)
fprintf_unfiltered (tmp_error_stream,
"Overlay breakpoint %d failed: in ROM?",
@@ -839,11 +837,9 @@ insert_bp_location (struct bp_location *bpt,
{
/* Yes. This overlay section is mapped into memory. */
if (bpt->loc_type == bp_loc_hardware_breakpoint)
- val = target_insert_hw_breakpoint (bpt->address,
- bpt->shadow_contents);
+ val = target_insert_hw_breakpoint (&bpt->target_info);
else
- val = target_insert_breakpoint (bpt->address,
- bpt->shadow_contents);
+ val = target_insert_breakpoint (&bpt->target_info);
}
else
{
@@ -1045,7 +1041,7 @@ in which its expression is valid.\n"),
/* If we get here, we must have a callback mechanism for exception
events -- with g++ style embedded label support, we insert
ordinary breakpoints and not catchpoints. */
- val = target_insert_breakpoint (bpt->address, bpt->shadow_contents);
+ val = target_insert_breakpoint (&bpt->target_info);
if (val)
{
/* Couldn't set breakpoint for some reason */
@@ -1240,9 +1236,9 @@ reattach_breakpoints (int pid)
{
remove_breakpoint (b, mark_inserted);
if (b->loc_type == bp_loc_hardware_breakpoint)
- val = target_insert_hw_breakpoint (b->address, b->shadow_contents);
+ val = target_insert_hw_breakpoint (&b->target_info);
else
- val = target_insert_breakpoint (b->address, b->shadow_contents);
+ val = target_insert_breakpoint (&b->target_info);
/* FIXME drow/2003-10-07: This doesn't handle any other kinds of
breakpoints. It's wrong for watchpoints, for example. */
if (val != 0)
@@ -1446,10 +1442,9 @@ remove_breakpoint (struct bp_location *b, insertion_state_t is)
/* No overlay handling: just remove the breakpoint. */
if (b->loc_type == bp_loc_hardware_breakpoint)
- val = target_remove_hw_breakpoint (b->address,
- b->shadow_contents);
+ val = target_remove_hw_breakpoint (&b->target_info);
else
- val = target_remove_breakpoint (b->address, b->shadow_contents);
+ val = target_remove_breakpoint (&b->target_info);
}
else
{
@@ -1460,14 +1455,12 @@ remove_breakpoint (struct bp_location *b, insertion_state_t is)
/* Yes -- overlay event support is not active, so we
should have set a breakpoint at the LMA. Remove it.
*/
- CORE_ADDR addr = overlay_unmapped_address (b->address,
- b->section);
/* Ignore any failures: if the LMA is in ROM, we will
have already warned when we failed to insert it. */
if (b->loc_type == bp_loc_hardware_breakpoint)
- target_remove_hw_breakpoint (addr, b->shadow_contents);
+ target_remove_hw_breakpoint (&b->overlay_target_info);
else
- target_remove_breakpoint (addr, b->shadow_contents);
+ target_remove_breakpoint (&b->overlay_target_info);
}
/* Did we set a breakpoint at the VMA?
If so, we will have marked the breakpoint 'inserted'. */
@@ -1478,11 +1471,9 @@ remove_breakpoint (struct bp_location *b, insertion_state_t is)
unmapped, but let's not rely on that being safe. We
don't know what the overlay manager might do. */
if (b->loc_type == bp_loc_hardware_breakpoint)
- val = target_remove_hw_breakpoint (b->address,
- b->shadow_contents);
+ val = target_remove_hw_breakpoint (&b->target_info);
else
- val = target_remove_breakpoint (b->address,
- b->shadow_contents);
+ val = target_remove_breakpoint (&b->target_info);
}
else
{
@@ -1570,8 +1561,7 @@ remove_breakpoint (struct bp_location *b, insertion_state_t is)
&& breakpoint_enabled (b->owner)
&& !b->duplicate)
{
-
- val = target_remove_breakpoint (b->address, b->shadow_contents);
+ val = target_remove_breakpoint (&b->target_info);
if (val)
return val;
b->inserted = (is == mark_inserted);
@@ -1581,8 +1571,7 @@ remove_breakpoint (struct bp_location *b, insertion_state_t is)
&& breakpoint_enabled (b->owner)
&& !b->duplicate)
{
-
- val = target_remove_breakpoint (b->address, b->shadow_contents);
+ val = target_remove_breakpoint (&b->target_info);
if (val)
return val;
@@ -6852,10 +6841,12 @@ delete_breakpoint (struct breakpoint *bpt)
_("another breakpoint was inserted on top of "
"a permanent breakpoint"));
+ memset (&b->loc->target_info, 0, sizeof (b->loc->target_info));
+ b->loc->target_info.placed_address = b->loc->address;
if (b->type == bp_hardware_breakpoint)
- val = target_insert_hw_breakpoint (b->loc->address, b->loc->shadow_contents);
+ val = target_insert_hw_breakpoint (&b->loc->target_info);
else
- val = target_insert_breakpoint (b->loc->address, b->loc->shadow_contents);
+ val = target_insert_breakpoint (&b->loc->target_info);
/* If there was an error in the insert, print a message, then stop execution. */
if (val != 0)
@@ -7658,6 +7649,97 @@ decode_line_spec_1 (char *string, int funfirstline)
error (_("Junk at end of line specification: %s"), string);
return sals;
}
+
+/* Create and insert a raw software breakpoint at PC. Return an
+ identifier, which should be used to remove the breakpoint later.
+ In general, places which call this should be using something on the
+ breakpoint chain instead; this function should be eliminated
+ someday. */
+
+void *
+deprecated_insert_raw_breakpoint (CORE_ADDR pc)
+{
+ struct bp_target_info *bp_tgt;
+
+ bp_tgt = xmalloc (sizeof (struct bp_target_info));
+ memset (bp_tgt, 0, sizeof (struct bp_target_info));
+
+ bp_tgt->placed_address = pc;
+ if (target_insert_breakpoint (bp_tgt) != 0)
+ {
+ /* Could not insert the breakpoint. */
+ xfree (bp_tgt);
+ return NULL;
+ }
+
+ return bp_tgt;
+}
+
+/* Remove a breakpoint BP inserted by deprecated_insert_raw_breakpoint. */
+
+int
+deprecated_remove_raw_breakpoint (void *bp)
+{
+ struct bp_target_info *bp_tgt = bp;
+ int ret;
+
+ ret = target_remove_breakpoint (bp_tgt);
+ xfree (bp_tgt);
+
+ return ret;
+}
+
+/* One (or perhaps two) breakpoints used for software single stepping. */
+
+static void *single_step_breakpoints[2];
+
+/* Create and insert a breakpoint for software single step. */
+
+void
+insert_single_step_breakpoint (CORE_ADDR next_pc)
+{
+ void **bpt_p;
+
+ if (single_step_breakpoints[0] == NULL)
+ bpt_p = &single_step_breakpoints[0];
+ else
+ {
+ gdb_assert (single_step_breakpoints[1] == NULL);
+ bpt_p = &single_step_breakpoints[1];
+ }
+
+ /* NOTE drow/2006-04-11: A future improvement to this function would be
+ to only create the breakpoints once, and actually put them on the
+ breakpoint chain. That would let us use set_raw_breakpoint. We could
+ adjust the addresses each time they were needed. Doing this requires
+ corresponding changes elsewhere where single step breakpoints are
+ handled, however. So, for now, we use this. */
+
+ *bpt_p = deprecated_insert_raw_breakpoint (next_pc);
+ if (*bpt_p == NULL)
+ warning (_("Could not insert single-step breakpoint at 0x%s"),
+ paddr_nz (next_pc));
+}
+
+/* Remove and delete any breakpoints used for software single step. */
+
+void
+remove_single_step_breakpoints (void)
+{
+ gdb_assert (single_step_breakpoints[0] != NULL);
+
+ /* See insert_single_step_breakpoint for more about this deprecated
+ call. */
+ deprecated_remove_raw_breakpoint (single_step_breakpoints[0]);
+ single_step_breakpoints[0] = NULL;
+
+ if (single_step_breakpoints[1] != NULL)
+ {
+ deprecated_remove_raw_breakpoint (single_step_breakpoints[1]);
+ single_step_breakpoints[1] = NULL;
+ }
+}
+
/* This help string is used for the break, hbreak, tbreak and thbreak commands.
It is defined as a macro to prevent duplication.