#include "dummy-frame.h"
#include "interps.h"
#include "format.h"
-#include "location.h"
#include "thread-fsm.h"
#include "tid-parse.h"
#include "mi/mi-common.h"
#include "extension.h"
#include <algorithm>
+#include "progspace-and-thread.h"
/* Enums for exception-handling support. */
enum exception_event_kind
copied into the command, so it can be anything that GDB can
evaluate to a callable address, not necessarily a function name. */
-static char *dprintf_function = "";
+static char *dprintf_function;
/* The channel to use for dynamic printf if the preferred style is to
call into the inferior; if a nonempty string, it will be passed to
"stderr", this could be an app-specific expression like
"mystreams[curlogger]". */
-static char *dprintf_channel = "";
+static char *dprintf_channel;
/* True if dprintf commands should continue to operate even if GDB
has disconnected. */
while executing the block of ALL_BP_LOCATIONS. */
#define ALL_BP_LOCATIONS(B,BP_TMP) \
- for (BP_TMP = bp_location; \
- BP_TMP < bp_location + bp_location_count && (B = *BP_TMP); \
+ for (BP_TMP = bp_locations; \
+ BP_TMP < bp_locations + bp_locations_count && (B = *BP_TMP);\
BP_TMP++)
/* Iterates through locations with address ADDRESS for the currently selected
for (BP_LOCP_START = BP_LOCP_START == NULL ? get_first_locp_gte_addr (ADDRESS) : BP_LOCP_START, \
BP_LOCP_TMP = BP_LOCP_START; \
BP_LOCP_START \
- && (BP_LOCP_TMP < bp_location + bp_location_count \
+ && (BP_LOCP_TMP < bp_locations + bp_locations_count \
&& (*BP_LOCP_TMP)->address == ADDRESS); \
BP_LOCP_TMP++)
struct breakpoint *breakpoint_chain;
-/* Array is sorted by bp_location_compare - primarily by the ADDRESS. */
+/* Array is sorted by bp_locations_compare - primarily by the ADDRESS. */
-static struct bp_location **bp_location;
+static struct bp_location **bp_locations;
-/* Number of elements of BP_LOCATION. */
+/* Number of elements of BP_LOCATIONS. */
-static unsigned bp_location_count;
+static unsigned bp_locations_count;
/* Maximum alignment offset between bp_target_info.PLACED_ADDRESS and
- ADDRESS for the current elements of BP_LOCATION which get a valid
+ ADDRESS for the current elements of BP_LOCATIONS which get a valid
result from bp_location_has_shadow. You can use it for roughly
- limiting the subrange of BP_LOCATION to scan for shadow bytes for
+ limiting the subrange of BP_LOCATIONS to scan for shadow bytes for
an address you need to read. */
-static CORE_ADDR bp_location_placed_address_before_address_max;
+static CORE_ADDR bp_locations_placed_address_before_address_max;
/* Maximum offset plus alignment between bp_target_info.PLACED_ADDRESS
+ bp_target_info.SHADOW_LEN and ADDRESS for the current elements of
- BP_LOCATION which get a valid result from bp_location_has_shadow.
- You can use it for roughly limiting the subrange of BP_LOCATION to
+ BP_LOCATIONS which get a valid result from bp_location_has_shadow.
+ You can use it for roughly limiting the subrange of BP_LOCATIONS to
scan for shadow bytes for an address you need to read. */
-static CORE_ADDR bp_location_shadow_len_after_address_max;
+static CORE_ADDR bp_locations_shadow_len_after_address_max;
/* The locations that no longer correspond to any breakpoint, unlinked
- from bp_location array, but for which a hit may still be reported
- by a target. */
+ from the bp_locations array, but for which a hit may still be
+ reported by a target. */
VEC(bp_location_p) *moribund_locations = NULL;
/* Number of last breakpoint made. */
/* A comparison function for bp_location AP and BP that is used by
bsearch. This comparison function only cares about addresses, unlike
- the more general bp_location_compare function. */
+ the more general bp_locations_compare function. */
static int
-bp_location_compare_addrs (const void *ap, const void *bp)
+bp_locations_compare_addrs (const void *ap, const void *bp)
{
const struct bp_location *a = *(const struct bp_location **) ap;
const struct bp_location *b = *(const struct bp_location **) bp;
struct bp_location **locp_found = NULL;
/* Initialize the dummy location's address field. */
- memset (&dummy_loc, 0, sizeof (struct bp_location));
dummy_loc.address = address;
/* Find a close match to the first location at ADDRESS. */
locp_found = ((struct bp_location **)
- bsearch (&dummy_locp, bp_location, bp_location_count,
+ bsearch (&dummy_locp, bp_locations, bp_locations_count,
sizeof (struct bp_location **),
- bp_location_compare_addrs));
+ bp_locations_compare_addrs));
/* Nothing was found, nothing left to do. */
if (locp_found == NULL)
/* We may have found a location that is at ADDRESS but is not the first in the
location's list. Go backwards (if possible) and locate the first one. */
- while ((locp_found - 1) >= bp_location
+ while ((locp_found - 1) >= bp_locations
&& (*(locp_found - 1))->address == address)
locp_found--;
void
breakpoint_set_commands (struct breakpoint *b,
- struct command_line *commands)
+ command_line_up &&commands)
{
- validate_commands_for_breakpoint (b, commands);
+ validate_commands_for_breakpoint (b, commands.get ());
decref_counted_command_line (&b->commands);
- b->commands = alloc_counted_command_line (commands);
+ b->commands = alloc_counted_command_line (commands.release ());
observer_notify_breakpoint_modified (b);
}
if (info->cmd == NULL)
{
- struct command_line *l;
+ command_line_up l;
if (info->control != NULL)
l = copy_command_lines (info->control->body_list[0]);
do_cleanups (old_chain);
}
- info->cmd = alloc_counted_command_line (l);
+ info->cmd = alloc_counted_command_line (l.release ());
}
/* If a breakpoint was on the list more than once, we don't need to
a failed assertion internal error will be raised.
The range of shadowed area by each bp_location is:
- bl->address - bp_location_placed_address_before_address_max
- up to bl->address + bp_location_shadow_len_after_address_max
+ bl->address - bp_locations_placed_address_before_address_max
+ up to bl->address + bp_locations_shadow_len_after_address_max
The range we were requested to resolve shadows for is:
memaddr ... memaddr + len
Thus the safe cutoff boundaries for performance optimization are
memaddr + len <= (bl->address
- - bp_location_placed_address_before_address_max)
+ - bp_locations_placed_address_before_address_max)
and:
- bl->address + bp_location_shadow_len_after_address_max <= memaddr */
+ bl->address + bp_locations_shadow_len_after_address_max <= memaddr */
void
breakpoint_xfer_memory (gdb_byte *readbuf, gdb_byte *writebuf,
report higher one. */
bc_l = 0;
- bc_r = bp_location_count;
+ bc_r = bp_locations_count;
while (bc_l + 1 < bc_r)
{
struct bp_location *bl;
bc = (bc_l + bc_r) / 2;
- bl = bp_location[bc];
+ bl = bp_locations[bc];
/* Check first BL->ADDRESS will not overflow due to the added
constant. Then advance the left boundary only if we are sure
the BC element can in no way affect the BUF content (MEMADDR
to MEMADDR + LEN range).
- Use the BP_LOCATION_SHADOW_LEN_AFTER_ADDRESS_MAX safety
+ Use the BP_LOCATIONS_SHADOW_LEN_AFTER_ADDRESS_MAX safety
offset so that we cannot miss a breakpoint with its shadow
range tail still reaching MEMADDR. */
- if ((bl->address + bp_location_shadow_len_after_address_max
+ if ((bl->address + bp_locations_shadow_len_after_address_max
>= bl->address)
- && (bl->address + bp_location_shadow_len_after_address_max
+ && (bl->address + bp_locations_shadow_len_after_address_max
<= memaddr))
bc_l = bc;
else
on "master" locations, we'd forget to restore the shadow of L1
and L2. */
while (bc_l > 0
- && bp_location[bc_l]->address == bp_location[bc_l - 1]->address)
+ && bp_locations[bc_l]->address == bp_locations[bc_l - 1]->address)
bc_l--;
/* Now do full processing of the found relevant range of elements. */
- for (bc = bc_l; bc < bp_location_count; bc++)
+ for (bc = bc_l; bc < bp_locations_count; bc++)
{
- struct bp_location *bl = bp_location[bc];
+ struct bp_location *bl = bp_locations[bc];
/* bp_location array has BL->OWNER always non-NULL. */
if (bl->owner->type == bp_none)
/* Performance optimization: any further element can no longer affect BUF
content. */
- if (bl->address >= bp_location_placed_address_before_address_max
- && memaddr + len <= (bl->address
- - bp_location_placed_address_before_address_max))
+ if (bl->address >= bp_locations_placed_address_before_address_max
+ && memaddr + len <= (bl->address
+ - bp_locations_placed_address_before_address_max))
break;
if (!bp_location_has_shadow (bl))
there was an error. */
tmp_error_stream.puts ("Warning:\n");
- struct cleanup *cleanups = save_current_space_and_thread ();
+ scoped_restore_current_pspace_and_thread restore_pspace_thread;
ALL_BP_LOCATIONS (bl, blp_tmp)
{
target_terminal_ours_for_output ();
error_stream (tmp_error_stream);
}
-
- do_cleanups (cleanups);
}
/* Used when starting or continuing the program. */
there was an error. */
tmp_error_stream.puts ("Warning:\n");
- struct cleanup *cleanups = save_current_space_and_thread ();
+ scoped_restore_current_pspace_and_thread restore_pspace_thread;
ALL_BP_LOCATIONS (bl, blp_tmp)
{
target_terminal_ours_for_output ();
error_stream (tmp_error_stream);
}
-
- do_cleanups (cleanups);
}
/* Used when the program stops.
create_longjmp_master_breakpoint (void)
{
struct program_space *pspace;
- struct cleanup *old_chain;
- old_chain = save_current_program_space ();
+ scoped_restore_current_program_space restore_pspace;
ALL_PSPACES (pspace)
{
objfile),
bp_longjmp_master,
&internal_breakpoint_ops);
- b->location
- = new_probe_location ("-probe-stap libc:longjmp");
+ b->location = new_probe_location ("-probe-stap libc:longjmp");
b->enable_state = bp_disabled;
}
}
}
}
-
- do_cleanups (old_chain);
}
/* Create a master std::terminate breakpoint. */
create_std_terminate_master_breakpoint (void)
{
struct program_space *pspace;
- struct cleanup *old_chain;
const char *const func_name = "std::terminate()";
- old_chain = save_current_program_space ();
+ scoped_restore_current_program_space restore_pspace;
ALL_PSPACES (pspace)
{
b->enable_state = bp_disabled;
}
}
-
- do_cleanups (old_chain);
}
/* Install a master breakpoint on the unwinder's debug hook. */
objfile),
bp_exception_master,
&internal_breakpoint_ops);
- b->location
- = new_probe_location ("-probe-stap libgcc:unwind");
+ b->location = new_probe_location ("-probe-stap libgcc:unwind");
b->enable_state = bp_disabled;
}
static int
breakpoint_event_location_empty_p (const struct breakpoint *b)
{
- return b->location != NULL && event_location_empty_p (b->location);
+ return b->location != NULL && event_location_empty_p (b->location.get ());
}
void
static int
remove_breakpoint (struct bp_location *bl)
{
- int ret;
- struct cleanup *old_chain;
-
/* BL is never in moribund_locations by our callers. */
gdb_assert (bl->owner != NULL);
This should not ever happen. */
gdb_assert (bl->owner->type != bp_none);
- old_chain = save_current_space_and_thread ();
+ scoped_restore_current_pspace_and_thread restore_pspace_thread;
switch_to_program_space_and_thread (bl->pspace);
- ret = remove_breakpoint_1 (bl, REMOVE_BREAKPOINT);
-
- do_cleanups (old_chain);
- return ret;
+ return remove_breakpoint_1 (bl, REMOVE_BREAKPOINT);
}
/* Clear the "inserted" flag in all breakpoints. */
if (any_deleted)
{
- struct cleanup *cleanup;
char *name;
int ix;
current_uiout->text (_(" Inferior unloaded "));
- cleanup = make_cleanup_ui_out_list_begin_end (current_uiout,
- "removed");
+ ui_out_emit_list list_emitter (current_uiout, "removed");
for (ix = 0;
VEC_iterate (char_ptr, current_program_space->deleted_solibs,
ix, name);
current_uiout->field_string ("library", name);
current_uiout->text ("\n");
}
-
- do_cleanups (cleanup);
}
if (any_added)
{
struct so_list *iter;
int ix;
- struct cleanup *cleanup;
current_uiout->text (_(" Inferior loaded "));
- cleanup = make_cleanup_ui_out_list_begin_end (current_uiout,
- "added");
+ ui_out_emit_list list_emitter (current_uiout, "added");
for (ix = 0;
VEC_iterate (so_list_ptr, current_program_space->added_solibs,
ix, iter);
current_uiout->field_string ("library", iter->so_name);
current_uiout->text ("\n");
}
-
- do_cleanups (cleanup);
}
}
struct bp_location *loc)
{
struct ui_out *uiout = current_uiout;
- struct cleanup *old_chain = save_current_program_space ();
+
+ scoped_restore_current_program_space restore_pspace;
if (loc != NULL && loc->shlib_disabled)
loc = NULL;
set_current_program_space (loc->pspace);
if (b->display_canonical)
- uiout->field_string ("what", event_location_to_string (b->location));
+ uiout->field_string ("what", event_location_to_string (b->location.get ()));
else if (loc && loc->symtab)
{
struct symbol *sym
}
else
{
- uiout->field_string ("pending", event_location_to_string (b->location));
+ uiout->field_string ("pending",
+ event_location_to_string (b->location.get ()));
/* If extra_string is available, it could be holding a condition
or dprintf arguments. In either case, make sure it is printed,
too, but only for non-MI streams. */
bp_location_condition_evaluator (loc));
uiout->text (")");
}
-
- do_cleanups (old_chain);
}
static const char *
struct ep_type_description
{
enum bptype type;
- char *description;
+ const char *description;
};
static struct ep_type_description bptypes[] =
{
VEC(int) *inf_num,
int mi_only)
{
- struct cleanup *back_to;
int is_mi = uiout->is_mi_like_p ();
int inf;
int i;
if (!is_mi && mi_only)
return;
- back_to = make_cleanup_ui_out_list_begin_end (uiout, field_name);
+ ui_out_emit_list list_emitter (uiout, field_name);
for (i = 0; VEC_iterate (int, inf_num, i, inf); ++i)
{
uiout->text (plongest (inf));
}
}
-
- do_cleanups (back_to);
}
/* Print B to gdb_stdout. */
l = b->commands ? b->commands->commands : NULL;
if (!part_of_multiple && l)
{
- struct cleanup *script_chain;
-
annotate_field (9);
- script_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "script");
+ ui_out_emit_tuple tuple_emitter (uiout, "script");
print_command_lines (uiout, l, 4);
- do_cleanups (script_chain);
}
if (is_tracepoint (b))
uiout->field_string ("original-location", w->exp_string);
}
else if (b->location != NULL
- && event_location_to_string (b->location) != NULL)
+ && event_location_to_string (b->location.get ()) != NULL)
uiout->field_string ("original-location",
- event_location_to_string (b->location));
+ event_location_to_string (b->location.get ()));
}
}
struct bp_location **last_loc,
int allflag)
{
- struct cleanup *bkpt_chain;
struct ui_out *uiout = current_uiout;
- bkpt_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "bkpt");
+ {
+ ui_out_emit_tuple tuple_emitter (uiout, "bkpt");
- print_one_breakpoint_location (b, NULL, 0, last_loc, allflag);
- do_cleanups (bkpt_chain);
+ print_one_breakpoint_location (b, NULL, 0, last_loc, allflag);
+ }
/* If this breakpoint has custom print function,
it's already printed. Otherwise, print individual
for (loc = b->loc; loc; loc = loc->next, ++n)
{
- struct cleanup *inner2 =
- make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
+ ui_out_emit_tuple tuple_emitter (uiout, NULL);
print_one_breakpoint_location (b, loc, n, last_loc, allflag);
- do_cleanups (inner2);
}
}
}
}
}
-void
-init_bp_location (struct bp_location *loc, const struct bp_location_ops *ops,
- struct breakpoint *owner)
+bp_location::bp_location (const bp_location_ops *ops, breakpoint *owner)
{
- memset (loc, 0, sizeof (*loc));
+ bp_location *loc = this;
gdb_assert (ops != NULL);
enum bptype bptype,
const struct breakpoint_ops *ops)
{
- memset (b, 0, sizeof (*b));
-
gdb_assert (ops != NULL);
b->ops = ops;
b->gdbarch = gdbarch;
b->language = current_language->la_language;
b->input_radix = input_radix;
- b->thread = -1;
- b->enable_state = bp_enabled;
- b->next = 0;
- b->silent = 0;
- b->ignore_count = 0;
- b->commands = NULL;
- b->frame_id = null_frame_id;
- b->condition_not_parsed = 0;
- b->py_bp_object = NULL;
b->related_breakpoint = b;
- b->location = NULL;
}
/* Helper to set_raw_breakpoint below. Creates a breakpoint
created in an enabled state. */
void
-add_solib_catchpoint (char *arg, int is_load, int is_temp, int enabled)
+add_solib_catchpoint (const char *arg, int is_load, int is_temp, int enabled)
{
struct solib_catchpoint *c;
struct gdbarch *gdbarch = get_current_arch ();
if (!arg)
arg = "";
- arg = skip_spaces (arg);
+ arg = skip_spaces_const (arg);
c = new solib_catchpoint ();
cleanup = make_cleanup (xfree, c);
void
init_catchpoint (struct breakpoint *b,
struct gdbarch *gdbarch, int tempflag,
- char *cond_string,
+ const char *cond_string,
const struct breakpoint_ops *ops)
{
struct symtab_and_line sal;
static void
create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch,
- int tempflag, char *cond_string,
+ int tempflag, const char *cond_string,
const struct breakpoint_ops *ops)
{
struct fork_catchpoint *c = new fork_catchpoint ();
static int
bp_loc_is_permanent (struct bp_location *loc)
{
- struct cleanup *cleanup;
- int retval;
-
gdb_assert (loc != NULL);
/* If we have a catchpoint or a watchpoint, just return 0. We should not
if (!breakpoint_address_is_meaningful (loc->owner))
return 0;
- cleanup = save_current_space_and_thread ();
+ scoped_restore_current_pspace_and_thread restore_pspace_thread;
switch_to_program_space_and_thread (loc->pspace);
-
- retval = program_breakpoint_here_p (loc->gdbarch, loc->address);
-
- do_cleanups (cleanup);
-
- return retval;
+ return program_breakpoint_here_p (loc->gdbarch, loc->address);
}
/* Build a command list for the dprintf corresponding to the current
printf_cmd_line->next = NULL;
printf_cmd_line->line = printf_line;
- breakpoint_set_commands (b, printf_cmd_line);
+ breakpoint_set_commands (b, command_line_up (printf_cmd_line));
}
}
static void
init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
struct symtabs_and_lines sals,
- struct event_location *location,
+ event_location_up &&location,
char *filter, char *cond_string,
char *extra_string,
enum bptype type, enum bpdisp disposition,
{
/* We already know the marker exists, otherwise, we
wouldn't see a sal for it. */
- const char *p = &event_location_to_string (b->location)[3];
+ const char *p
+ = &event_location_to_string (b->location.get ())[3];
const char *endp;
char *marker_str;
b->display_canonical = display_canonical;
if (location != NULL)
- b->location = location;
+ b->location = std::move (location);
else
- {
- const char *addr_string = NULL;
- int addr_string_len = 0;
-
- if (location != NULL)
- addr_string = event_location_to_string (location);
- if (addr_string != NULL)
- addr_string_len = strlen (addr_string);
-
- b->location = new_address_location (b->loc->address,
- addr_string, addr_string_len);
- }
+ b->location = new_address_location (b->loc->address, NULL, 0);
b->filter = filter;
}
static void
create_breakpoint_sal (struct gdbarch *gdbarch,
struct symtabs_and_lines sals,
- struct event_location *location,
+ event_location_up &&location,
char *filter, char *cond_string,
char *extra_string,
enum bptype type, enum bpdisp disposition,
old_chain = make_cleanup (xfree, b);
init_breakpoint_sal (b, gdbarch,
- sals, location,
+ sals, std::move (location),
filter, cond_string, extra_string,
type, disposition,
thread, task, ignore_count,
{
/* Note that 'location' can be NULL in the case of a plain
'break', without arguments. */
- struct event_location *location
+ event_location_up location
= (canonical->location != NULL
- ? copy_event_location (canonical->location) : NULL);
+ ? copy_event_location (canonical->location.get ()) : NULL);
char *filter_string = lsal->canonical ? xstrdup (lsal->canonical) : NULL;
- struct cleanup *inner = make_cleanup_delete_event_location (location);
make_cleanup (xfree, filter_string);
create_breakpoint_sal (gdbarch, lsal->sals,
- location,
+ std::move (location),
filter_string,
cond_string, extra_string,
type, disposition,
thread, task, ignore_count, ops,
from_tty, enabled, internal, flags,
canonical->special_display);
- discard_cleanups (inner);
}
}
unsigned flags)
{
struct linespec_result canonical;
- struct cleanup *old_chain;
struct cleanup *bkpt_chain = NULL;
int pending = 0;
int task = 0;
if (extra_string != NULL && *extra_string == '\0')
extra_string = NULL;
- init_linespec_result (&canonical);
-
TRY
{
ops->create_sals_from_location (location, &canonical, type_wanted);
if (!pending && VEC_empty (linespec_sals, canonical.sals))
return 0;
- /* Create a chain of things that always need to be cleaned up. */
- old_chain = make_cleanup_destroy_linespec_result (&canonical);
-
/* ----------------------------- SNIP -----------------------------
Anything added to the cleanup chain beyond this point is assumed
to be part of a breakpoint. If the breakpoint create succeeds
/* That's it. Discard the cleanups for data inserted into the
breakpoint. */
discard_cleanups (bkpt_chain);
- /* But cleanup everything else. */
- do_cleanups (old_chain);
/* error call may happen here - have BKPT_CHAIN already discarded. */
update_global_location_list (UGLL_MAY_INSERT);
? bp_hardware_breakpoint
: bp_breakpoint);
struct breakpoint_ops *ops;
- struct event_location *location;
- struct cleanup *cleanup;
- location = string_to_event_location (&arg, current_language);
- cleanup = make_cleanup_delete_event_location (location);
+ event_location_up location = string_to_event_location (&arg, current_language);
/* Matching breakpoints on probes. */
if (location != NULL
- && event_location_type (location) == PROBE_LOCATION)
+ && event_location_type (location.get ()) == PROBE_LOCATION)
ops = &bkpt_probe_breakpoint_ops;
else
ops = &bkpt_breakpoint_ops;
create_breakpoint (get_current_arch (),
- location,
+ location.get (),
NULL, 0, arg, 1 /* parse arg */,
tempflag, type_wanted,
0 /* Ignore count */,
1 /* enabled */,
0 /* internal */,
0);
- do_cleanups (cleanup);
}
/* Helper function for break_command_1 and disassemble_command. */
if we have line numbers but no functions (as can
happen in assembly source). */
- struct bound_minimal_symbol msym;
- struct cleanup *old_chain = save_current_space_and_thread ();
-
+ scoped_restore_current_pspace_and_thread restore_pspace_thread;
switch_to_program_space_and_thread (sal->pspace);
- msym = lookup_minimal_symbol_by_pc (sal->pc);
+ bound_minimal_symbol msym = lookup_minimal_symbol_by_pc (sal->pc);
if (msym.minsym)
sal->section = MSYMBOL_OBJ_SECTION (msym.objfile, msym.minsym);
-
- do_cleanups (old_chain);
}
}
}
static void
dprintf_command (char *arg, int from_tty)
{
- struct event_location *location;
- struct cleanup *cleanup;
-
- location = string_to_event_location (&arg, current_language);
- cleanup = make_cleanup_delete_event_location (location);
+ event_location_up location = string_to_event_location (&arg, current_language);
/* If non-NULL, ARG should have been advanced past the location;
the next character must be ','. */
}
create_breakpoint (get_current_arch (),
- location,
+ location.get (),
NULL, 0, arg, 1 /* parse arg */,
0, bp_dprintf,
0 /* Ignore count */,
1 /* enabled */,
0 /* internal */,
0);
- do_cleanups (cleanup);
}
static void
print_recreate_ranged_breakpoint (struct breakpoint *b, struct ui_file *fp)
{
fprintf_unfiltered (fp, "break-range %s, %s",
- event_location_to_string (b->location),
- event_location_to_string (b->location_range_end));
+ event_location_to_string (b->location.get ()),
+ event_location_to_string (b->location_range_end.get ()));
print_recreate_thread (b, fp);
}
struct symtab_and_line sal_start, sal_end;
struct cleanup *cleanup_bkpt;
struct linespec_sals *lsal_start, *lsal_end;
- struct event_location *start_location, *end_location;
/* We don't support software ranged breakpoints. */
if (target_ranged_break_num_registers () < 0)
if (arg == NULL || arg[0] == '\0')
error(_("No address range specified."));
- init_linespec_result (&canonical_start);
-
arg_start = arg;
- start_location = string_to_event_location (&arg, current_language);
- cleanup_bkpt = make_cleanup_delete_event_location (start_location);
- parse_breakpoint_sals (start_location, &canonical_start);
- make_cleanup_destroy_linespec_result (&canonical_start);
+ event_location_up start_location = string_to_event_location (&arg,
+ current_language);
+ parse_breakpoint_sals (start_location.get (), &canonical_start);
if (arg[0] != ',')
error (_("Too few arguments."));
sal_start = lsal_start->sals.sals[0];
addr_string_start = savestring (arg_start, arg - arg_start);
- make_cleanup (xfree, addr_string_start);
+ cleanup_bkpt = make_cleanup (xfree, addr_string_start);
arg++; /* Skip the comma. */
arg = skip_spaces (arg);
/* Parse the end location. */
- init_linespec_result (&canonical_end);
arg_start = arg;
/* We call decode_line_full directly here instead of using
symtab and line as the default symtab and line for the end of the
range. This makes it possible to have ranges like "foo.c:27, +14",
where +14 means 14 lines from the start location. */
- end_location = string_to_event_location (&arg, current_language);
- make_cleanup_delete_event_location (end_location);
- decode_line_full (end_location, DECODE_LINE_FUNFIRSTLINE, NULL,
+ event_location_up end_location = string_to_event_location (&arg,
+ current_language);
+ decode_line_full (end_location.get (), DECODE_LINE_FUNFIRSTLINE, NULL,
sal_start.symtab, sal_start.line,
&canonical_end, NULL, NULL);
- make_cleanup_destroy_linespec_result (&canonical_end);
-
if (VEC_empty (linespec_sals, canonical_end.sals))
error (_("Could not find location of the end of the range."));
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
b->disposition = disp_donttouch;
- b->location = copy_event_location (start_location);
- b->location_range_end = copy_event_location (end_location);
+ b->location = std::move (start_location);
+ b->location_range_end = std::move (end_location);
b->loc->length = length;
do_cleanups (cleanup_bkpt);
static void
print_mention_watchpoint (struct breakpoint *b)
{
- struct cleanup *ui_out_chain;
struct watchpoint *w = (struct watchpoint *) b;
struct ui_out *uiout = current_uiout;
+ const char *tuple_name;
switch (b->type)
{
case bp_watchpoint:
uiout->text ("Watchpoint ");
- ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt");
+ tuple_name = "wpt";
break;
case bp_hardware_watchpoint:
uiout->text ("Hardware watchpoint ");
- ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt");
+ tuple_name = "wpt";
break;
case bp_read_watchpoint:
uiout->text ("Hardware read watchpoint ");
- ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-rwpt");
+ tuple_name = "hw-rwpt";
break;
case bp_access_watchpoint:
uiout->text ("Hardware access (read/write) watchpoint ");
- ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-awpt");
+ tuple_name = "hw-awpt";
break;
default:
internal_error (__FILE__, __LINE__,
_("Invalid hardware watchpoint type."));
}
+ ui_out_emit_tuple tuple_emitter (uiout, tuple_name);
uiout->field_int ("number", b->number);
uiout->text (": ");
uiout->field_string ("exp", w->exp_string);
- do_cleanups (ui_out_chain);
}
/* Implement the "print_recreate" breakpoint_ops method for
{
struct watchpoint *w = (struct watchpoint *) b;
struct ui_out *uiout = current_uiout;
- struct cleanup *ui_out_chain;
+ const char *tuple_name;
switch (b->type)
{
case bp_hardware_watchpoint:
uiout->text ("Masked hardware watchpoint ");
- ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt");
+ tuple_name = "wpt";
break;
case bp_read_watchpoint:
uiout->text ("Masked hardware read watchpoint ");
- ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-rwpt");
+ tuple_name = "hw-rwpt";
break;
case bp_access_watchpoint:
uiout->text ("Masked hardware access (read/write) watchpoint ");
- ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-awpt");
+ tuple_name = "hw-awpt";
break;
default:
internal_error (__FILE__, __LINE__,
_("Invalid hardware watchpoint type."));
}
+ ui_out_emit_tuple tuple_emitter (uiout, tuple_name);
uiout->field_int ("number", b->number);
uiout->text (": ");
uiout->field_string ("exp", w->exp_string);
- do_cleanups (ui_out_chain);
}
/* Implement the "print_recreate" breakpoint_ops method for
const struct block *exp_valid_block = NULL, *cond_exp_valid_block = NULL;
struct value *val, *mark, *result;
int saved_bitpos = 0, saved_bitsize = 0;
- struct frame_info *frame;
const char *exp_start = NULL;
const char *exp_end = NULL;
const char *tok, *end_tok;
if (*tok)
error (_("Junk at end of command."));
- frame = block_innermost_frame (exp_valid_block);
+ frame_info *wp_frame = block_innermost_frame (exp_valid_block);
+
+ /* Save this because create_internal_breakpoint below invalidates
+ 'wp_frame'. */
+ frame_id watchpoint_frame = get_frame_id (wp_frame);
/* If the expression is "local", then set up a "watchpoint scope"
breakpoint at the point where we've left the scope of the watchpoint
expression. Create the scope breakpoint before the watchpoint, so
that we will encounter it first in bpstat_stop_status. */
- if (exp_valid_block && frame)
+ if (exp_valid_block != NULL && wp_frame != NULL)
{
- if (frame_id_p (frame_unwind_caller_id (frame)))
+ frame_id caller_frame_id = frame_unwind_caller_id (wp_frame);
+
+ if (frame_id_p (caller_frame_id))
{
+ gdbarch *caller_arch = frame_unwind_caller_arch (wp_frame);
+ CORE_ADDR caller_pc = frame_unwind_caller_pc (wp_frame);
+
scope_breakpoint
- = create_internal_breakpoint (frame_unwind_caller_arch (frame),
- frame_unwind_caller_pc (frame),
+ = create_internal_breakpoint (caller_arch, caller_pc,
bp_watchpoint_scope,
&momentary_breakpoint_ops);
+ /* create_internal_breakpoint could invalidate WP_FRAME. */
+ wp_frame = NULL;
+
scope_breakpoint->enable_state = bp_enabled;
/* Automatically delete the breakpoint when it hits. */
scope_breakpoint->disposition = disp_del;
/* Only break in the proper frame (help with recursion). */
- scope_breakpoint->frame_id = frame_unwind_caller_id (frame);
+ scope_breakpoint->frame_id = caller_frame_id;
/* Set the address at which we will stop. */
- scope_breakpoint->loc->gdbarch
- = frame_unwind_caller_arch (frame);
- scope_breakpoint->loc->requested_address
- = frame_unwind_caller_pc (frame);
+ scope_breakpoint->loc->gdbarch = caller_arch;
+ scope_breakpoint->loc->requested_address = caller_pc;
scope_breakpoint->loc->address
= adjust_breakpoint_address (scope_breakpoint->loc->gdbarch,
scope_breakpoint->loc->requested_address,
else
b->cond_string = 0;
- if (frame)
+ if (frame_id_p (watchpoint_frame))
{
- w->watchpoint_frame = get_frame_id (frame);
+ w->watchpoint_frame = watchpoint_frame;
w->watchpoint_thread = inferior_ptid;
}
else
struct frame_id caller_frame_id;
struct breakpoint *location_breakpoint;
struct breakpoint *caller_breakpoint = NULL;
- struct cleanup *old_chain, *cleanup;
+ struct cleanup *old_chain;
int thread;
struct thread_info *tp;
- struct event_location *location;
struct until_break_fsm *sm;
clear_proceed_status (0);
/* Set a breakpoint where the user wants it and at return from
this function. */
- location = string_to_event_location (&arg, current_language);
- cleanup = make_cleanup_delete_event_location (location);
+ event_location_up location = string_to_event_location (&arg, current_language);
if (last_displayed_sal_is_valid ())
- sals = decode_line_1 (location, DECODE_LINE_FUNFIRSTLINE, NULL,
+ sals = decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE, NULL,
get_last_displayed_symtab (),
get_last_displayed_line ());
else
- sals = decode_line_1 (location, DECODE_LINE_FUNFIRSTLINE,
+ sals = decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE,
NULL, (struct symtab *) NULL, 0);
if (sals.nelts != 1)
discard_cleanups (old_chain);
proceed (-1, GDB_SIGNAL_DEFAULT);
-
- do_cleanups (cleanup);
}
/* This function attempts to parse an optional "if <cond>" clause
it updates arg to point to the first character following the parsed
if clause in the arg string. */
-char *
-ep_parse_optional_if_clause (char **arg)
+const char *
+ep_parse_optional_if_clause (const char **arg)
{
- char *cond_string;
+ const char *cond_string;
if (((*arg)[0] != 'i') || ((*arg)[1] != 'f') || !isspace ((*arg)[2]))
return NULL;
/* Skip any extra leading whitespace, and record the start of the
condition string. */
- *arg = skip_spaces (*arg);
+ *arg = skip_spaces_const (*arg);
cond_string = *arg;
/* Assume that the condition occupies the remainder of the arg
catch_fork_kind;
static void
-catch_fork_command_1 (char *arg, int from_tty,
+catch_fork_command_1 (char *arg_entry, int from_tty,
struct cmd_list_element *command)
{
+ const char *arg = arg_entry;
struct gdbarch *gdbarch = get_current_arch ();
- char *cond_string = NULL;
+ const char *cond_string = NULL;
catch_fork_kind fork_kind;
int tempflag;
if (!arg)
arg = "";
- arg = skip_spaces (arg);
+ arg = skip_spaces_const (arg);
/* The allowed syntax is:
catch [v]fork
}
static void
-catch_exec_command_1 (char *arg, int from_tty,
+catch_exec_command_1 (char *arg_entry, int from_tty,
struct cmd_list_element *command)
{
+ const char *arg = arg_entry;
struct exec_catchpoint *c;
struct gdbarch *gdbarch = get_current_arch ();
int tempflag;
- char *cond_string = NULL;
+ const char *cond_string = NULL;
tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
if (!arg)
arg = "";
- arg = skip_spaces (arg);
+ arg = skip_spaces_const (arg);
/* The allowed syntax is:
catch exec
qsort being an unstable algorithm. */
static int
-bp_location_compare (const void *ap, const void *bp)
+bp_locations_compare (const void *ap, const void *bp)
{
const struct bp_location *a = *(const struct bp_location **) ap;
const struct bp_location *b = *(const struct bp_location **) bp;
return (a > b) - (a < b);
}
-/* Set bp_location_placed_address_before_address_max and
- bp_location_shadow_len_after_address_max according to the current
- content of the bp_location array. */
+/* Set bp_locations_placed_address_before_address_max and
+ bp_locations_shadow_len_after_address_max according to the current
+ content of the bp_locations array. */
static void
-bp_location_target_extensions_update (void)
+bp_locations_target_extensions_update (void)
{
struct bp_location *bl, **blp_tmp;
- bp_location_placed_address_before_address_max = 0;
- bp_location_shadow_len_after_address_max = 0;
+ bp_locations_placed_address_before_address_max = 0;
+ bp_locations_shadow_len_after_address_max = 0;
ALL_BP_LOCATIONS (bl, blp_tmp)
{
gdb_assert (bl->address >= start);
addr = bl->address - start;
- if (addr > bp_location_placed_address_before_address_max)
- bp_location_placed_address_before_address_max = addr;
+ if (addr > bp_locations_placed_address_before_address_max)
+ bp_locations_placed_address_before_address_max = addr;
/* Zero SHADOW_LEN would not pass bp_location_has_shadow. */
gdb_assert (bl->address < end);
addr = end - bl->address;
- if (addr > bp_location_shadow_len_after_address_max)
- bp_location_shadow_len_after_address_max = addr;
+ if (addr > bp_locations_shadow_len_after_address_max)
+ bp_locations_shadow_len_after_address_max = addr;
}
}
download_tracepoint_locations (void)
{
struct breakpoint *b;
- struct cleanup *old_chain;
enum tribool can_download_tracepoint = TRIBOOL_UNKNOWN;
- old_chain = save_current_space_and_thread ();
+ scoped_restore_current_pspace_and_thread restore_pspace_thread;
ALL_TRACEPOINTS (b)
{
if (bp_location_downloaded)
observer_notify_breakpoint_modified (b);
}
-
- do_cleanups (old_chain);
}
/* Swap the insertion/duplication state between two locations. */
struct bp_location *awp_loc_first; /* access watchpoint */
struct bp_location *rwp_loc_first; /* read watchpoint */
- /* Saved former bp_location array which we compare against the newly
- built bp_location from the current state of ALL_BREAKPOINTS. */
- struct bp_location **old_location, **old_locp;
- unsigned old_location_count;
+ /* Saved former bp_locations array which we compare against the newly
+ built bp_locations from the current state of ALL_BREAKPOINTS. */
+ struct bp_location **old_locations, **old_locp;
+ unsigned old_locations_count;
- old_location = bp_location;
- old_location_count = bp_location_count;
- bp_location = NULL;
- bp_location_count = 0;
- cleanups = make_cleanup (xfree, old_location);
+ old_locations = bp_locations;
+ old_locations_count = bp_locations_count;
+ bp_locations = NULL;
+ bp_locations_count = 0;
+ cleanups = make_cleanup (xfree, old_locations);
ALL_BREAKPOINTS (b)
for (loc = b->loc; loc; loc = loc->next)
- bp_location_count++;
+ bp_locations_count++;
- bp_location = XNEWVEC (struct bp_location *, bp_location_count);
- locp = bp_location;
+ bp_locations = XNEWVEC (struct bp_location *, bp_locations_count);
+ locp = bp_locations;
ALL_BREAKPOINTS (b)
for (loc = b->loc; loc; loc = loc->next)
*locp++ = loc;
- qsort (bp_location, bp_location_count, sizeof (*bp_location),
- bp_location_compare);
+ qsort (bp_locations, bp_locations_count, sizeof (*bp_locations),
+ bp_locations_compare);
- bp_location_target_extensions_update ();
+ bp_locations_target_extensions_update ();
/* Identify bp_location instances that are no longer present in the
new list, and therefore should be freed. Note that it's not
LOCP is kept in sync with OLD_LOCP, each pointing to the current
and former bp_location array state respectively. */
- locp = bp_location;
- for (old_locp = old_location; old_locp < old_location + old_location_count;
+ locp = bp_locations;
+ for (old_locp = old_locations;
+ old_locp < old_locations + old_locations_count;
old_locp++)
{
struct bp_location *old_loc = *old_locp;
/* Skip LOCP entries which will definitely never be needed.
Stop either at or being the one matching OLD_LOC. */
- while (locp < bp_location + bp_location_count
+ while (locp < bp_locations + bp_locations_count
&& (*locp)->address < old_loc->address)
locp++;
for (loc2p = locp;
- (loc2p < bp_location + bp_location_count
+ (loc2p < bp_locations + bp_locations_count
&& (*loc2p)->address == old_loc->address);
loc2p++)
{
if (breakpoint_address_is_meaningful (old_loc->owner))
{
for (loc2p = locp;
- (loc2p < bp_location + bp_location_count
+ (loc2p < bp_locations + bp_locations_count
&& (*loc2p)->address == old_loc->address);
loc2p++)
{
if (b->extra_string == NULL)
{
printf_filtered (_(" (%s) pending."),
- event_location_to_string (b->location));
+ event_location_to_string (b->location.get ()));
}
else if (b->type == bp_dprintf)
{
printf_filtered (_(" (%s,%s) pending."),
- event_location_to_string (b->location),
+ event_location_to_string (b->location.get ()),
b->extra_string);
}
else
{
printf_filtered (_(" (%s %s) pending."),
- event_location_to_string (b->location),
+ event_location_to_string (b->location.get ()),
b->extra_string);
}
}
different file name, and this at least reflects the
real situation somewhat. */
printf_filtered (": %s.",
- event_location_to_string (b->location));
+ event_location_to_string (b->location.get ()));
}
if (b->loc->next)
xfree (self->cond_string);
xfree (self->extra_string);
xfree (self->filter);
- delete_event_location (self->location);
- delete_event_location (self->location_range_end);
}
static struct bp_location *
base_breakpoint_allocate_location (struct breakpoint *self)
{
- struct bp_location *loc;
-
- loc = new struct bp_location ();
- init_bp_location (loc, &bp_location_ops, self);
- return loc;
+ return new bp_location (&bp_location_ops, self);
}
static void
_("unhandled breakpoint type %d"), (int) tp->type);
fprintf_unfiltered (fp, " %s",
- event_location_to_string (tp->location));
+ event_location_to_string (tp->location.get ()));
/* Print out extra_string if this breakpoint is pending. It might
contain, for example, conditions that were set by the user. */
struct linespec_sals lsal;
lsal.sals = parse_probes (location, NULL, canonical);
- lsal.canonical = xstrdup (event_location_to_string (canonical->location));
+ lsal.canonical
+ = xstrdup (event_location_to_string (canonical->location.get ()));
VEC_safe_push (linespec_sals, canonical->sals, &lsal);
}
_("unhandled tracepoint type %d"), (int) self->type);
fprintf_unfiltered (fp, " %s",
- event_location_to_string (self->location));
+ event_location_to_string (self->location.get ()));
print_recreate_thread (self, fp);
if (tp->pass_count)
dprintf_print_recreate (struct breakpoint *tp, struct ui_file *fp)
{
fprintf_unfiltered (fp, "dprintf %s,%s",
- event_location_to_string (tp->location),
+ event_location_to_string (tp->location.get ()),
tp->extra_string);
print_recreate_thread (tp, fp);
}
canonical->location = new_linespec_location (&str);
do_cleanups (cleanup);
- lsal.canonical = xstrdup (event_location_to_string (canonical->location));
+ lsal.canonical
+ = xstrdup (event_location_to_string (canonical->location.get ()));
VEC_safe_push (linespec_sals, canonical->sals, &lsal);
}
{
struct symtabs_and_lines expanded;
struct tracepoint *tp;
- struct cleanup *old_chain;
- struct event_location *location;
+ event_location_up location;
expanded.nelts = 1;
expanded.sals = &lsal->sals.sals[i];
- location = copy_event_location (canonical->location);
- old_chain = make_cleanup_delete_event_location (location);
+ location = copy_event_location (canonical->location.get ());
tp = new tracepoint ();
init_breakpoint_sal (&tp->base, gdbarch, expanded,
- location, NULL,
+ std::move (location), NULL,
cond_string, extra_string,
type_wanted, disposition,
thread, task, ignore_count, ops,
tp->static_trace_marker_id_idx = i;
install_breakpoint (internal, &tp->base, 0);
-
- discard_cleanups (old_chain);
}
}
b->loc->line_number = sal2.line;
b->loc->symtab = sym != NULL ? sal2.symtab : NULL;
- delete_event_location (b->location);
+ b->location.reset (NULL);
initialize_explicit_location (&explicit_loc);
explicit_loc.source_filename
= ASTRDUP (symtab_to_filename_for_display (sal2.symtab));
struct symtabs_and_lines expanded_end = {0};
struct program_space *filter_pspace = current_program_space;
- sals = location_to_sals (b, b->location, filter_pspace, &found);
+ sals = location_to_sals (b, b->location.get (), filter_pspace, &found);
if (found)
{
make_cleanup (xfree, sals.sals);
if (b->location_range_end != NULL)
{
- sals_end = location_to_sals (b, b->location_range_end,
+ sals_end = location_to_sals (b, b->location_range_end.get (),
filter_pspace, &found);
if (found)
{
{
struct linespec_result canonical;
- init_linespec_result (&canonical);
decode_line_full (location, DECODE_LINE_FUNFIRSTLINE, search_pspace,
(struct symtab *) NULL, 0,
&canonical, multiple_symbols_all,
contents. */
lsal->sals.sals = NULL;
}
-
- destroy_linespec_result (&canonical);
}
/* Prepare the global context for a re-set of breakpoint B. */
struct breakpoint *b, *b_tmp;
enum language save_language;
int save_input_radix;
- struct cleanup *old_chain;
save_language = current_language->la_language;
save_input_radix = input_radix;
- old_chain = save_current_space_and_thread ();
-
- /* Note: we must not try to insert locations until after all
- breakpoints have been re-set. Otherwise, e.g., when re-setting
- breakpoint 1, we'd insert the locations of breakpoint 2, which
- hadn't been re-set yet, and thus may have stale locations. */
- ALL_BREAKPOINTS_SAFE (b, b_tmp)
{
- /* Format possible error msg. */
- char *message = xstrprintf ("Error in re-setting breakpoint %d: ",
- b->number);
- struct cleanup *cleanups = make_cleanup (xfree, message);
- catch_errors (breakpoint_re_set_one, b, message, RETURN_MASK_ALL);
- do_cleanups (cleanups);
- }
- set_language (save_language);
- input_radix = save_input_radix;
+ scoped_restore_current_pspace_and_thread restore_pspace_thread;
- jit_breakpoint_re_set ();
+ /* Note: we must not try to insert locations until after all
+ breakpoints have been re-set. Otherwise, e.g., when re-setting
+ breakpoint 1, we'd insert the locations of breakpoint 2, which
+ hadn't been re-set yet, and thus may have stale locations. */
- do_cleanups (old_chain);
+ ALL_BREAKPOINTS_SAFE (b, b_tmp)
+ {
+ /* Format possible error msg. */
+ char *message = xstrprintf ("Error in re-setting breakpoint %d: ",
+ b->number);
+ struct cleanup *cleanups = make_cleanup (xfree, message);
+ catch_errors (breakpoint_re_set_one, b, message, RETURN_MASK_ALL);
+ do_cleanups (cleanups);
+ }
+ set_language (save_language);
+ input_radix = save_input_radix;
+
+ jit_breakpoint_re_set ();
+ }
create_overlay_event_breakpoint ();
create_longjmp_master_breakpoint ();
insert_single_step_breakpoints (struct gdbarch *gdbarch)
{
struct regcache *regcache = get_current_regcache ();
- VEC (CORE_ADDR) * next_pcs;
+ std::vector<CORE_ADDR> next_pcs;
next_pcs = gdbarch_software_single_step (gdbarch, regcache);
- if (next_pcs != NULL)
+ if (!next_pcs.empty ())
{
- int i;
- CORE_ADDR pc;
struct frame_info *frame = get_current_frame ();
struct address_space *aspace = get_frame_address_space (frame);
- for (i = 0; VEC_iterate (CORE_ADDR, next_pcs, i, pc); i++)
+ for (CORE_ADDR pc : next_pcs)
insert_single_step_breakpoint (gdbarch, aspace, pc);
- VEC_free (CORE_ADDR, next_pcs);
-
return 1;
}
else
trace_command (char *arg, int from_tty)
{
struct breakpoint_ops *ops;
- struct event_location *location;
- struct cleanup *back_to;
- location = string_to_event_location (&arg, current_language);
- back_to = make_cleanup_delete_event_location (location);
+ event_location_up location = string_to_event_location (&arg,
+ current_language);
if (location != NULL
- && event_location_type (location) == PROBE_LOCATION)
+ && event_location_type (location.get ()) == PROBE_LOCATION)
ops = &tracepoint_probe_breakpoint_ops;
else
ops = &tracepoint_breakpoint_ops;
create_breakpoint (get_current_arch (),
- location,
+ location.get (),
NULL, 0, arg, 1 /* parse arg */,
0 /* tempflag */,
bp_tracepoint /* type_wanted */,
from_tty,
1 /* enabled */,
0 /* internal */, 0);
- do_cleanups (back_to);
}
static void
ftrace_command (char *arg, int from_tty)
{
- struct event_location *location;
- struct cleanup *back_to;
-
- location = string_to_event_location (&arg, current_language);
- back_to = make_cleanup_delete_event_location (location);
+ event_location_up location = string_to_event_location (&arg,
+ current_language);
create_breakpoint (get_current_arch (),
- location,
+ location.get (),
NULL, 0, arg, 1 /* parse arg */,
0 /* tempflag */,
bp_fast_tracepoint /* type_wanted */,
from_tty,
1 /* enabled */,
0 /* internal */, 0);
- do_cleanups (back_to);
}
/* strace command implementation. Creates a static tracepoint. */
strace_command (char *arg, int from_tty)
{
struct breakpoint_ops *ops;
- struct event_location *location;
+ event_location_up location;
struct cleanup *back_to;
/* Decide if we are dealing with a static tracepoint marker (`-m'),
location = string_to_event_location (&arg, current_language);
}
- back_to = make_cleanup_delete_event_location (location);
create_breakpoint (get_current_arch (),
- location,
+ location.get (),
NULL, 0, arg, 1 /* parse arg */,
0 /* tempflag */,
bp_static_tracepoint /* type_wanted */,
from_tty,
1 /* enabled */,
0 /* internal */, 0);
- do_cleanups (back_to);
}
/* Set up a fake reader function that gets command lines from a linked
{
char *addr_str, small_buf[100];
struct tracepoint *tp;
- struct event_location *location;
- struct cleanup *cleanup;
if (utp->at_string)
addr_str = utp->at_string;
"has no source form, ignoring it"),
utp->number);
- location = string_to_event_location (&addr_str, current_language);
- cleanup = make_cleanup_delete_event_location (location);
+ event_location_up location = string_to_event_location (&addr_str,
+ current_language);
if (!create_breakpoint (get_current_arch (),
- location,
+ location.get (),
utp->cond_string, -1, addr_str,
0 /* parse cond/thread */,
0 /* tempflag */,
utp->enabled /* enabled */,
0 /* internal */,
CREATE_BREAKPOINT_FLAGS_INSERTED))
- {
- do_cleanups (cleanup);
- return NULL;
- }
-
- do_cleanups (cleanup);
+ return NULL;
/* Get the tracepoint we just created. */
tp = get_tracepoint (tracepoint_count);
function. */
if (!VEC_empty (char_ptr, utp->cmd_strings))
{
- struct command_line *cmd_list;
+ command_line_up cmd_list;
this_utp = utp;
next_cmd = 0;
cmd_list = read_command_lines_1 (read_uploaded_action, 1, NULL, NULL);
- breakpoint_set_commands (&tp->base, cmd_list);
+ breakpoint_set_commands (&tp->base, std::move (cmd_list));
}
else if (!VEC_empty (char_ptr, utp->actions)
|| !VEC_empty (char_ptr, utp->step_actions))
static struct cmd_list_element *tcatch_cmdlist;
void
-add_catch_command (char *name, char *docstring,
+add_catch_command (const char *name, const char *docstring,
cmd_sfunc_ftype *sfunc,
completer_ftype *completer,
void *user_data_catch,