aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-11-01 22:32:45 -0600
committerTom Tromey <tom@tromey.com>2017-11-04 10:27:20 -0600
commit454dafbdf2d1293a9b18a6fe9e9c9e0911eb740c (patch)
treef33b5a538c368cfafb7784aa18e3cd6251aa74dd /gdb/breakpoint.c
parent331b71e5ee226cb5455969899274f0e43e83aa1e (diff)
downloadgdb-454dafbdf2d1293a9b18a6fe9e9c9e0911eb740c.zip
gdb-454dafbdf2d1293a9b18a6fe9e9c9e0911eb740c.tar.gz
gdb-454dafbdf2d1293a9b18a6fe9e9c9e0911eb740c.tar.bz2
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
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c35
1 files changed, 11 insertions, 24 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 61e4128..adc8950 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -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
frame. */
-struct breakpoint *
+breakpoint_up
set_momentary_breakpoint (struct gdbarch *gdbarch, struct symtab_and_line sal,
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);
- return b;
+ return breakpoint_up (b);
}
/* 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);
}
-struct breakpoint *
+breakpoint_up
set_momentary_breakpoint_at_pc (struct gdbarch *gdbarch, CORE_ADDR pc,
enum bptype type)
{
@@ -11146,8 +11146,8 @@ static struct thread_fsm_ops until_break_fsm_ops =
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;
@@ -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);
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;
}
@@ -11219,8 +11219,6 @@ until_break_command (const char *arg, int from_tty, int anywhere)
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;
@@ -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
one. */
+ breakpoint_up caller_breakpoint;
if (frame_id_p (caller_frame_id))
{
struct symtab_and_line sal2;
@@ -11281,7 +11280,6 @@ until_break_command (const char *arg, int from_tty, int anywhere)
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);
@@ -11290,6 +11288,7 @@ until_break_command (const char *arg, int from_tty, int anywhere)
/* 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. */
@@ -11300,10 +11299,10 @@ until_break_command (const char *arg, int from_tty, int anywhere)
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);
@@ -13366,18 +13365,6 @@ delete_breakpoint (struct breakpoint *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
for each of B and its related breakpoints. */