Change linespec_result::location to be an event_location_up
authorTom Tromey <tom@tromey.com>
Mon, 10 Apr 2017 21:53:22 +0000 (15:53 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 12 Apr 2017 17:16:19 +0000 (11:16 -0600)
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  <tom@tromey.com>

* 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) <location>: 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
gdb/breakpoint.c
gdb/linespec.c
gdb/linespec.h
gdb/location.c
gdb/location.h
gdb/probe.c

index 7ddac5b..cf3e144 100644 (file)
@@ -1,5 +1,21 @@
 2017-04-12  Tom Tromey  <tom@tromey.com>
 
+       * 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) <location>: 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  <tom@tromey.com>
+
        * linespec.h (struct linespec_result): Add constructor and
        destructor.
        (init_linespec_result, destroy_linespec_result)
index 42f344a..42e2e6d 100644 (file)
@@ -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,
index 51fa128..acf4900 100644 (file)
@@ -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);
index 5ea8f6f..f1244c4 100644 (file)
@@ -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;
index 8aa8bd5..8796320 100644 (file)
@@ -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)
     {
index 5a5adb5..7e1f012 100644 (file)
@@ -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.  */
index 4f4a5a3..c147810 100644 (file)
@@ -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);