diff options
author | Daniel Jacobowitz <drow@false.org> | 2006-04-18 19:20:08 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2006-04-18 19:20:08 +0000 |
commit | 8181d85fdcb9f4d31030a70bd0a1d3f4e1f5b7e3 (patch) | |
tree | 32a74d421c0211907c72d01b52586972a227862d /gdb/breakpoint.c | |
parent | bb8f5920403b60671c504eda876c8283da2f2165 (diff) | |
download | gdb-8181d85fdcb9f4d31030a70bd0a1d3f4e1f5b7e3.zip gdb-8181d85fdcb9f4d31030a70bd0a1d3f4e1f5b7e3.tar.gz gdb-8181d85fdcb9f4d31030a70bd0a1d3f4e1f5b7e3.tar.bz2 |
gdb/
* breakpoint.c (deprecated_read_memory_nobpt): Update to use
shadow_len.
(insert_bp_location, reattach_breakpoints, remove_breakpoint)
(delete_breakpoint): Update calls to changed methods.
(deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint)
(single_step_breakpoints, insert_single_step_breakpoint)
(remove_single_step_breakpoints): New.
* breakpoint.h (struct bp_target_info): New.
(struct bp_location): Replace shadow_contents with
target_info and overlay_target_info.
(deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint)
(insert_single_step_breakpoint, remove_single_step_breakpoints): New
prototypes.
* gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h.
(memory_insert_breakpoint, memory_remove_breakpoint): Update second
argument.
* mem-break.c (default_memory_insert_breakpoint): Update. Set
placed_address, placed_size, and shadow_len.
(default_memory_remove_breakpoint): Update. Don't use
BREAKPOINT_FROM_PC.
(memory_insert_breakpoint, memory_remove_breakpoint): Update.
* target.c (update_current_target): Update prototypes for changed
functions.
(debug_to_insert_breakpoint, debug_to_remove_breakpoint)
(debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint):
Update.
* target.h: Forward declare struct bp_target_info.
(struct target_ops): Use a bp_target_info argument for
to_insert_breakpoint, to_remove_breakpoint,
to_insert_hw_breakpoint, and to_remove_hw_breakpoint.
(target_insert_breakpoint, target_remove_breakpoint)
(target_insert_hw_breakpoint, target_remove_hw_breakpoint)
(memory_insert_breakpoint, memory_remove_breakpoint)
(default_memory_insert_breakpoint, default_memory_remove_breakpoint):
Update.
* config/i386/nm-i386.h: Forward declare struct bp_target_info.
(i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update.
(target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* alpha-tdep.c (alpha_software_single_step): Use
insert_single_step_breakpoint and remove_single_step_breakpoints.
Remove unused statics.
* arm-tdep.c (arm_software_single_step): Likewise. Add a note.
* cris-tdep.c (cris_software_single_step): Likewise.
* mips-tdep.c (mips_software_single_step): Likewise.
* rs6000-tdep.c (rs6000_software_single_step): Likewise.
* sparc-tdep.c (sparc_software_single_step): Likewise.
* wince.c (struct thread_info_struct): Remove step_prev.
(undoSStep): Use remove_single_step_breakpoints.
(wince_software_single_step): Use insert_single_step_breakpoint.
* corelow.c (ignore): Remove unneeded prototype. Update arguments.
* exec.c (ignore): Likewise.
* sol-thread.c (ignore): Likewise.
* procfs.c (dbx_link_shadow_contents): Delete.
(dbx_link_bpt): New.
(procfs_mourn_inferior): Remove it if necessary.
(remove_dbx_link_breakpoint): Use it.
(insert_dbx_link_bpt_in_file): Set it.
(procfs_init_inferior): Don't update dbx_link_bpt_addr.
* rs6000-nat.c (exec_one_dummy_insn): Use
deprecated_insert_raw_breakpoint and
deprecated_remove_raw_breakpoint.
* solib-irix.c (shadow_contents, breakpoint_addr): Delete.
(base_breakpoint): New.
(disable_break): Use it.
(enable_break): Set it.
* i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint):
Update.
* ia64-tdep.c (ia64_memory_insert_breakpoint)
(ia64_memory_remove_breakpoint): Likewise.
* m32r-tdep.c (m32r_memory_insert_breakpoint)
(m32r_memory_remove_breakpoint): Likewise.
* monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint):
Likewise. Remove unnecessary prototypes. Use placed_address
and placed_size. Removed useless read from memory.
* nto-procfs.c (procfs_insert_breakpoint)
(procfs_remove_breakpoint, procfs_insert_hw_breakpoint)
(procfs_remove_hw_breakpoint): Update.
* ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise.
* ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise.
* ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise.
* ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise.
* remote-e7000.c (e7000_insert_breakpoint)
(e7000_remove_breakpoint): Likewise.
* remote-m32r-sdi.c (m32r_insert_breakpoint)
(m32r_remove_breakpoint): Likewise.
* remote-mips.c (mips_insert_breakpoint)
(mips_remove_breakpoint): Likewise.
* remote-rdp.c (remote_rdp_insert_breakpoint)
(remote_rdp_remove_breakpoint): Likewise.
(rdp_step): Use deprecated_insert_raw_breakpoint and
deprecated_remove_raw_breakpoint.
* remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint):
Update.
* remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint):
Delete.
(init_gdbsim_ops): Use memory_insert_breakpoint and
memory_remove_breakpoint.
* remote-st.c (st2000_insert_breakpoint)
(st2000_remove_breakpoint): Update. Remove unused
BREAKPOINT_FROM_PC.
* remote.c (remote_insert_breakpoint, remote_remove_breakpoint):
Update. Use placed_address and placed_size.
(remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise.
gdb/doc/
* gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert
and remove breakpoint prototypes.
(Watchpoints): Move description of target_insert_hw_breakpoint and
target_remove_hw_breakpoint ...
(Breakpoints): ... to here. Document target_insert_breakpoint and
target_remove_breakpoint.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r-- | gdb/breakpoint.c | 160 |
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. |