+2017-04-12 Tom Tromey <tom@tromey.com>
+
+ * tracepoint.c (scope_info): Update.
+ * spu-tdep.c (spu_catch_start): Update.
+ * python/python.c (gdbpy_decode_line): Update.
+ * python/py-finishbreakpoint.c (bpfinishpy_init): Update.
+ * python/py-breakpoint.c (bppy_init): Update.
+ * probe.c (parse_probes): Update.
+ * mi/mi-cmd-break.c (mi_cmd_break_insert_1): Update.
+ * location.h (event_location_deleter): New struct.
+ (event_location_up): New typedef.
+ (new_linespec_location, new_address_location, new_probe_location)
+ (new_explicit_location, copy_event_location)
+ (string_to_event_location, string_to_event_location_basic)
+ (string_to_explicit_location): Update return type.
+ (make_cleanup_delete_event_location): Remove.
+ * location.c (new_linespec_location, new_address_location)
+ (new_probe_location, new_explicit_location, copy_event_location):
+ Return event_location_up.
+ (delete_event_location_cleanup)
+ (make_cleanup_delete_event_location): Remove.
+ (string_to_explicit_location, string_to_event_location_basic)
+ (string_to_event_location): Return event_location_up.
+ * linespec.c (canonicalize_linespec, event_location_to_sals)
+ (decode_line_with_current_source)
+ (decode_line_with_last_displayed, decode_objc): Update.
+ * guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Update.
+ * completer.c (location_completer): Update.
+ * cli/cli-cmds.c (edit_command, list_command): Update.
+ * breakpoint.c (create_overlay_event_breakpoint)
+ (create_longjmp_master_breakpoint)
+ (create_std_terminate_master_breakpoint)
+ (create_exception_master_breakpoint)
+ (create_thread_event_breakpoint): Update.
+ (init_breakpoint_sal): Update. Remove some dead code.
+ (create_breakpoint_sal): Change type of "location". Update.
+ (create_breakpoints_sal, create_breakpoint, break_command_1)
+ (dprintf_command, break_range_command, until_break_command)
+ (init_ada_exception_breakpoint)
+ (strace_marker_create_sals_from_location)
+ (update_static_tracepoint, trace_command, ftrace_command)
+ (strace_command, create_tracepoint_from_upload): Update.
+ * break-catch-throw.c (re_set_exception_catchpoint): Update.
+ * ax-gdb.c (agent_command_1): Update.
+
2017-04-12 Pedro Alves <palves@redhat.com>
* Makefile.in (ALL_TARGET_OBS): Add i386-go32-tdep.o.
int ix;
struct linespec_sals *iter;
struct cleanup *old_chain;
- struct event_location *location;
exp = skip_spaces (exp);
init_linespec_result (&canonical);
- location = new_linespec_location (&exp);
- old_chain = make_cleanup_delete_event_location (location);
- decode_line_full (location, DECODE_LINE_FUNFIRSTLINE, NULL,
+ event_location_up location = new_linespec_location (&exp);
+ decode_line_full (location.get (), DECODE_LINE_FUNFIRSTLINE, NULL,
(struct symtab *) NULL, 0, &canonical,
NULL, NULL);
- make_cleanup_destroy_linespec_result (&canonical);
+ old_chain = make_cleanup_destroy_linespec_result (&canonical);
exp = skip_spaces (exp);
if (exp[0] == ',')
{
struct symtabs_and_lines sals_end = {0};
struct cleanup *cleanup;
enum exception_event_kind kind = classify_exception_breakpoint (self);
- struct event_location *location;
struct program_space *filter_pspace = current_program_space;
/* We first try to use the probe interface. */
TRY
{
- location
+ event_location_up location
= new_probe_location (exception_functions[kind].probe);
- cleanup = make_cleanup_delete_event_location (location);
- sals = parse_probes (location, filter_pspace, NULL);
- do_cleanups (cleanup);
+ sals = parse_probes (location.get (), filter_pspace, NULL);
}
CATCH (e, RETURN_MASK_ERROR)
{
initialize_explicit_location (&explicit_loc);
explicit_loc.function_name
= ASTRDUP (exception_functions[kind].function);
- location = new_explicit_location (&explicit_loc);
- cleanup = make_cleanup_delete_event_location (location);
- self->ops->decode_location (self, location, filter_pspace, &sals);
- do_cleanups (cleanup);
+ event_location_up location = new_explicit_location (&explicit_loc);
+ self->ops->decode_location (self, location.get (), filter_pspace,
+ &sals);
}
CATCH (ex, RETURN_MASK_ERROR)
{
&internal_breakpoint_ops);
initialize_explicit_location (&explicit_loc);
explicit_loc.function_name = ASTRDUP (func_name);
- b->location = new_explicit_location (&explicit_loc);
+ b->location = new_explicit_location (&explicit_loc).release ();
if (overlay_debugging == ovly_auto)
{
bp_longjmp_master,
&internal_breakpoint_ops);
b->location
- = new_probe_location ("-probe-stap libc:longjmp");
+ = new_probe_location ("-probe-stap libc:longjmp").release ();
b->enable_state = bp_disabled;
}
&internal_breakpoint_ops);
initialize_explicit_location (&explicit_loc);
explicit_loc.function_name = ASTRDUP (func_name);
- b->location = new_explicit_location (&explicit_loc);
+ b->location = new_explicit_location (&explicit_loc).release ();
b->enable_state = bp_disabled;
}
}
&internal_breakpoint_ops);
initialize_explicit_location (&explicit_loc);
explicit_loc.function_name = ASTRDUP (func_name);
- b->location = new_explicit_location (&explicit_loc);
+ b->location = new_explicit_location (&explicit_loc).release ();
b->enable_state = bp_disabled;
}
}
bp_exception_master,
&internal_breakpoint_ops);
b->location
- = new_probe_location ("-probe-stap libgcc:unwind");
+ = new_probe_location ("-probe-stap libgcc:unwind").release ();
b->enable_state = bp_disabled;
}
&internal_breakpoint_ops);
initialize_explicit_location (&explicit_loc);
explicit_loc.function_name = ASTRDUP (func_name);
- b->location = new_explicit_location (&explicit_loc);
+ b->location = new_explicit_location (&explicit_loc).release ();
b->enable_state = bp_disabled;
}
}
b->enable_state = bp_enabled;
/* location has to be used or breakpoint_re_set will delete me. */
- b->location = new_address_location (b->loc->address, NULL, 0);
+ b->location = new_address_location (b->loc->address, NULL, 0).release ();
update_global_location_list_nothrow (UGLL_MAY_INSERT);
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,
b->display_canonical = display_canonical;
if (location != NULL)
- b->location = location;
+ b->location = location.release ();
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).release ();
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);
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);
}
}
b = new breakpoint ();
init_raw_breakpoint_without_location (b, gdbarch, type_wanted, ops);
- b->location = copy_event_location (location);
+ b->location = copy_event_location (location).release ();
if (parse_extra)
b->cond_string = NULL;
? 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. */
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
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)
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);
+ cleanup_bkpt = make_cleanup_destroy_linespec_result (&canonical_start);
if (arg[0] != ',')
error (_("Too few arguments."));
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);
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 = start_location.release ();
+ b->location_range_end = end_location.release ();
b->loc->length = length;
do_cleanups (cleanup_bkpt);
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
b->enable_state = enabled ? bp_enabled : bp_disabled;
b->disposition = tempflag ? disp_del : disp_donttouch;
- b->location = string_to_event_location (&addr_string,
- language_def (language_ada));
+ b->location
+ = string_to_event_location (&addr_string,
+ language_def (language_ada)).release ();
b->language = language_ada;
}
str = savestring (arg_start, arg - arg_start);
cleanup = make_cleanup (xfree, str);
- canonical->location = new_linespec_location (&str);
+ canonical->location = new_linespec_location (&str).release ();
do_cleanups (cleanup);
lsal.canonical = xstrdup (event_location_to_string (canonical->location));
{
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);
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);
}
}
= ASTRDUP (symtab_to_filename_for_display (sal2.symtab));
explicit_loc.line_offset.offset = b->loc->line_number;
explicit_loc.line_offset.sign = LINE_OFFSET_NONE;
- b->location = new_explicit_location (&explicit_loc);
+ b->location = new_explicit_location (&explicit_loc).release ();
/* Might be nice to check if function changed, and warn if
so. */
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);
}
else
{
- struct cleanup *cleanup;
- struct event_location *location;
char *arg1;
/* Now should only be one argument -- decode it in SAL. */
arg1 = arg;
- location = string_to_event_location (&arg1, current_language);
- cleanup = make_cleanup_delete_event_location (location);
- sals = decode_line_1 (location, DECODE_LINE_LIST_MODE, NULL, NULL, 0);
+ event_location_up location = string_to_event_location (&arg1,
+ current_language);
+ sals = decode_line_1 (location.get (), DECODE_LINE_LIST_MODE,
+ NULL, NULL, 0);
filter_sals (&sals);
if (! sals.nelts)
{
/* C++ */
- do_cleanups (cleanup);
return;
}
if (sals.nelts > 1)
{
ambiguous_line_spec (&sals);
xfree (sals.sals);
- do_cleanups (cleanup);
return;
}
if (sal.symtab == 0)
error (_("No line number known for %s."), arg);
- do_cleanups (cleanup);
}
if ((editor = (char *) getenv ("EDITOR")) == NULL)
int dummy_beg = 0;
int linenum_beg = 0;
char *p;
- struct cleanup *cleanup;
-
- cleanup = make_cleanup (null_cleanup, NULL);
/* Pull in the current default source line if necessary. */
if (arg == NULL || ((arg[0] == '+' || arg[0] == '-') && arg[1] == '\0'))
dummy_beg = 1;
else
{
- struct event_location *location;
-
- location = string_to_event_location (&arg1, current_language);
- make_cleanup_delete_event_location (location);
- sals = decode_line_1 (location, DECODE_LINE_LIST_MODE, NULL, NULL, 0);
+ event_location_up location = string_to_event_location (&arg1,
+ current_language);
+ sals = decode_line_1 (location.get (), DECODE_LINE_LIST_MODE,
+ NULL, NULL, 0);
filter_sals (&sals);
if (!sals.nelts)
{
/* C++ */
- do_cleanups (cleanup);
return;
}
if (sals.nelts > 1)
{
ambiguous_line_spec (&sals);
xfree (sals.sals);
- do_cleanups (cleanup);
return;
}
dummy_end = 1;
else
{
- struct event_location *location;
-
- location = string_to_event_location (&arg1, current_language);
- make_cleanup_delete_event_location (location);
+ event_location_up location
+ = string_to_event_location (&arg1, current_language);
if (dummy_beg)
- sals_end = decode_line_1 (location,
+ sals_end = decode_line_1 (location.get (),
DECODE_LINE_LIST_MODE, NULL, NULL, 0);
else
- sals_end = decode_line_1 (location, DECODE_LINE_LIST_MODE,
+ sals_end = decode_line_1 (location.get (), DECODE_LINE_LIST_MODE,
NULL, sal.symtab, sal.line);
filter_sals (&sals_end);
if (sals_end.nelts == 0)
- {
- do_cleanups (cleanup);
- return;
- }
+ return;
if (sals_end.nelts > 1)
{
ambiguous_line_spec (&sals_end);
xfree (sals_end.sals);
- do_cleanups (cleanup);
return;
}
sal_end = sals_end.sals[0];
? sal.line + get_lines_to_list ()
: sal_end.line + 1),
0);
- do_cleanups (cleanup);
}
/* Subroutine of disassemble_command to simplify it.
{
VEC (char_ptr) *matches = NULL;
const char *copy = text;
- struct event_location *location;
- location = string_to_explicit_location (©, current_language, 1);
+ event_location_up location = string_to_explicit_location (©,
+ current_language,
+ 1);
if (location != NULL)
- {
- struct cleanup *cleanup;
-
- cleanup = make_cleanup_delete_event_location (location);
- matches = explicit_location_completer (ignore, location, text, word);
- do_cleanups (cleanup);
- }
+ matches = explicit_location_completer (ignore, location.get (),
+ text, word);
else
{
/* This is an address or linespec location.
= bpscm_get_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
struct gdb_exception except = exception_none;
char *location, *copy;
- struct event_location *eloc;
- struct cleanup *cleanup;
/* We only support registering breakpoints created with make-breakpoint. */
if (!bp_smob->is_scheme_bkpt)
pending_breakpoint_scm = self;
location = bp_smob->spec.location;
copy = skip_spaces (location);
- eloc = string_to_event_location_basic (©, current_language);
- cleanup = make_cleanup_delete_event_location (eloc);
+ event_location_up eloc = string_to_event_location_basic (©,
+ current_language);
TRY
{
case bp_breakpoint:
{
create_breakpoint (get_current_arch (),
- eloc, NULL, -1, NULL,
+ eloc.get (), NULL, -1, NULL,
0,
0, bp_breakpoint,
0,
/* Ensure this gets reset, even if there's an error. */
pending_breakpoint_scm = SCM_BOOL_F;
GDBSCM_HANDLE_GDB_EXCEPTION (except);
- do_cleanups (cleanup);
return SCM_UNSPECIFIED;
}
/* Save everything as an explicit location. */
canon = state->canonical->location
- = new_explicit_location (&ls->explicit_loc);
+ = new_explicit_location (&ls->explicit_loc).release ();
explicit_loc = get_explicit_location (canon);
if (explicit_loc->label_name != NULL)
addr = linespec_expression_to_pc (&const_expr);
if (PARSER_STATE (parser)->canonical != NULL)
PARSER_STATE (parser)->canonical->location
- = copy_event_location (location);
+ = copy_event_location (location).release ();
do_cleanups (cleanup);
}
{
struct symtabs_and_lines sals;
struct symtab_and_line cursal;
- struct event_location *location;
- struct cleanup *cleanup;
if (string == 0)
error (_("Empty line specification."));
and get a default source symtab+line or it will recursively call us! */
cursal = get_current_source_symtab_and_line ();
- location = string_to_event_location (&string, current_language);
- cleanup = make_cleanup_delete_event_location (location);
- sals = decode_line_1 (location, flags, NULL,
+ event_location_up location = string_to_event_location (&string,
+ current_language);
+ sals = decode_line_1 (location.get (), flags, NULL,
cursal.symtab, cursal.line);
if (*string)
error (_("Junk at end of line specification: %s"), string);
- do_cleanups (cleanup);
return sals;
}
decode_line_with_last_displayed (char *string, int flags)
{
struct symtabs_and_lines sals;
- struct event_location *location;
- struct cleanup *cleanup;
if (string == 0)
error (_("Empty line specification."));
- location = string_to_event_location (&string, current_language);
- cleanup = make_cleanup_delete_event_location (location);
+ event_location_up location = string_to_event_location (&string,
+ current_language);
if (last_displayed_sal_is_valid ())
- sals = decode_line_1 (location, flags, NULL,
+ sals = decode_line_1 (location.get (), flags, NULL,
get_last_displayed_symtab (),
get_last_displayed_line ());
else
- sals = decode_line_1 (location, flags, NULL, (struct symtab *) NULL, 0);
+ sals = decode_line_1 (location.get (), flags, NULL,
+ (struct symtab *) NULL, 0);
if (*string)
error (_("Junk at end of line specification: %s"), string);
- do_cleanups (cleanup);
return sals;
}
str = xstrdup (saved_arg);
make_cleanup (xfree, str);
- self->canonical->location = new_linespec_location (&str);
+ self->canonical->location = new_linespec_location (&str).release ();
}
}
/* See description in location.h. */
-struct event_location *
+event_location_up
new_linespec_location (char **linespec)
{
struct event_location *location;
if ((p - orig) > 0)
EL_LINESPEC (location) = savestring (orig, p - orig);
}
- return location;
+ return event_location_up (location);
}
/* See description in location.h. */
/* See description in location.h. */
-struct event_location *
+event_location_up
new_address_location (CORE_ADDR addr, const char *addr_string,
int addr_string_len)
{
EL_ADDRESS (location) = addr;
if (addr_string != NULL)
EL_STRING (location) = xstrndup (addr_string, addr_string_len);
- return location;
+ return event_location_up (location);
}
/* See description in location.h. */
/* See description in location.h. */
-struct event_location *
+event_location_up
new_probe_location (const char *probe)
{
struct event_location *location;
EL_TYPE (location) = PROBE_LOCATION;
if (probe != NULL)
EL_PROBE (location) = xstrdup (probe);
- return location;
+ return event_location_up (location);
}
/* See description in location.h. */
/* See description in location.h. */
-struct event_location *
+event_location_up
new_explicit_location (const struct explicit_location *explicit_loc)
{
struct event_location tmp;
/* See description in location.h. */
-struct event_location *
+event_location_up
copy_event_location (const struct event_location *src)
{
struct event_location *dst;
gdb_assert_not_reached ("unknown event location type");
}
- return dst;
-}
-
-/* A cleanup function for struct event_location. */
-
-static void
-delete_event_location_cleanup (void *data)
-{
- struct event_location *location = (struct event_location *) data;
-
- delete_event_location (location);
-}
-
-/* See description in location.h. */
-
-struct cleanup *
-make_cleanup_delete_event_location (struct event_location *location)
-{
- return make_cleanup (delete_event_location_cleanup, location);
+ return event_location_up (dst);
}
/* See description in location.h. */
/* See description in location.h. */
-struct event_location *
+event_location_up
string_to_explicit_location (const char **argp,
const struct language_defn *language,
int dont_throw)
{
- struct cleanup *cleanup;
- struct event_location *location;
+ event_location_up location;
/* It is assumed that input beginning with '-' and a non-digit
character is an explicit location. "-p" is reserved, though,
return NULL;
location = new_explicit_location (NULL);
- cleanup = make_cleanup_delete_event_location (location);
/* Process option/argument pairs. dprintf_command
requires that processing stop on ','. */
*argp = start;
discard_cleanups (oarg_cleanup);
do_cleanups (opt_cleanup);
- discard_cleanups (cleanup);
return location;
}
"line offset."));
}
- discard_cleanups (cleanup);
return location;
}
/* See description in location.h. */
-struct event_location *
+event_location_up
string_to_event_location_basic (char **stringp,
const struct language_defn *language)
{
- struct event_location *location;
+ event_location_up location;
const char *cs;
/* Try the input as a probe spec. */
/* See description in location.h. */
-struct event_location *
+event_location_up
string_to_event_location (char **stringp,
const struct language_defn *language)
{
- struct event_location *location;
const char *arg, *orig;
/* Try an explicit location. */
orig = arg = *stringp;
- location = string_to_explicit_location (&arg, language, 0);
+ event_location_up location = string_to_explicit_location (&arg, language, 0);
if (location != NULL)
{
/* It was a valid explicit location. Advance STRINGP to
extern const char *
event_location_to_string (struct event_location *location);
-/* Create a new linespec location. The return result is malloc'd
- and should be freed with delete_event_location. */
+/* Free an event location and any associated data. */
+
+extern void delete_event_location (struct event_location *location);
+
+/* A deleter for a struct event_location. */
+
+struct event_location_deleter
+{
+ void operator() (event_location *location) const
+ {
+ delete_event_location (location);
+ }
+};
+
+/* A unique pointer for event_location. */
+typedef std::unique_ptr<event_location, event_location_deleter>
+ event_location_up;
+
+/* Create a new linespec location. */
-extern struct event_location *
- new_linespec_location (char **linespec);
+extern event_location_up new_linespec_location (char **linespec);
/* Return the linespec location (a string) of the given event_location
(which must be of type LINESPEC_LOCATION). */
ADDR_STRING, a string of ADDR_STRING_LEN characters, is
the expression that was parsed to determine the address ADDR. */
-extern struct event_location *
- new_address_location (CORE_ADDR addr, const char *addr_string,
- int addr_string_len);
+extern event_location_up new_address_location (CORE_ADDR addr,
+ const char *addr_string,
+ int addr_string_len);
/* Return the address location (a CORE_ADDR) of the given event_location
(which must be of type ADDRESS_LOCATION). */
extern const char *
get_address_string_location (const struct event_location *location);
-/* Create a new probe location. The return result is malloc'd
- and should be freed with delete_event_location. */
+/* Create a new probe location. */
-extern struct event_location *
- new_probe_location (const char *probe);
+extern event_location_up new_probe_location (const char *probe);
/* Return the probe location (a string) of the given event_location
(which must be of type PROBE_LOCATION). */
initialize_explicit_location (struct explicit_location *explicit_loc);
/* Create a new explicit location. If not NULL, EXPLICIT is checked for
- validity. If invalid, an exception is thrown.
+ validity. If invalid, an exception is thrown. */
- The return result is malloc'd and should be freed with
- delete_event_location. */
-
-extern struct event_location *
+extern event_location_up
new_explicit_location (const struct explicit_location *explicit_loc);
/* Return the explicit location of the given event_location
extern const struct explicit_location *
get_explicit_location_const (const struct event_location *location);
-/* Free an event location and any associated data. */
-
-extern void delete_event_location (struct event_location *location);
-
-/* Make a cleanup to free LOCATION. */
-
-extern struct cleanup *
- make_cleanup_delete_event_location (struct event_location *location);
-
/* Return a copy of the given SRC location. */
-extern struct event_location *
+extern event_location_up
copy_event_location (const struct event_location *src);
/* Attempt to convert the input string in *ARGP into an event_location.
but invalid, input, e.g., if it is called with missing argument parameters
or invalid options.
- The return result must be freed with delete_event_location.
-
This function is intended to be used by CLI commands and will parse
explicit locations in a CLI-centric way. Other interfaces should use
string_to_event_location_basic if they want to maintain support for
legacy specifications of probe, address, and linespec locations. */
-extern struct event_location *
+extern event_location_up
string_to_event_location (char **argp,
const struct language_defn *langauge);
/* Like string_to_event_location, but does not attempt to parse explicit
locations. */
-extern struct event_location *
+extern event_location_up
string_to_event_location_basic (char **argp,
const struct language_defn *language);
parameters or invalid options. If DONT_THROW is non-zero, this function
will not throw any exceptions. */
-extern struct event_location *
+extern event_location_up
string_to_explicit_location (const char **argp,
const struct language_defn *langauge,
int dont_throw);
int tracepoint = 0;
struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
enum bptype type_wanted;
- struct event_location *location;
+ event_location_up location;
struct breakpoint_ops *ops;
int is_explicit = 0;
struct explicit_location explicit_loc;
{
location = string_to_event_location_basic (&address, current_language);
if (*address)
- {
- delete_event_location (location);
- error (_("Garbage '%s' at end of location"), address);
- }
+ error (_("Garbage '%s' at end of location"), address);
}
- make_cleanup_delete_event_location (location);
-
- create_breakpoint (get_current_arch (), location, condition, thread,
+ create_breakpoint (get_current_arch (), location.get (), condition, thread,
extra_string,
0 /* condition and thread are valid. */,
temp_p, type_wanted,
make_cleanup (xfree, canon);
canonical->special_display = 1;
canonical->pre_expanded = 1;
- canonical->location = new_probe_location (canon);
+ canonical->location = new_probe_location (canon).release ();
}
do_cleanups (cleanup);
{
case bp_breakpoint:
{
- struct event_location *location;
- struct cleanup *cleanup;
-
- location
+ event_location_up location
= string_to_event_location_basic (©, current_language);
- cleanup = make_cleanup_delete_event_location (location);
create_breakpoint (python_gdbarch,
- location, NULL, -1, NULL,
+ location.get (), NULL, -1, NULL,
0,
temporary_bp, bp_breakpoint,
0,
AUTO_BOOLEAN_TRUE,
&bkpt_breakpoint_ops,
0, 1, internal_bp, 0);
-
- do_cleanups (cleanup);
break;
}
case bp_watchpoint:
TRY
{
- struct event_location *location;
- struct cleanup *back_to;
-
/* Set a breakpoint on the return address. */
- location = new_address_location (get_frame_pc (prev_frame), NULL, 0);
- back_to = make_cleanup_delete_event_location (location);
+ event_location_up location
+ = new_address_location (get_frame_pc (prev_frame), NULL, 0);
create_breakpoint (python_gdbarch,
- location, NULL, thread, NULL,
+ location.get (), NULL, thread, NULL,
0,
1 /*temp_flag*/,
bp_breakpoint,
AUTO_BOOLEAN_TRUE,
&bkpt_breakpoint_ops,
0, 1, internal_bp, 0);
- do_cleanups (back_to);
}
CATCH (except, RETURN_MASK_ALL)
{
struct cleanup *cleanups;
gdbpy_ref<> result;
gdbpy_ref<> unparsed;
- struct event_location *location = NULL;
+ event_location_up location;
if (! PyArg_ParseTuple (args, "|s", &arg))
return NULL;
sals.sals = NULL;
if (arg != NULL)
- {
- location = string_to_event_location_basic (&arg, python_language);
- make_cleanup_delete_event_location (location);
- }
+ location = string_to_event_location_basic (&arg, python_language);
TRY
{
if (location != NULL)
- sals = decode_line_1 (location, 0, NULL, NULL, 0);
+ sals = decode_line_1 (location.get (), 0, NULL, NULL, 0);
else
{
set_default_source_symtab_and_line ();
struct bound_minimal_symbol minsym;
struct compunit_symtab *cust;
CORE_ADDR pc;
- struct event_location *location;
- struct cleanup *back_to;
/* Do this only if requested by "set spu stop-on-load on". */
if (!spu_stop_on_load_p)
/* Use a numerical address for the set_breakpoint command to avoid having
the breakpoint re-set incorrectly. */
- location = new_address_location (pc, NULL, 0);
- back_to = make_cleanup_delete_event_location (location);
- create_breakpoint (get_objfile_arch (objfile), location,
+ event_location_up location = new_address_location (pc, NULL, 0);
+ create_breakpoint (get_objfile_arch (objfile), location.get (),
NULL /* cond_string */, -1 /* thread */,
NULL /* extra_string */,
0 /* parse_condition_and_thread */, 1 /* tempflag */,
AUTO_BOOLEAN_FALSE /* pending_break_support */,
&bkpt_breakpoint_ops /* ops */, 0 /* from_tty */,
1 /* enabled */, 0 /* internal */, 0);
- do_cleanups (back_to);
}
int j, count = 0;
struct gdbarch *gdbarch;
int regno;
- struct event_location *location;
- struct cleanup *back_to;
if (args == 0 || *args == 0)
error (_("requires an argument (function, "
"line or *addr) to define a scope"));
- location = string_to_event_location (&args, current_language);
- back_to = make_cleanup_delete_event_location (location);
- sals = decode_line_1 (location, DECODE_LINE_FUNFIRSTLINE, NULL, NULL, 0);
+ event_location_up location = string_to_event_location (&args,
+ current_language);
+ sals = decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE,
+ NULL, NULL, 0);
if (sals.nelts == 0)
{
/* Presumably decode_line_1 has already warned. */
- do_cleanups (back_to);
return;
}
if (count <= 0)
printf_filtered ("Scope for %s contains no locals or arguments.\n",
save_args);
- do_cleanups (back_to);
}
/* Helper for trace_dump_command. Dump the action list starting at