struct process_info *proc = current_process ();
struct raw_breakpoint *bp;
int err;
+ unsigned char buf[MAX_BREAKPOINT_LEN];
if (breakpoint_data == NULL)
error ("Target does not support breakpoints.");
/* Note that there can be fast tracepoint jumps installed in the
same memory range, so to get at the original memory, we need to
use read_inferior_memory, which masks those out. */
- err = read_inferior_memory (where, bp->old_data, breakpoint_len);
+ err = read_inferior_memory (where, buf, breakpoint_len);
if (err != 0)
{
if (debug_threads)
free (bp);
return NULL;
}
+ memcpy (bp->old_data, buf, breakpoint_len);
err = (*the_target->write_memory) (where, breakpoint_data,
breakpoint_len);
if (--bp->refcount == 0)
{
struct fast_tracepoint_jump *prev_bp_link = *bp_link;
+ unsigned char *buf;
/* Unlink it. */
*bp_link = bp->next;
pass the current shadow contents, because
write_inferior_memory updates any shadow memory with
what we pass here, and we want that to be a nop. */
- ret = write_inferior_memory (bp->pc,
- fast_tracepoint_jump_shadow (bp),
- bp->length);
+ buf = alloca (bp->length);
+ memcpy (buf, fast_tracepoint_jump_shadow (bp), bp->length);
+ ret = write_inferior_memory (bp->pc, buf, bp->length);
if (ret != 0)
{
/* Something went wrong, relink the jump. */
struct process_info *proc = current_process ();
struct fast_tracepoint_jump *jp;
int err;
+ unsigned char *buf;
/* We refcount fast tracepoint jumps. Check if we already know
about a jump at this address. */
jp->length = length;
memcpy (fast_tracepoint_jump_insn (jp), insn, length);
jp->refcount = 1;
+ buf = alloca (length);
/* Note that there can be trap breakpoints inserted in the same
address range. To access the original memory contents, we use
`read_inferior_memory', which masks out breakpoints. */
- err = read_inferior_memory (where,
- fast_tracepoint_jump_shadow (jp), jp->length);
+ err = read_inferior_memory (where, buf, length);
if (err != 0)
{
if (debug_threads)
free (jp);
return NULL;
}
+ memcpy (fast_tracepoint_jump_shadow (jp), buf, length);
/* Link the jump in. */
jp->inserted = 1;
the current shadow contents, because write_inferior_memory
updates any shadow memory with what we pass here, and we want
that to be a nop. */
- err = write_inferior_memory (where, fast_tracepoint_jump_shadow (jp),
- length);
+ err = write_inferior_memory (where, buf, length);
if (err != 0)
{
if (debug_threads)
if (jp->inserted)
{
+ unsigned char *buf;
+
jp->inserted = 0;
/* Since there can be trap breakpoints inserted in the same
pass the current shadow contents, because
write_inferior_memory updates any shadow memory with what we
pass here, and we want that to be a nop. */
- err = write_inferior_memory (jp->pc,
- fast_tracepoint_jump_shadow (jp),
- jp->length);
+ buf = alloca (jp->length);
+ memcpy (buf, fast_tracepoint_jump_shadow (jp), jp->length);
+ err = write_inferior_memory (jp->pc, buf, jp->length);
if (err != 0)
{
jp->inserted = 1;
{
struct fast_tracepoint_jump *jp;
int err;
+ unsigned char *buf;
jp = find_fast_tracepoint_jump_at (where);
if (jp == NULL)
to pass the current shadow contents, because
write_inferior_memory updates any shadow memory with what we pass
here, and we want that to be a nop. */
- err = write_inferior_memory (where,
- fast_tracepoint_jump_shadow (jp), jp->length);
+ buf = alloca (jp->length);
+ memcpy (buf, fast_tracepoint_jump_shadow (jp), jp->length);
+ err = write_inferior_memory (where, buf, jp->length);
if (err != 0)
{
jp->inserted = 0;
if (bp->inserted)
{
struct raw_breakpoint *prev_bp_link = *bp_link;
+ unsigned char buf[MAX_BREAKPOINT_LEN];
*bp_link = bp->next;
to pass the current shadow contents, because
write_inferior_memory updates any shadow memory with
what we pass here, and we want that to be a nop. */
- ret = write_inferior_memory (bp->pc, bp->old_data,
- breakpoint_len);
+ memcpy (buf, bp->old_data, breakpoint_len);
+ ret = write_inferior_memory (bp->pc, buf, breakpoint_len);
if (ret != 0)
{
/* Something went wrong, relink the breakpoint. */
if (bp->inserted)
{
int err;
+ unsigned char buf[MAX_BREAKPOINT_LEN];
bp->inserted = 0;
/* Since there can be fast tracepoint jumps inserted in the same
that we need to pass the current shadow contents, because
write_inferior_memory updates any shadow memory with what we
pass here, and we want that to be a nop. */
- err = write_inferior_memory (bp->pc, bp->old_data,
- breakpoint_len);
+ memcpy (buf, bp->old_data, breakpoint_len);
+ err = write_inferior_memory (bp->pc, buf, breakpoint_len);
if (err != 0)
{
bp->inserted = 1;
CORE_ADDR start, end;
int copy_offset, copy_len, buf_offset;
+ gdb_assert (fast_tracepoint_jump_shadow (jp) >= buf + mem_len
+ || buf >= fast_tracepoint_jump_shadow (jp) + (jp)->length);
+
if (mem_addr >= bp_end)
continue;
if (jp->pc >= mem_end)
CORE_ADDR start, end;
int copy_offset, copy_len, buf_offset;
+ gdb_assert (bp->old_data >= buf + mem_len
+ || buf >= &bp->old_data[sizeof (bp->old_data)]);
+
if (mem_addr >= bp_end)
continue;
if (bp->pc >= mem_end)
CORE_ADDR start, end;
int copy_offset, copy_len, buf_offset;
+ gdb_assert (fast_tracepoint_jump_shadow (jp) >= myaddr + mem_len
+ || myaddr >= fast_tracepoint_jump_shadow (jp) + (jp)->length);
+ gdb_assert (fast_tracepoint_jump_insn (jp) >= buf + mem_len
+ || buf >= fast_tracepoint_jump_insn (jp) + (jp)->length);
+
if (mem_addr >= jp_end)
continue;
if (jp->pc >= mem_end)
CORE_ADDR start, end;
int copy_offset, copy_len, buf_offset;
+ gdb_assert (bp->old_data >= myaddr + mem_len
+ || myaddr >= &bp->old_data[sizeof (bp->old_data)]);
+
if (mem_addr >= bp_end)
continue;
if (bp->pc >= mem_end)