/* Add breakpoint B at the end of the global breakpoint chain. */
-static void
-add_to_breakpoint_chain (struct breakpoint *b)
+static breakpoint *
+add_to_breakpoint_chain (std::unique_ptr<breakpoint> &&b)
{
struct breakpoint *b1;
+ struct breakpoint *result = b.get ();
/* Add this breakpoint to the end of the chain so that a list of
breakpoints will come out in order of increasing numbers. */
b1 = breakpoint_chain;
if (b1 == 0)
- breakpoint_chain = b;
+ breakpoint_chain = b.release ();
else
{
while (b1->next)
b1 = b1->next;
- b1->next = b;
+ b1->next = b.release ();
}
+
+ return result;
}
/* Initializes breakpoint B with type BPTYPE and no locations yet. */
std::unique_ptr<breakpoint> b = new_breakpoint_from_type (bptype);
init_raw_breakpoint_without_location (b.get (), gdbarch, bptype, ops);
- add_to_breakpoint_chain (b.get ());
-
- return b.release ();
+ return add_to_breakpoint_chain (std::move (b));
}
/* Initialize loc->function_name. EXPLICIT_LOC says no indirect function
std::unique_ptr<breakpoint> b = new_breakpoint_from_type (bptype);
init_raw_breakpoint (b.get (), gdbarch, sal, bptype, ops);
- add_to_breakpoint_chain (b.get ());
-
- return b.release ();
+ return add_to_breakpoint_chain (std::move (b));
}
/* Call this routine when stepping and nexting to enable a breakpoint
c->enable_state = enabled ? bp_enabled : bp_disabled;
- install_breakpoint (0, c.release (), 1);
+ install_breakpoint (0, std::move (c), 1);
}
/* A helper function that does all the work for "catch load" and
}
void
-install_breakpoint (int internal, struct breakpoint *b, int update_gll)
+install_breakpoint (int internal, std::unique_ptr<breakpoint> &&arg, int update_gll)
{
- add_to_breakpoint_chain (b);
+ breakpoint *b = add_to_breakpoint_chain (std::move (arg));
set_breakpoint_number (internal, b);
if (is_tracepoint (b))
set_tracepoint_count (breakpoint_count);
int tempflag, const char *cond_string,
const struct breakpoint_ops *ops)
{
- struct fork_catchpoint *c = new fork_catchpoint ();
+ std::unique_ptr<fork_catchpoint> c (new fork_catchpoint ());
- init_catchpoint (c, gdbarch, tempflag, cond_string, ops);
+ init_catchpoint (c.get (), gdbarch, tempflag, cond_string, ops);
c->forked_inferior_pid = null_ptid;
- install_breakpoint (0, c, 1);
+ install_breakpoint (0, std::move (c), 1);
}
/* Exec catchpoints. */
static struct breakpoint *
new_single_step_breakpoint (int thread, struct gdbarch *gdbarch)
{
- struct breakpoint *b = new breakpoint ();
+ std::unique_ptr<breakpoint> b (new breakpoint ());
- init_raw_breakpoint_without_location (b, gdbarch, bp_single_step,
+ init_raw_breakpoint_without_location (b.get (), gdbarch, bp_single_step,
&momentary_breakpoint_ops);
b->disposition = disp_donttouch;
b->thread = thread;
gdb_assert (b->thread != 0);
- add_to_breakpoint_chain (b);
-
- return b;
+ return add_to_breakpoint_chain (std::move (b));
}
/* Set a momentary breakpoint of type TYPE at address specified by
enabled, internal, flags,
display_canonical);
- install_breakpoint (internal, b.release (), 0);
+ install_breakpoint (internal, std::move (b), 0);
}
/* Add SALS.nelts breakpoints to the breakpoint table. For each
&& type_wanted != bp_hardware_breakpoint) || thread != -1)
b->pspace = current_program_space;
- install_breakpoint (internal, b.release (), 0);
+ install_breakpoint (internal, std::move (b), 0);
}
if (VEC_length (linespec_sals, canonical.sals) > 1)
the hardware watchpoint. */
int use_mask = 0;
CORE_ADDR mask = 0;
- struct watchpoint *w;
char *expression;
struct cleanup *back_to;
else
bp_type = bp_hardware_watchpoint;
- w = new watchpoint ();
+ std::unique_ptr<watchpoint> w (new watchpoint ());
if (use_mask)
- init_raw_breakpoint_without_location (w, NULL, bp_type,
+ init_raw_breakpoint_without_location (w.get (), NULL, bp_type,
&masked_watchpoint_breakpoint_ops);
else
- init_raw_breakpoint_without_location (w, NULL, bp_type,
+ init_raw_breakpoint_without_location (w.get (), NULL, bp_type,
&watchpoint_breakpoint_ops);
w->thread = thread;
w->disposition = disp_donttouch;
/* The scope breakpoint is related to the watchpoint. We will
need to act on them together. */
w->related_breakpoint = scope_breakpoint;
- scope_breakpoint->related_breakpoint = w;
+ scope_breakpoint->related_breakpoint = w.get ();
}
if (!just_location)
value_free_to_mark (mark);
- TRY
- {
- /* Finally update the new watchpoint. This creates the locations
- that should be inserted. */
- update_watchpoint (w, 1);
- }
- CATCH (e, RETURN_MASK_ALL)
- {
- delete_breakpoint (w);
- throw_exception (e);
- }
- END_CATCH
+ /* Finally update the new watchpoint. This creates the locations
+ that should be inserted. */
+ update_watchpoint (w.get (), 1);
- install_breakpoint (internal, w, 1);
+ install_breakpoint (internal, std::move (w), 1);
do_cleanups (back_to);
}
struct cmd_list_element *command)
{
const char *arg = arg_entry;
- struct exec_catchpoint *c;
struct gdbarch *gdbarch = get_current_arch ();
int tempflag;
const char *cond_string = NULL;
if ((*arg != '\0') && !isspace (*arg))
error (_("Junk at end of arguments."));
- c = new exec_catchpoint ();
- init_catchpoint (c, gdbarch, tempflag, cond_string,
+ std::unique_ptr<exec_catchpoint> c (new exec_catchpoint ());
+ init_catchpoint (c.get (), gdbarch, tempflag, cond_string,
&catch_exec_breakpoint_ops);
c->exec_pathname = NULL;
- install_breakpoint (0, c, 1);
+ install_breakpoint (0, std::move (c), 1);
}
void
for (i = 0; i < lsal->sals.nelts; ++i)
{
struct symtabs_and_lines expanded;
- struct tracepoint *tp;
event_location_up location;
expanded.nelts = 1;
location = copy_event_location (canonical->location.get ());
- tp = new tracepoint ();
- init_breakpoint_sal (tp, gdbarch, expanded,
+ std::unique_ptr<tracepoint> tp (new tracepoint ());
+ init_breakpoint_sal (tp.get (), gdbarch, expanded,
std::move (location), NULL,
std::move (cond_string),
std::move (extra_string),
corresponds to this one */
tp->static_trace_marker_id_idx = i;
- install_breakpoint (internal, tp, 0);
+ install_breakpoint (internal, std::move (tp), 0);
}
}