aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-12-06 20:03:14 +0000
committerPedro Alves <palves@redhat.com>2011-12-06 20:03:14 +0000
commitf0ba3972e968a8f328d2d465bbd1218e228fbf2a (patch)
treedaeb62e5fc8f74947ee31f0f14a3bcccd14f2006 /gdb/breakpoint.c
parent31aba06f31d348be54adb50195af858baff6256f (diff)
downloadgdb-f0ba3972e968a8f328d2d465bbd1218e228fbf2a.zip
gdb-f0ba3972e968a8f328d2d465bbd1218e228fbf2a.tar.gz
gdb-f0ba3972e968a8f328d2d465bbd1218e228fbf2a.tar.bz2
2011-12-06 Pedro Alves <pedro@codesourcery.com>
gdb/ * breakpoint.c (breakpoint_restore_shadows): Rename to ... (breakpoint_xfer_memory): ... this. Change prototype. Handle memory writes too. * breakpoint.h (breakpoint_restore_shadows): Delete. (breakpoint_xfer_memory): Declare. * mem-break.c (default_memory_insert_breakpoint) (default_memory_remove_breakpoint): Use target_write_raw_memory. (memory_xfer_partial): Rename to ... (memory_xfer_partial_1): ... this. Don't mask out breakpoints here. (memory_xfer_partial): New. (target_write_raw_memory): New. * target.h (target_write_raw_memory): New. gdb/testsuite/ * gdb.base/break-always.exp: Test changing memory at addresses with breakpoints inserted.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index bd0a0e3..d9d5bbe 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1049,7 +1049,9 @@ bp_location_has_shadow (struct bp_location *bl)
bl->address + bp_location_shadow_len_after_address_max <= memaddr */
void
-breakpoint_restore_shadows (gdb_byte *buf, ULONGEST memaddr, LONGEST len)
+breakpoint_xfer_memory (gdb_byte *readbuf, gdb_byte *writebuf,
+ const gdb_byte *writebuf_org,
+ ULONGEST memaddr, LONGEST len)
{
/* Left boundary, right boundary and median element of our binary
search. */
@@ -1161,8 +1163,32 @@ breakpoint_restore_shadows (gdb_byte *buf, ULONGEST memaddr, LONGEST len)
bp_size -= (bp_addr + bp_size) - (memaddr + len);
}
- memcpy (buf + bp_addr - memaddr,
- bl->target_info.shadow_contents + bptoffset, bp_size);
+ if (readbuf != NULL)
+ {
+ /* Update the read buffer with this inserted breakpoint's
+ shadow. */
+ memcpy (readbuf + bp_addr - memaddr,
+ bl->target_info.shadow_contents + bptoffset, bp_size);
+ }
+ else
+ {
+ struct gdbarch *gdbarch = bl->gdbarch;
+ const unsigned char *bp;
+ CORE_ADDR placed_address = bl->target_info.placed_address;
+ unsigned placed_size = bl->target_info.placed_size;
+
+ /* Update the shadow with what we want to write to memory. */
+ memcpy (bl->target_info.shadow_contents + bptoffset,
+ writebuf_org + bp_addr - memaddr, bp_size);
+
+ /* Determine appropriate breakpoint contents and size for this
+ address. */
+ bp = gdbarch_breakpoint_from_pc (gdbarch, &placed_address, &placed_size);
+
+ /* Update the final write buffer with this inserted
+ breakpoint's INSN. */
+ memcpy (writebuf + bp_addr - memaddr, bp + bptoffset, bp_size);
+ }
}
}