2017-11-04 Tom Tromey <tom@tromey.com>
+ * breakpoint.c (set_momentary_breakpoint): Return
+ breakpoint_up.
+ (until_break_command): Update.
+ (new_until_break_fsm): Change argument types to
+ breakpoint_up.
+ (set_momentary_breakpoint_at_pc): Return breakpoint_up.
+ (do_delete_breakpoint_cleanup, make_cleanup_delete_breakpoint):
+ Remove.
+ * infcmd.c (finish_forward): Update.
+ * breakpoint.h (set_momentary_breakpoint)
+ (set_momentary_breakpoint_at_pc): Return breakpoint_up.
+ (make_cleanup_delete_breakpoint): Remove.
+ (struct breakpoint_deleter): New.
+ (breakpoint_up): New typedef.
+ * infrun.c (insert_step_resume_breakpoint_at_sal_1): Update.
+ (insert_exception_resume_breakpoint): Update.
+ (insert_exception_resume_from_probe): Update.
+ (insert_longjmp_resume_breakpoint): Update.
+ * arm-linux-tdep.c (arm_linux_copy_svc): Update.
+ * elfread.c (elf_gnu_ifunc_resolver_stop): Update.
+ * infcall.c (call_function_by_hand_dummy): Update
+
+2017-11-04 Tom Tromey <tom@tromey.com>
+
* c-typeprint.c (c_type_print_base): Use gdb::unique_xmalloc_ptr.
2017-11-04 Tom Tromey <tom@tromey.com>
{
inferior_thread ()->control.step_resume_breakpoint
= set_momentary_breakpoint (gdbarch, sal, get_frame_id (frame),
- bp_step_resume);
+ bp_step_resume).release ();
/* set_momentary_breakpoint invalidates FRAME. */
frame = NULL;
SAL. If FRAME_ID is valid, the breakpoint is restricted to that
frame. */
-struct breakpoint *
+breakpoint_up
set_momentary_breakpoint (struct gdbarch *gdbarch, struct symtab_and_line sal,
struct frame_id frame_id, enum bptype type)
{
update_global_location_list_nothrow (UGLL_MAY_INSERT);
- return b;
+ return breakpoint_up (b);
}
/* Make a momentary breakpoint based on the master breakpoint ORIG.
return momentary_breakpoint_from_master (orig, orig->type, orig->ops, 0);
}
-struct breakpoint *
+breakpoint_up
set_momentary_breakpoint_at_pc (struct gdbarch *gdbarch, CORE_ADDR pc,
enum bptype type)
{
static struct until_break_fsm *
new_until_break_fsm (struct interp *cmd_interp, int thread,
- struct breakpoint *location_breakpoint,
- struct breakpoint *caller_breakpoint)
+ breakpoint_up &&location_breakpoint,
+ breakpoint_up &&caller_breakpoint)
{
struct until_break_fsm *sm;
thread_fsm_ctor (&sm->thread_fsm, &until_break_fsm_ops, cmd_interp);
sm->thread = thread;
- sm->location_breakpoint = location_breakpoint;
- sm->caller_breakpoint = caller_breakpoint;
+ sm->location_breakpoint = location_breakpoint.release ();
+ sm->caller_breakpoint = caller_breakpoint.release ();
return sm;
}
struct gdbarch *frame_gdbarch;
struct frame_id stack_frame_id;
struct frame_id caller_frame_id;
- struct breakpoint *location_breakpoint;
- struct breakpoint *caller_breakpoint = NULL;
struct cleanup *old_chain;
int thread;
struct thread_info *tp;
/* Keep within the current frame, or in frames called by the current
one. */
+ breakpoint_up caller_breakpoint;
if (frame_id_p (caller_frame_id))
{
struct symtab_and_line sal2;
sal2,
caller_frame_id,
bp_until);
- make_cleanup_delete_breakpoint (caller_breakpoint);
set_longjmp_breakpoint (tp, caller_frame_id);
make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
/* set_momentary_breakpoint could invalidate FRAME. */
frame = NULL;
+ breakpoint_up location_breakpoint;
if (anywhere)
/* If the user told us to continue until a specified location,
we don't specify a frame at which we need to stop. */
only at the very same frame. */
location_breakpoint = set_momentary_breakpoint (frame_gdbarch, sal,
stack_frame_id, bp_until);
- make_cleanup_delete_breakpoint (location_breakpoint);
sm = new_until_break_fsm (command_interp (), tp->global_num,
- location_breakpoint, caller_breakpoint);
+ std::move (location_breakpoint),
+ std::move (caller_breakpoint));
tp->thread_fsm = &sm->thread_fsm;
discard_cleanups (old_chain);
delete bpt;
}
-static void
-do_delete_breakpoint_cleanup (void *b)
-{
- delete_breakpoint ((struct breakpoint *) b);
-}
-
-struct cleanup *
-make_cleanup_delete_breakpoint (struct breakpoint *b)
-{
- return make_cleanup (do_delete_breakpoint_cleanup, b);
-}
-
/* Iterator function to call a user-provided callback function once
for each of B and its related breakpoints. */
extern void breakpoint_re_set_thread (struct breakpoint *);
-extern struct breakpoint *set_momentary_breakpoint
+extern void delete_breakpoint (struct breakpoint *);
+
+struct breakpoint_deleter
+{
+ void operator() (struct breakpoint *b) const
+ {
+ delete_breakpoint (b);
+ }
+};
+
+typedef std::unique_ptr<struct breakpoint, breakpoint_deleter> breakpoint_up;
+
+extern breakpoint_up set_momentary_breakpoint
(struct gdbarch *, struct symtab_and_line, struct frame_id, enum bptype);
-extern struct breakpoint *set_momentary_breakpoint_at_pc
+extern breakpoint_up set_momentary_breakpoint_at_pc
(struct gdbarch *, CORE_ADDR pc, enum bptype type);
extern struct breakpoint *clone_momentary_breakpoint (struct breakpoint *bpkt);
extern void breakpoint_init_inferior (enum inf_context);
-extern struct cleanup *make_cleanup_delete_breakpoint (struct breakpoint *);
-
-extern void delete_breakpoint (struct breakpoint *);
-
extern void breakpoint_auto_delete (bpstat);
typedef void (*walk_bp_location_callback) (struct bp_location *, void *);
sal.pc = prev_pc;
sal.section = find_pc_overlay (sal.pc);
sal.explicit_pc = 1;
- b_return = set_momentary_breakpoint (get_frame_arch (prev_frame), sal,
- prev_frame_id,
- bp_gnu_ifunc_resolver_return);
+ b_return
+ = set_momentary_breakpoint (get_frame_arch (prev_frame), sal,
+ prev_frame_id,
+ bp_gnu_ifunc_resolver_return).release ();
/* set_momentary_breakpoint invalidates PREV_FRAME. */
prev_frame = NULL;
/* Sanity. The exact same SP value is returned by
PUSH_DUMMY_CALL, saved as the dummy-frame TOS, and used by
dummy_id to form the frame ID's stack address. */
- breakpoint *bpt = set_momentary_breakpoint (gdbarch, sal,
- dummy_id, bp_call_dummy);
+ breakpoint *bpt
+ = set_momentary_breakpoint (gdbarch, sal,
+ dummy_id, bp_call_dummy).release ();
/* set_momentary_breakpoint invalidates FRAME. */
frame = NULL;
sm->breakpoint = set_momentary_breakpoint (gdbarch, sal,
get_stack_frame_id (frame),
- bp_finish);
+ bp_finish).release ();
/* set_momentary_breakpoint invalidates FRAME. */
frame = NULL;
paddress (gdbarch, sr_sal.pc));
inferior_thread ()->control.step_resume_breakpoint
- = set_momentary_breakpoint (gdbarch, sr_sal, sr_id, sr_type);
+ = set_momentary_breakpoint (gdbarch, sr_sal, sr_id, sr_type).release ();
}
void
paddress (gdbarch, pc));
inferior_thread ()->control.exception_resume_breakpoint =
- set_momentary_breakpoint_at_pc (gdbarch, pc, bp_longjmp_resume);
+ set_momentary_breakpoint_at_pc (gdbarch, pc, bp_longjmp_resume).release ();
}
/* Insert an exception resume breakpoint. TP is the thread throwing
(unsigned long) handler);
bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame),
- handler, bp_exception_resume);
+ handler,
+ bp_exception_resume).release ();
/* set_momentary_breakpoint_at_pc invalidates FRAME. */
frame = NULL;
handler));
bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame),
- handler, bp_exception_resume);
+ handler, bp_exception_resume).release ();
bp->thread = tp->global_num;
inferior_thread ()->control.exception_resume_breakpoint = bp;
}