From 8e9e35b1808481735e2d1efbf70ed7396a845d8e Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 10 Apr 2017 15:53:22 -0600 Subject: [PATCH] Change linespec_result::location to be an event_location_up This is a follow-up to another patch. It changes linespec_result::location to be an event_location_up. gdb/ChangeLog 2017-04-12 Tom Tromey * probe.c (parse_probes): Update. * location.h (delete_event_location): Don't declare. (event_location_deleter::operator()): Update. * location.c (event_location_deleter::operator()): Rename from delete_event_location. * linespec.h (linespec_result) : Change type to event_location_up. * linespec.c (canonicalize_linespec, event_location_to_sals) (decode_objc): Update. (linespec_result): Don't call delete_event_location. * breakpoint.c (create_breakpoints_sal) (bkpt_probe_create_sals_from_location) (strace_marker_create_sals_from_location): Update. --- gdb/ChangeLog | 16 ++++++++++++++++ gdb/breakpoint.c | 12 +++++++----- gdb/linespec.c | 10 +++++----- gdb/linespec.h | 6 +++--- gdb/location.c | 4 +--- gdb/location.h | 9 +-------- gdb/probe.c | 2 +- 7 files changed, 34 insertions(+), 25 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7ddac5b..cf3e144 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,21 @@ 2017-04-12 Tom Tromey + * probe.c (parse_probes): Update. + * location.h (delete_event_location): Don't declare. + (event_location_deleter::operator()): Update. + * location.c (event_location_deleter::operator()): Rename from + delete_event_location. + * linespec.h (linespec_result) : Change type to + event_location_up. + * linespec.c (canonicalize_linespec, event_location_to_sals) + (decode_objc): Update. + (linespec_result): Don't call delete_event_location. + * breakpoint.c (create_breakpoints_sal) + (bkpt_probe_create_sals_from_location) + (strace_marker_create_sals_from_location): Update. + +2017-04-12 Tom Tromey + * linespec.h (struct linespec_result): Add constructor and destructor. (init_linespec_result, destroy_linespec_result) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 42f344a..42e2e6d 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -9429,7 +9429,7 @@ create_breakpoints_sal (struct gdbarch *gdbarch, 'break', without arguments. */ 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; make_cleanup (xfree, filter_string); @@ -13390,7 +13390,8 @@ bkpt_probe_create_sals_from_location (const struct event_location *location, 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); } @@ -13646,10 +13647,11 @@ strace_marker_create_sals_from_location (const struct event_location *location, str = savestring (arg_start, arg - arg_start); cleanup = make_cleanup (xfree, str); - canonical->location = new_linespec_location (&str).release (); + 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); } @@ -13686,7 +13688,7 @@ strace_marker_create_breakpoints_sal (struct gdbarch *gdbarch, expanded.nelts = 1; expanded.sals = &lsal->sals.sals[i]; - location = copy_event_location (canonical->location); + location = copy_event_location (canonical->location.get ()); tp = new tracepoint (); init_breakpoint_sal (&tp->base, gdbarch, expanded, diff --git a/gdb/linespec.c b/gdb/linespec.c index 51fa128..acf4900 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1750,8 +1750,9 @@ canonicalize_linespec (struct linespec_state *state, const linespec_p ls) return; /* Save everything as an explicit location. */ - canon = state->canonical->location - = new_explicit_location (&ls->explicit_loc).release (); + state->canonical->location + = new_explicit_location (&ls->explicit_loc); + canon = state->canonical->location.get (); explicit_loc = get_explicit_location (canon); if (explicit_loc->label_name != NULL) @@ -2491,7 +2492,7 @@ event_location_to_sals (linespec_parser *parser, addr = linespec_expression_to_pc (&const_expr); if (PARSER_STATE (parser)->canonical != NULL) PARSER_STATE (parser)->canonical->location - = copy_event_location (location).release (); + = copy_event_location (location); do_cleanups (cleanup); } @@ -2780,7 +2781,7 @@ decode_objc (struct linespec_state *self, linespec_p ls, const char *arg) str = xstrdup (saved_arg); make_cleanup (xfree, str); - self->canonical->location = new_linespec_location (&str).release (); + self->canonical->location = new_linespec_location (&str); } } @@ -3892,7 +3893,6 @@ linespec_result::~linespec_result () int i; struct linespec_sals *lsal; - delete_event_location (location); for (i = 0; VEC_iterate (linespec_sals, sals, i, lsal); ++i) { xfree (lsal->canonical); diff --git a/gdb/linespec.h b/gdb/linespec.h index 5ea8f6f..f1244c4 100644 --- a/gdb/linespec.h +++ b/gdb/linespec.h @@ -19,6 +19,7 @@ struct symtab; +#include "location.h" #include "vec.h" /* Flags to pass to decode_line_1 and decode_line_full. */ @@ -61,7 +62,6 @@ struct linespec_result linespec_result () : special_display (0), pre_expanded (0), - location (NULL), sals (NULL) { } @@ -83,8 +83,8 @@ struct linespec_result int pre_expanded; /* If PRE_EXPANDED is non-zero, this is set to the location entered - by the user. This will be freed by destroy_linespec_result. */ - struct event_location *location; + by the user. */ + event_location_up location; /* The sals. The vector will be freed by the destructor. */ VEC (linespec_sals) *sals; diff --git a/gdb/location.c b/gdb/location.c index 8aa8bd5..8796320 100644 --- a/gdb/location.c +++ b/gdb/location.c @@ -342,10 +342,8 @@ copy_event_location (const struct event_location *src) return event_location_up (dst); } -/* See description in location.h. */ - void -delete_event_location (struct event_location *location) +event_location_deleter::operator() (event_location *location) const { if (location != NULL) { diff --git a/gdb/location.h b/gdb/location.h index 5a5adb5..7e1f012 100644 --- a/gdb/location.h +++ b/gdb/location.h @@ -114,18 +114,11 @@ extern char * extern const char * event_location_to_string (struct event_location *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); - } + void operator() (event_location *location) const; }; /* A unique pointer for event_location. */ diff --git a/gdb/probe.c b/gdb/probe.c index 4f4a5a3..c147810 100644 --- a/gdb/probe.c +++ b/gdb/probe.c @@ -205,7 +205,7 @@ parse_probes (const struct event_location *location, make_cleanup (xfree, canon); canonical->special_display = 1; canonical->pre_expanded = 1; - canonical->location = new_probe_location (canon).release (); + canonical->location = new_probe_location (canon); } do_cleanups (cleanup); -- 2.7.4