/* Memory breakpoint operations for the remote server for GDB.
- Copyright (C) 2002-2017 Free Software Foundation, Inc.
+ Copyright (C) 2002-2019 Free Software Foundation, Inc.
Contributed by MontaVista Software.
|| type == gdb_breakpoint_Z4);
}
-int
-any_persistent_commands (void)
+bool
+any_persistent_commands (process_info *proc)
{
- struct process_info *proc = current_process ();
struct breakpoint *bp;
struct point_command_list *cl;
for (cl = gdb_bp->command_list; cl != NULL; cl = cl->next)
if (cl->persistence)
- return 1;
+ return true;
}
}
- return 0;
+ return false;
}
/* Find low-level breakpoint of type TYPE at address ADDR that is not
int err;
/* Since there can be trap breakpoints inserted in the same address
- range, we use `write_inferior_memory', which takes care of
+ range, we use `target_write_memory', which takes care of
layering breakpoints on top of fast tracepoints, and on top of
the buffer we pass it. This works because the caller has already
either unlinked the breakpoint or marked it uninserted. Also
note that we need to pass the current shadow contents, because
- write_inferior_memory updates any shadow memory with what we pass
+ target_write_memory updates any shadow memory with what we pass
here, and we want that to be a nop. */
memcpy (buf, bp->old_data, bp_size (bp));
- err = write_inferior_memory (bp->pc, buf, bp_size (bp));
+ err = target_write_memory (bp->pc, buf, bp_size (bp));
if (err != 0)
{
if (debug_threads)
{
struct process_info *proc = current_process ();
struct raw_breakpoint *bp;
- struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
if (type == raw_bkpt_type_sw || type == raw_bkpt_type_hw)
{
else
bp = find_raw_breakpoint_at (where, type, kind);
+ gdb::unique_xmalloc_ptr<struct raw_breakpoint> bp_holder;
if (bp == NULL)
{
- bp = XCNEW (struct raw_breakpoint);
+ bp_holder.reset (XCNEW (struct raw_breakpoint));
+ bp = bp_holder.get ();
bp->pc = where;
bp->kind = kind;
bp->raw_type = type;
- make_cleanup (xfree, bp);
}
if (!bp->inserted)
debug_printf ("Failed to insert breakpoint at 0x%s (%d).\n",
paddress (where), *err);
- do_cleanups (old_chain);
return NULL;
}
bp->inserted = 1;
}
- discard_cleanups (old_chain);
+ /* If the breakpoint was allocated above, we know we want to keep it
+ now. */
+ bp_holder.release ();
/* Link the breakpoint in, if this is the first reference. */
if (++bp->refcount == 1)
*bp_link = bp->next;
/* Since there can be breakpoints inserted in the same
- address range, we use `write_inferior_memory', which
+ address range, we use `target_write_memory', which
takes care of layering breakpoints on top of fast
tracepoints, and on top of the buffer we pass it.
This works because we've already unlinked the fast
tracepoint jump above. Also note that we need to
pass the current shadow contents, because
- write_inferior_memory updates any shadow memory with
+ target_write_memory updates any shadow memory with
what we pass here, and we want that to be a nop. */
buf = (unsigned char *) alloca (bp->length);
memcpy (buf, fast_tracepoint_jump_shadow (bp), bp->length);
- ret = write_inferior_memory (bp->pc, buf, bp->length);
+ ret = target_write_memory (bp->pc, buf, bp->length);
if (ret != 0)
{
/* Something went wrong, relink the jump. */
proc->fast_tracepoint_jumps = jp;
/* Since there can be trap breakpoints inserted in the same address
- range, we use use `write_inferior_memory', which takes care of
+ range, we use use `target_write_memory', which takes care of
layering breakpoints on top of fast tracepoints, on top of the
buffer we pass it. This works because we've already linked in
the fast tracepoint jump above. Also note that we need to pass
- the current shadow contents, because write_inferior_memory
+ the current shadow contents, because target_write_memory
updates any shadow memory with what we pass here, and we want
that to be a nop. */
- err = write_inferior_memory (where, buf, length);
+ err = target_write_memory (where, buf, length);
if (err != 0)
{
if (debug_threads)
jp->inserted = 0;
/* Since there can be trap breakpoints inserted in the same
- address range, we use use `write_inferior_memory', which
+ address range, we use use `target_write_memory', which
takes care of layering breakpoints on top of fast
tracepoints, and on top of the buffer we pass it. This works
because we've already marked the fast tracepoint fast
tracepoint jump uninserted above. Also note that we need to
pass the current shadow contents, because
- write_inferior_memory updates any shadow memory with what we
+ target_write_memory updates any shadow memory with what we
pass here, and we want that to be a nop. */
buf = (unsigned char *) alloca (jp->length);
memcpy (buf, fast_tracepoint_jump_shadow (jp), jp->length);
- err = write_inferior_memory (jp->pc, buf, jp->length);
+ err = target_write_memory (jp->pc, buf, jp->length);
if (err != 0)
{
jp->inserted = 1;
jp->inserted = 1;
/* Since there can be trap breakpoints inserted in the same address
- range, we use `write_inferior_memory', which takes care of
+ range, we use `target_write_memory', which takes care of
layering breakpoints on top of fast tracepoints, and on top of
the buffer we pass it. This works because we've already marked
the fast tracepoint jump inserted above. Also note that we need
to pass the current shadow contents, because
- write_inferior_memory updates any shadow memory with what we pass
+ target_write_memory updates any shadow memory with what we pass
here, and we want that to be a nop. */
buf = (unsigned char *) alloca (jp->length);
memcpy (buf, fast_tracepoint_jump_shadow (jp), jp->length);
- err = write_inferior_memory (where, buf, jp->length);
+ err = target_write_memory (where, buf, jp->length);
if (err != 0)
{
jp->inserted = 0;
/* Add a target-side condition CONDITION to a breakpoint. */
int
-add_breakpoint_condition (struct gdb_breakpoint *bp, char **condition)
+add_breakpoint_condition (struct gdb_breakpoint *bp, const char **condition)
{
- char *actparm = *condition;
+ const char *actparm = *condition;
struct agent_expr *cond;
if (condition == NULL)
/* Add a target-side command COMMAND to the breakpoint at ADDR. */
int
-add_breakpoint_commands (struct gdb_breakpoint *bp, char **command,
+add_breakpoint_commands (struct gdb_breakpoint *bp, const char **command,
int persist)
{
- char *actparm = *command;
+ const char *actparm = *command;
struct agent_expr *cmd;
if (command == NULL)
{
struct single_step_breakpoint *bp;
- gdb_assert (ptid_get_pid (current_ptid) == ptid_get_pid (ptid));
+ gdb_assert (current_ptid.pid () == ptid.pid ());
bp = (struct single_step_breakpoint *) set_breakpoint_type_at (single_step_breakpoint,
stop_at, NULL);
while (bp)
{
if (bp->type == single_step_breakpoint
- && ptid_equal (((struct single_step_breakpoint *) bp)->ptid,
- ptid_of (thread)))
+ && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
{
struct thread_info *saved_thread = current_thread;
for (bp = proc->breakpoints; bp != NULL; bp = bp->next)
{
if (bp->type == single_step_breakpoint
- && ptid_equal (((struct single_step_breakpoint *) bp)->ptid,
- ptid_of (thread)))
+ && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
{
gdb_assert (bp->raw->inserted > 0);
while (bp)
{
if (bp->type == single_step_breakpoint
- && ptid_equal (((struct single_step_breakpoint *) bp)->ptid,
- ptid_of (thread)))
+ && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
return 1;
else
{
for (bp = proc->breakpoints; bp != NULL; bp = bp->next)
{
if (bp->type == single_step_breakpoint
- && ptid_equal (((struct single_step_breakpoint *) bp)->ptid,
- ptid_of (thread)))
+ && ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
{
gdb_assert (bp->raw->inserted > 0);