Introduce gdb_breakpoint_up
This introduces gdb_breakpoint_up, a unique_ptr typedef that owns a breakpoint. It then changes set_momentary_breakpoint to return a gdb_breakpoint_up and fixes up the fallout. This then allows the removal of make_cleanup_delete_breakpoint. Once breakpoints are fully C++-ified, this typedef can be removed in favor of a plain std::unique_ptr. gdb/ChangeLog 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
This commit is contained in:
parent
331b71e5ee
commit
454dafbdf2
8 changed files with 63 additions and 41 deletions
|
@ -1,3 +1,27 @@
|
||||||
|
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>
|
2017-11-04 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* c-typeprint.c (c_type_print_base): Use gdb::unique_xmalloc_ptr.
|
* c-typeprint.c (c_type_print_base): Use gdb::unique_xmalloc_ptr.
|
||||||
|
|
|
@ -1020,7 +1020,7 @@ arm_linux_copy_svc (struct gdbarch *gdbarch, struct regcache *regs,
|
||||||
{
|
{
|
||||||
inferior_thread ()->control.step_resume_breakpoint
|
inferior_thread ()->control.step_resume_breakpoint
|
||||||
= set_momentary_breakpoint (gdbarch, sal, get_frame_id (frame),
|
= set_momentary_breakpoint (gdbarch, sal, get_frame_id (frame),
|
||||||
bp_step_resume);
|
bp_step_resume).release ();
|
||||||
|
|
||||||
/* set_momentary_breakpoint invalidates FRAME. */
|
/* set_momentary_breakpoint invalidates FRAME. */
|
||||||
frame = NULL;
|
frame = NULL;
|
||||||
|
|
|
@ -8582,7 +8582,7 @@ new_single_step_breakpoint (int thread, struct gdbarch *gdbarch)
|
||||||
SAL. If FRAME_ID is valid, the breakpoint is restricted to that
|
SAL. If FRAME_ID is valid, the breakpoint is restricted to that
|
||||||
frame. */
|
frame. */
|
||||||
|
|
||||||
struct breakpoint *
|
breakpoint_up
|
||||||
set_momentary_breakpoint (struct gdbarch *gdbarch, struct symtab_and_line sal,
|
set_momentary_breakpoint (struct gdbarch *gdbarch, struct symtab_and_line sal,
|
||||||
struct frame_id frame_id, enum bptype type)
|
struct frame_id frame_id, enum bptype type)
|
||||||
{
|
{
|
||||||
|
@ -8605,7 +8605,7 @@ set_momentary_breakpoint (struct gdbarch *gdbarch, struct symtab_and_line sal,
|
||||||
|
|
||||||
update_global_location_list_nothrow (UGLL_MAY_INSERT);
|
update_global_location_list_nothrow (UGLL_MAY_INSERT);
|
||||||
|
|
||||||
return b;
|
return breakpoint_up (b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make a momentary breakpoint based on the master breakpoint ORIG.
|
/* Make a momentary breakpoint based on the master breakpoint ORIG.
|
||||||
|
@ -8658,7 +8658,7 @@ clone_momentary_breakpoint (struct breakpoint *orig)
|
||||||
return momentary_breakpoint_from_master (orig, orig->type, orig->ops, 0);
|
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,
|
set_momentary_breakpoint_at_pc (struct gdbarch *gdbarch, CORE_ADDR pc,
|
||||||
enum bptype type)
|
enum bptype type)
|
||||||
{
|
{
|
||||||
|
@ -11146,8 +11146,8 @@ static struct thread_fsm_ops until_break_fsm_ops =
|
||||||
|
|
||||||
static struct until_break_fsm *
|
static struct until_break_fsm *
|
||||||
new_until_break_fsm (struct interp *cmd_interp, int thread,
|
new_until_break_fsm (struct interp *cmd_interp, int thread,
|
||||||
struct breakpoint *location_breakpoint,
|
breakpoint_up &&location_breakpoint,
|
||||||
struct breakpoint *caller_breakpoint)
|
breakpoint_up &&caller_breakpoint)
|
||||||
{
|
{
|
||||||
struct until_break_fsm *sm;
|
struct until_break_fsm *sm;
|
||||||
|
|
||||||
|
@ -11155,8 +11155,8 @@ new_until_break_fsm (struct interp *cmd_interp, int thread,
|
||||||
thread_fsm_ctor (&sm->thread_fsm, &until_break_fsm_ops, cmd_interp);
|
thread_fsm_ctor (&sm->thread_fsm, &until_break_fsm_ops, cmd_interp);
|
||||||
|
|
||||||
sm->thread = thread;
|
sm->thread = thread;
|
||||||
sm->location_breakpoint = location_breakpoint;
|
sm->location_breakpoint = location_breakpoint.release ();
|
||||||
sm->caller_breakpoint = caller_breakpoint;
|
sm->caller_breakpoint = caller_breakpoint.release ();
|
||||||
|
|
||||||
return sm;
|
return sm;
|
||||||
}
|
}
|
||||||
|
@ -11219,8 +11219,6 @@ until_break_command (const char *arg, int from_tty, int anywhere)
|
||||||
struct gdbarch *frame_gdbarch;
|
struct gdbarch *frame_gdbarch;
|
||||||
struct frame_id stack_frame_id;
|
struct frame_id stack_frame_id;
|
||||||
struct frame_id caller_frame_id;
|
struct frame_id caller_frame_id;
|
||||||
struct breakpoint *location_breakpoint;
|
|
||||||
struct breakpoint *caller_breakpoint = NULL;
|
|
||||||
struct cleanup *old_chain;
|
struct cleanup *old_chain;
|
||||||
int thread;
|
int thread;
|
||||||
struct thread_info *tp;
|
struct thread_info *tp;
|
||||||
|
@ -11269,6 +11267,7 @@ until_break_command (const char *arg, int from_tty, int anywhere)
|
||||||
/* Keep within the current frame, or in frames called by the current
|
/* Keep within the current frame, or in frames called by the current
|
||||||
one. */
|
one. */
|
||||||
|
|
||||||
|
breakpoint_up caller_breakpoint;
|
||||||
if (frame_id_p (caller_frame_id))
|
if (frame_id_p (caller_frame_id))
|
||||||
{
|
{
|
||||||
struct symtab_and_line sal2;
|
struct symtab_and_line sal2;
|
||||||
|
@ -11281,7 +11280,6 @@ until_break_command (const char *arg, int from_tty, int anywhere)
|
||||||
sal2,
|
sal2,
|
||||||
caller_frame_id,
|
caller_frame_id,
|
||||||
bp_until);
|
bp_until);
|
||||||
make_cleanup_delete_breakpoint (caller_breakpoint);
|
|
||||||
|
|
||||||
set_longjmp_breakpoint (tp, caller_frame_id);
|
set_longjmp_breakpoint (tp, caller_frame_id);
|
||||||
make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
|
make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
|
||||||
|
@ -11290,6 +11288,7 @@ until_break_command (const char *arg, int from_tty, int anywhere)
|
||||||
/* set_momentary_breakpoint could invalidate FRAME. */
|
/* set_momentary_breakpoint could invalidate FRAME. */
|
||||||
frame = NULL;
|
frame = NULL;
|
||||||
|
|
||||||
|
breakpoint_up location_breakpoint;
|
||||||
if (anywhere)
|
if (anywhere)
|
||||||
/* If the user told us to continue until a specified location,
|
/* If the user told us to continue until a specified location,
|
||||||
we don't specify a frame at which we need to stop. */
|
we don't specify a frame at which we need to stop. */
|
||||||
|
@ -11300,10 +11299,10 @@ until_break_command (const char *arg, int from_tty, int anywhere)
|
||||||
only at the very same frame. */
|
only at the very same frame. */
|
||||||
location_breakpoint = set_momentary_breakpoint (frame_gdbarch, sal,
|
location_breakpoint = set_momentary_breakpoint (frame_gdbarch, sal,
|
||||||
stack_frame_id, bp_until);
|
stack_frame_id, bp_until);
|
||||||
make_cleanup_delete_breakpoint (location_breakpoint);
|
|
||||||
|
|
||||||
sm = new_until_break_fsm (command_interp (), tp->global_num,
|
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;
|
tp->thread_fsm = &sm->thread_fsm;
|
||||||
|
|
||||||
discard_cleanups (old_chain);
|
discard_cleanups (old_chain);
|
||||||
|
@ -13366,18 +13365,6 @@ delete_breakpoint (struct breakpoint *bpt)
|
||||||
delete bpt;
|
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
|
/* Iterator function to call a user-provided callback function once
|
||||||
for each of B and its related breakpoints. */
|
for each of B and its related breakpoints. */
|
||||||
|
|
||||||
|
|
|
@ -1223,10 +1223,22 @@ extern void breakpoint_re_set (void);
|
||||||
|
|
||||||
extern void breakpoint_re_set_thread (struct breakpoint *);
|
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);
|
(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);
|
(struct gdbarch *, CORE_ADDR pc, enum bptype type);
|
||||||
|
|
||||||
extern struct breakpoint *clone_momentary_breakpoint (struct breakpoint *bpkt);
|
extern struct breakpoint *clone_momentary_breakpoint (struct breakpoint *bpkt);
|
||||||
|
@ -1235,10 +1247,6 @@ extern void set_ignore_count (int, int, int);
|
||||||
|
|
||||||
extern void breakpoint_init_inferior (enum inf_context);
|
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);
|
extern void breakpoint_auto_delete (bpstat);
|
||||||
|
|
||||||
typedef void (*walk_bp_location_callback) (struct bp_location *, void *);
|
typedef void (*walk_bp_location_callback) (struct bp_location *, void *);
|
||||||
|
|
|
@ -923,9 +923,10 @@ elf_gnu_ifunc_resolver_stop (struct breakpoint *b)
|
||||||
sal.pc = prev_pc;
|
sal.pc = prev_pc;
|
||||||
sal.section = find_pc_overlay (sal.pc);
|
sal.section = find_pc_overlay (sal.pc);
|
||||||
sal.explicit_pc = 1;
|
sal.explicit_pc = 1;
|
||||||
b_return = set_momentary_breakpoint (get_frame_arch (prev_frame), sal,
|
b_return
|
||||||
prev_frame_id,
|
= set_momentary_breakpoint (get_frame_arch (prev_frame), sal,
|
||||||
bp_gnu_ifunc_resolver_return);
|
prev_frame_id,
|
||||||
|
bp_gnu_ifunc_resolver_return).release ();
|
||||||
|
|
||||||
/* set_momentary_breakpoint invalidates PREV_FRAME. */
|
/* set_momentary_breakpoint invalidates PREV_FRAME. */
|
||||||
prev_frame = NULL;
|
prev_frame = NULL;
|
||||||
|
|
|
@ -1100,8 +1100,9 @@ call_function_by_hand_dummy (struct value *function,
|
||||||
/* Sanity. The exact same SP value is returned by
|
/* Sanity. The exact same SP value is returned by
|
||||||
PUSH_DUMMY_CALL, saved as the dummy-frame TOS, and used by
|
PUSH_DUMMY_CALL, saved as the dummy-frame TOS, and used by
|
||||||
dummy_id to form the frame ID's stack address. */
|
dummy_id to form the frame ID's stack address. */
|
||||||
breakpoint *bpt = set_momentary_breakpoint (gdbarch, sal,
|
breakpoint *bpt
|
||||||
dummy_id, bp_call_dummy);
|
= set_momentary_breakpoint (gdbarch, sal,
|
||||||
|
dummy_id, bp_call_dummy).release ();
|
||||||
|
|
||||||
/* set_momentary_breakpoint invalidates FRAME. */
|
/* set_momentary_breakpoint invalidates FRAME. */
|
||||||
frame = NULL;
|
frame = NULL;
|
||||||
|
|
|
@ -1986,7 +1986,7 @@ finish_forward (struct finish_command_fsm *sm, struct frame_info *frame)
|
||||||
|
|
||||||
sm->breakpoint = set_momentary_breakpoint (gdbarch, sal,
|
sm->breakpoint = set_momentary_breakpoint (gdbarch, sal,
|
||||||
get_stack_frame_id (frame),
|
get_stack_frame_id (frame),
|
||||||
bp_finish);
|
bp_finish).release ();
|
||||||
|
|
||||||
/* set_momentary_breakpoint invalidates FRAME. */
|
/* set_momentary_breakpoint invalidates FRAME. */
|
||||||
frame = NULL;
|
frame = NULL;
|
||||||
|
|
|
@ -7402,7 +7402,7 @@ insert_step_resume_breakpoint_at_sal_1 (struct gdbarch *gdbarch,
|
||||||
paddress (gdbarch, sr_sal.pc));
|
paddress (gdbarch, sr_sal.pc));
|
||||||
|
|
||||||
inferior_thread ()->control.step_resume_breakpoint
|
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
|
void
|
||||||
|
@ -7491,7 +7491,7 @@ insert_longjmp_resume_breakpoint (struct gdbarch *gdbarch, CORE_ADDR pc)
|
||||||
paddress (gdbarch, pc));
|
paddress (gdbarch, pc));
|
||||||
|
|
||||||
inferior_thread ()->control.exception_resume_breakpoint =
|
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
|
/* Insert an exception resume breakpoint. TP is the thread throwing
|
||||||
|
@ -7526,7 +7526,8 @@ insert_exception_resume_breakpoint (struct thread_info *tp,
|
||||||
(unsigned long) handler);
|
(unsigned long) handler);
|
||||||
|
|
||||||
bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame),
|
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. */
|
/* set_momentary_breakpoint_at_pc invalidates FRAME. */
|
||||||
frame = NULL;
|
frame = NULL;
|
||||||
|
@ -7567,7 +7568,7 @@ insert_exception_resume_from_probe (struct thread_info *tp,
|
||||||
handler));
|
handler));
|
||||||
|
|
||||||
bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame),
|
bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame),
|
||||||
handler, bp_exception_resume);
|
handler, bp_exception_resume).release ();
|
||||||
bp->thread = tp->global_num;
|
bp->thread = tp->global_num;
|
||||||
inferior_thread ()->control.exception_resume_breakpoint = bp;
|
inferior_thread ()->control.exception_resume_breakpoint = bp;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue