This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/3] struct symtabs_and_lines -> std::vector<symtab_and_line>


This replaces "struct symtabs_and_lines" with
std::vector<symtab_and_line> in most cases.  This removes a number of
cleanups.

In some cases, the sals objects do not own the sals they point at.
Instead they point at some sal that lives on the stack.  Typically
something like this:

  struct symtab_and_line sal;
  struct symtabs_and_lines sals;

  // fill in sal

  sals.nelts = 1;
  sals.sals = &sal;

  // use sals

Instead of switching those cases to std::vector too, such usages are
replaced by gdb::array_view<symtab_and_line> instead.  This avoids
introducing heap allocations.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	* ax-gdb.c (agent_command_1): Use range-for.
	* break-catch-throw.c (re_set_exception_catchpoint): Update.
	* breakpoint.c: Include "common/array-view.h".
	(init_breakpoint_sal, create_breakpoint_sal): Change sals
	parameter from struct symtabs_and_lines to
	array_view<symtab_and_line>.  Adjust.  Use range-for.  Update.
	(breakpoint_sals_to_pc): Change sals parameter from struct
	symtabs_and_lines to std::vector reference.
	(check_fast_tracepoint_sals): Change sals parameter from struct
	symtabs_and_lines to std::array_view.  Use range-for.
	(decode_static_tracepoint_spec): Return a std::vector instead of
	symtabs_and_lines.  Update.
	(create_breakpoint): Update.
	(break_range_command, until_break_command, clear_command): Update.
	(base_breakpoint_decode_location, bkpt_decode_location)
	(bkpt_probe_create_sals_from_location)
	(bkpt_probe_decode_location, tracepoint_decode_location)
	(tracepoint_probe_decode_location)
	(strace_marker_create_sals_from_location): Return a std::vector
	instead of symtabs_and_lines.
	(strace_marker_create_breakpoints_sal): Update.
	(strace_marker_decode_location): Return a std::vector instead of
	symtabs_and_lines.  Update.
	(update_breakpoint_locations): Change struct symtabs_and_lines
	parameters to gdb::array_view.  Adjust.
	(location_to_sals): Return a std::vector instead of
	symtabs_and_lines.  Update.
	(breakpoint_re_set_default): Use std::vector instead of struct
	symtabs_and_lines.
	(decode_location_default): Return a std::vector instead of
	symtabs_and_lines.  Update.
	* breakpoint.h: Include "common/array-view.h".
	(struct breakpoint_ops) <decode_location>: Now returns a
	std::vector instead of returning a symtabs_and_lines via output
	parameter.
	(update_breakpoint_locations): Change sals parameters to use
	gdb::array_view.
	* cli/cli-cmds.c (edit_command, list_command): Update to use
	std::vector and gdb::array_view.
	(ambiguous_line_spec): Adjust to use gdb::array_view and
	range-for.
	(compare_symtabs): Rename to ...
	(cmp_symtabs): ... this.  Change parameters to symtab_and_line
	const reference and adjust.
	(filter_sals): Rewrite using std::vector and standard algorithms.
	* elfread.c (elf_gnu_ifunc_resolver_return_stop): Simplify.
	(jump_command): Update to use std::vector.
	* linespec.c (struct linespec_state) <canonical_names>: Update
	comment.
	(add_sal_to_sals_basic): Delete.
	(add_sal_to_sals, filter_results, convert_results_to_lsals)
	(decode_line_2, create_sals_line_offset)
	(convert_address_location_to_sals, convert_linespec_to_sals)
	(convert_explicit_location_to_sals, parse_linespec)
	(event_location_to_sals, decode_line_full, decode_line_1)
	(decode_line_with_current_source)
	(decode_line_with_last_displayed, decode_objc)
	(decode_digits_list_mode, decode_digits_ordinary, minsym_found)
	(linespec_result::~linespec_result): Adjust to use std::vector
	instead of symtabs_and_lines.
	* linespec.h (linespec_sals::sals): Now a std::vector.
	(struct linespec_result): Use std::vector, bool, and in-class
	initialization.
	(decode_line_1, decode_line_with_current_source)
	(decode_line_with_last_displayed): Return std::vector.
	* macrocmd.c (info_macros_command): Use std::vector.
	* mi/mi-main.c (mi_cmd_trace_find): Use std::vector.
	* probe.c (parse_probes_in_pspace, parse_probes): Adjust to use
	std::vector.
	* probe.h (parse_probes): Return a std::vector.
	* python/python.c (gdbpy_decode_line): Use std::vector and
	gdb::array_view.
	* source.c (select_source_symtab, line_info): Use std::vector.
	* stack.c (func_command): Use std::vector.
	* symtab.h (struct symtabs_and_lines): Delete.
	* tracepoint.c (tfind_line_command, scope_info): Use std::vector.
---
 gdb/ax-gdb.c            |  12 +-
 gdb/break-catch-throw.c |  12 +-
 gdb/breakpoint.c        | 331 +++++++++++++++++++++---------------------------
 gdb/breakpoint.h        |  20 +--
 gdb/cli/cli-cmds.c      | 151 +++++++++-------------
 gdb/elfread.c           |  10 +-
 gdb/infcmd.c            |  16 +--
 gdb/linespec.c          | 252 ++++++++++++++++--------------------
 gdb/linespec.h          |  32 ++---
 gdb/macrocmd.c          |   8 +-
 gdb/mi/mi-main.c        |  17 +--
 gdb/probe.c             |  34 ++---
 gdb/probe.h             |  14 +-
 gdb/python/python.c     |  47 +++----
 gdb/source.c            |  43 +++----
 gdb/stack.c             |  21 ++-
 gdb/symtab.h            |   5 -
 gdb/tracepoint.c        |  31 ++---
 18 files changed, 434 insertions(+), 622 deletions(-)

diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 91bc4b8..a72a458 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -2577,8 +2577,6 @@ agent_command_1 (char *exp, int eval)
   if (check_for_argument (&exp, "-at", sizeof ("-at") - 1))
     {
       struct linespec_result canonical;
-      int ix;
-      struct linespec_sals *iter;
 
       exp = skip_spaces (exp);
 
@@ -2592,13 +2590,9 @@ agent_command_1 (char *exp, int eval)
 	  exp++;
 	  exp = skip_spaces (exp);
 	}
-      for (ix = 0; VEC_iterate (linespec_sals, canonical.sals, ix, iter); ++ix)
-        {
-	  int i;
-
-	  for (i = 0; i < iter->sals.nelts; i++)
-	    agent_eval_command_one (exp, eval, iter->sals.sals[i].pc);
-        }
+      for (const auto &lsal : canonical.lsals)
+	for (const auto &sal : lsal.sals)
+	  agent_eval_command_one (exp, eval, sal.pc);
     }
   else
     agent_eval_command_one (exp, eval, get_frame_pc (get_current_frame ()));
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 5318e5f..e05834a 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -184,9 +184,7 @@ check_status_exception_catchpoint (struct bpstats *bs)
 static void
 re_set_exception_catchpoint (struct breakpoint *self)
 {
-  struct symtabs_and_lines sals = {0};
-  struct symtabs_and_lines sals_end = {0};
-  struct cleanup *cleanup;
+  std::vector<symtab_and_line> sals;
   enum exception_event_kind kind = classify_exception_breakpoint (self);
   struct program_space *filter_pspace = current_program_space;
 
@@ -209,8 +207,8 @@ re_set_exception_catchpoint (struct breakpoint *self)
 	  explicit_loc.function_name
 	    = ASTRDUP (exception_functions[kind].function);
 	  event_location_up location = new_explicit_location (&explicit_loc);
-	  self->ops->decode_location (self, location.get (), filter_pspace,
-				      &sals);
+	  sals = self->ops->decode_location (self, location.get (),
+					     filter_pspace);
 	}
       CATCH (ex, RETURN_MASK_ERROR)
 	{
@@ -223,9 +221,7 @@ re_set_exception_catchpoint (struct breakpoint *self)
     }
   END_CATCH
 
-  cleanup = make_cleanup (xfree, sals.sals);
-  update_breakpoint_locations (self, filter_pspace, sals, sals_end);
-  do_cleanups (cleanup);
+  update_breakpoint_locations (self, filter_pspace, sals, {});
 }
 
 static enum print_stop_action
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index bc681cf..f7d404d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -81,6 +81,7 @@
 #include "extension.h"
 #include <algorithm>
 #include "progspace-and-thread.h"
+#include "common/array-view.h"
 
 /* Enums for exception-handling support.  */
 enum exception_event_kind
@@ -128,10 +129,9 @@ static void create_breakpoints_sal_default (struct gdbarch *,
 					    const struct breakpoint_ops *,
 					    int, int, int, unsigned);
 
-static void decode_location_default (struct breakpoint *b,
-				     const struct event_location *location,
-				     struct program_space *search_pspace,
-				     struct symtabs_and_lines *sals);
+static std::vector<symtab_and_line> decode_location_default
+  (struct breakpoint *b, const struct event_location *location,
+   struct program_space *search_pspace);
 
 static void clear_command (char *, int);
 
@@ -9148,7 +9148,7 @@ update_dprintf_commands (char *args, int from_tty,
 
 static void
 init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
-		     struct symtabs_and_lines sals,
+		     gdb::array_view<const symtab_and_line> sals,
 		     event_location_up &&location,
 		     gdb::unique_xmalloc_ptr<char> filter,
 		     gdb::unique_xmalloc_ptr<char> cond_string,
@@ -9175,11 +9175,10 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
 	error (_("Hardware breakpoints used exceeds limit."));
     }
 
-  gdb_assert (sals.nelts > 0);
+  gdb_assert (!sals.empty ());
 
-  for (i = 0; i < sals.nelts; ++i)
+  for (const auto &sal : sals)
     {
-      struct symtab_and_line sal = sals.sals[i];
       struct bp_location *loc;
 
       if (from_tty)
@@ -9192,7 +9191,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
 				      sal.pspace, sal.pc, sal.section, thread);
 	}
 
-      if (i == 0)
+      if (&sal == &sals[0])
 	{
 	  init_raw_breakpoint (b, gdbarch, sal, type, ops);
 	  b->thread = thread;
@@ -9288,7 +9287,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
 
 static void
 create_breakpoint_sal (struct gdbarch *gdbarch,
-		       struct symtabs_and_lines sals,
+		       gdb::array_view<const symtab_and_line> sals,
 		       event_location_up &&location,
 		       gdb::unique_xmalloc_ptr<char> filter,
 		       gdb::unique_xmalloc_ptr<char> cond_string,
@@ -9340,13 +9339,10 @@ create_breakpoints_sal (struct gdbarch *gdbarch,
 			const struct breakpoint_ops *ops, int from_tty,
 			int enabled, int internal, unsigned flags)
 {
-  int i;
-  struct linespec_sals *lsal;
-
   if (canonical->pre_expanded)
-    gdb_assert (VEC_length (linespec_sals, canonical->sals) == 1);
+    gdb_assert (canonical->lsals.size () == 1);
 
-  for (i = 0; VEC_iterate (linespec_sals, canonical->sals, i, lsal); ++i)
+  for (const auto &lsal : canonical->lsals)
     {
       /* Note that 'location' can be NULL in the case of a plain
 	 'break', without arguments.  */
@@ -9354,9 +9350,9 @@ create_breakpoints_sal (struct gdbarch *gdbarch,
 	= (canonical->location != NULL
 	   ? copy_event_location (canonical->location.get ()) : NULL);
       gdb::unique_xmalloc_ptr<char> filter_string
-	(lsal->canonical != NULL ? xstrdup (lsal->canonical) : NULL);
+	(lsal.canonical != NULL ? xstrdup (lsal.canonical) : NULL);
 
-      create_breakpoint_sal (gdbarch, lsal->sals,
+      create_breakpoint_sal (gdbarch, lsal.sals,
 			     std::move (location),
 			     std::move (filter_string),
 			     std::move (cond_string),
@@ -9392,12 +9388,10 @@ parse_breakpoint_sals (const struct event_location *location,
 	     breakpoint address.  */
 	  if (last_displayed_sal_is_valid ())
 	    {
-	      struct linespec_sals lsal;
 	      struct symtab_and_line sal;
 	      CORE_ADDR pc;
 
 	      init_sal (&sal);		/* Initialize to zeroes.  */
-	      lsal.sals.sals = XNEW (struct symtab_and_line);
 
 	      /* Set sal's pspace, pc, symtab, and line to the values
 		 corresponding to the last call to print_frame_info.
@@ -9416,11 +9410,11 @@ parse_breakpoint_sals (const struct event_location *location,
 	      sal.pc = pc;
 	      sal.explicit_pc = 1;
 
-	      lsal.sals.sals[0] = sal;
-	      lsal.sals.nelts = 1;
+	      struct linespec_sals lsal;
+	      lsal.sals = {sal};
 	      lsal.canonical = NULL;
 
-	      VEC_safe_push (linespec_sals, canonical->sals, &lsal);
+	      canonical->lsals.push_back (std::move (lsal));
 	      return;
 	    }
 	  else
@@ -9465,12 +9459,10 @@ parse_breakpoint_sals (const struct event_location *location,
    inserted as a breakpoint.  If it can't throw an error.  */
 
 static void
-breakpoint_sals_to_pc (struct symtabs_and_lines *sals)
+breakpoint_sals_to_pc (std::vector<symtab_and_line> &sals)
 {    
-  int i;
-
-  for (i = 0; i < sals->nelts; i++)
-    resolve_sal_pc (&sals->sals[i]);
+  for (auto &sal : sals)
+    resolve_sal_pc (&sal);
 }
 
 /* Fast tracepoints may have restrictions on valid locations.  For
@@ -9482,30 +9474,27 @@ breakpoint_sals_to_pc (struct symtabs_and_lines *sals)
 
 static void
 check_fast_tracepoint_sals (struct gdbarch *gdbarch,
-			    struct symtabs_and_lines *sals)
+			    gdb::array_view<const symtab_and_line> sals)
 {
-  int i, rslt;
-  struct symtab_and_line *sal;
+  int rslt;
   char *msg;
   struct cleanup *old_chain;
 
-  for (i = 0; i < sals->nelts; i++)
+  for (const auto &sal : sals)
     {
       struct gdbarch *sarch;
 
-      sal = &sals->sals[i];
-
-      sarch = get_sal_arch (*sal);
+      sarch = get_sal_arch (sal);
       /* We fall back to GDBARCH if there is no architecture
 	 associated with SAL.  */
       if (sarch == NULL)
 	sarch = gdbarch;
-      rslt = gdbarch_fast_tracepoint_valid_at (sarch, sal->pc, &msg);
+      rslt = gdbarch_fast_tracepoint_valid_at (sarch, sal.pc, &msg);
       old_chain = make_cleanup (xfree, msg);
 
       if (!rslt)
 	error (_("May not have a fast tracepoint at %s%s"),
-	       paddress (sarch, sal->pc), (msg ? msg : ""));
+	       paddress (sarch, sal.pc), (msg ? msg : ""));
 
       do_cleanups (old_chain);
     }
@@ -9590,11 +9579,10 @@ find_condition_and_thread (const char *tok, CORE_ADDR pc,
 
 /* Decode a static tracepoint marker spec.  */
 
-static struct symtabs_and_lines
+static std::vector<symtab_and_line>
 decode_static_tracepoint_spec (const char **arg_p)
 {
   VEC(static_tracepoint_marker_p) *markers = NULL;
-  struct symtabs_and_lines sals;
   struct cleanup *old_chain;
   const char *p = &(*arg_p)[3];
   const char *endp;
@@ -9612,19 +9600,21 @@ decode_static_tracepoint_spec (const char **arg_p)
   if (VEC_empty(static_tracepoint_marker_p, markers))
     error (_("No known static tracepoint marker named %s"), marker_str);
 
-  sals.nelts = VEC_length(static_tracepoint_marker_p, markers);
-  sals.sals = XNEWVEC (struct symtab_and_line, sals.nelts);
+  std::vector<symtab_and_line> sals;
+  sals.reserve (VEC_length(static_tracepoint_marker_p, markers));
 
-  for (i = 0; i < sals.nelts; i++)
+  for (i = 0; i < VEC_length(static_tracepoint_marker_p, markers); i++)
     {
       struct static_tracepoint_marker *marker;
 
       marker = VEC_index (static_tracepoint_marker_p, markers, i);
 
-      init_sal (&sals.sals[i]);
+      symtab_and_line sal;
+      init_sal (&sal);
 
-      sals.sals[i] = find_pc_line (marker->address, 0);
-      sals.sals[i].pc = marker->address;
+      sal = find_pc_line (marker->address, 0);
+      sal.pc = marker->address;
+      sals.push_back (sal);
 
       release_static_tracepoint_marker (marker);
     }
@@ -9698,7 +9688,7 @@ create_breakpoint (struct gdbarch *gdbarch,
     }
   END_CATCH
 
-  if (!pending && VEC_empty (linespec_sals, canonical.sals))
+  if (!pending && canonical.lsals.empty ())
     return 0;
 
   /* ----------------------------- SNIP -----------------------------
@@ -9711,21 +9701,15 @@ create_breakpoint (struct gdbarch *gdbarch,
      are ok for the target.  */
   if (!pending)
     {
-      int ix;
-      struct linespec_sals *iter;
-
-      for (ix = 0; VEC_iterate (linespec_sals, canonical.sals, ix, iter); ++ix)
-	breakpoint_sals_to_pc (&iter->sals);
+      for (auto &lsal : canonical.lsals)
+	breakpoint_sals_to_pc (lsal.sals);
     }
 
   /* Fast tracepoints may have additional restrictions on location.  */
   if (!pending && type_wanted == bp_fast_tracepoint)
     {
-      int ix;
-      struct linespec_sals *iter;
-
-      for (ix = 0; VEC_iterate (linespec_sals, canonical.sals, ix, iter); ++ix)
-	check_fast_tracepoint_sals (gdbarch, &iter->sals);
+      for (const auto &lsal : canonical.lsals)
+	check_fast_tracepoint_sals (gdbarch, lsal.sals);
     }
 
   /* Verify that condition can be parsed, before setting any
@@ -9740,16 +9724,15 @@ create_breakpoint (struct gdbarch *gdbarch,
         {
 	  char *rest;
 	  char *cond;
-	  struct linespec_sals *lsal;
 
-	  lsal = VEC_index (linespec_sals, canonical.sals, 0);
+	  const linespec_sals &lsal = canonical.lsals[0];
 
 	  /* Here we only parse 'arg' to separate condition
 	     from thread number, so parsing in context of first
 	     sal is OK.  When setting the breakpoint we'll
 	     re-parse it in context of each sal.  */
 
-	  find_condition_and_thread (extra_string, lsal->sals.sals[0].pc,
+	  find_condition_and_thread (extra_string, lsal.sals[0].pc,
 				     &cond, &thread, &task, &rest);
 	  cond_string_copy.reset (cond);
 	  extra_string_copy.reset (rest);
@@ -9805,7 +9788,7 @@ create_breakpoint (struct gdbarch *gdbarch,
       install_breakpoint (internal, b.release (), 0);
     }
   
-  if (VEC_length (linespec_sals, canonical.sals) > 1)
+  if (canonical.lsals.size () > 1)
     {
       warning (_("Multiple breakpoints were set.\nUse the "
 		 "\"delete\" command to delete unwanted breakpoints."));
@@ -10240,9 +10223,7 @@ break_range_command (char *arg, int from_tty)
   int bp_count, can_use_bp, length;
   CORE_ADDR end;
   struct breakpoint *b;
-  struct symtab_and_line sal_start, sal_end;
   struct cleanup *cleanup_bkpt;
-  struct linespec_sals *lsal_start, *lsal_end;
 
   /* We don't support software ranged breakpoints.  */
   if (target_ranged_break_num_registers () < 0)
@@ -10266,16 +10247,16 @@ break_range_command (char *arg, int from_tty)
 
   if (arg[0] != ',')
     error (_("Too few arguments."));
-  else if (VEC_empty (linespec_sals, canonical_start.sals))
+  else if (canonical_start.lsals.empty ())
     error (_("Could not find location of the beginning of the range."));
 
-  lsal_start = VEC_index (linespec_sals, canonical_start.sals, 0);
+  const linespec_sals &lsal_start = canonical_start.lsals[0];
 
-  if (VEC_length (linespec_sals, canonical_start.sals) > 1
-      || lsal_start->sals.nelts != 1)
+  if (canonical_start.lsals.size () > 1
+      || lsal_start.sals.size () != 1)
     error (_("Cannot create a ranged breakpoint with multiple locations."));
 
-  sal_start = lsal_start->sals.sals[0];
+  const symtab_and_line &sal_start = lsal_start.sals[0];
   addr_string_start = savestring (arg_start, arg - arg_start);
   cleanup_bkpt = make_cleanup (xfree, addr_string_start);
 
@@ -10297,15 +10278,15 @@ break_range_command (char *arg, int from_tty)
 		    sal_start.symtab, sal_start.line,
 		    &canonical_end, NULL, NULL);
 
-  if (VEC_empty (linespec_sals, canonical_end.sals))
+  if (canonical_end.lsals.empty ())
     error (_("Could not find location of the end of the range."));
 
-  lsal_end = VEC_index (linespec_sals, canonical_end.sals, 0);
-  if (VEC_length (linespec_sals, canonical_end.sals) > 1
-      || lsal_end->sals.nelts != 1)
+  const linespec_sals &lsal_end = canonical_end.lsals[0];
+  if (canonical_end.lsals.size () > 1
+      || lsal_end.sals.size () != 1)
     error (_("Cannot create a ranged breakpoint with multiple locations."));
 
-  sal_end = lsal_end->sals.sals[0];
+  const symtab_and_line &sal_end = lsal_end.sals[0];
 
   end = find_breakpoint_range_end (sal_end);
   if (sal_start.pc > end)
@@ -11521,8 +11502,6 @@ until_break_fsm_async_reply_reason (struct thread_fsm *self)
 void
 until_break_command (char *arg, int from_tty, int anywhere)
 {
-  struct symtabs_and_lines sals;
-  struct symtab_and_line sal;
   struct frame_info *frame;
   struct gdbarch *frame_gdbarch;
   struct frame_id stack_frame_id;
@@ -11541,19 +11520,18 @@ until_break_command (char *arg, int from_tty, int anywhere)
 
   event_location_up location = string_to_event_location (&arg, current_language);
 
-  if (last_displayed_sal_is_valid ())
-    sals = decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE, NULL,
-			  get_last_displayed_symtab (),
-			  get_last_displayed_line ());
-  else
-    sals = decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE,
-			  NULL, (struct symtab *) NULL, 0);
+  std::vector<symtab_and_line> sals
+    = (last_displayed_sal_is_valid ()
+       ? decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE, NULL,
+			get_last_displayed_symtab (),
+			get_last_displayed_line ())
+       : decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE,
+			NULL, (struct symtab *) NULL, 0));
 
-  if (sals.nelts != 1)
+  if (sals.size () != 1)
     error (_("Couldn't get information on specified line."));
 
-  sal = sals.sals[0];
-  xfree (sals.sals);	/* malloc'd, so freed.  */
+  symtab_and_line &sal = sals[0];
 
   if (*arg)
     error (_("Junk at end of arguments."));
@@ -11824,36 +11802,34 @@ clear_command (char *arg, int from_tty)
   VEC(breakpoint_p) *found = 0;
   int ix;
   int default_match;
-  struct symtabs_and_lines sals;
-  struct symtab_and_line sal;
   int i;
   struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
 
+  std::vector<symtab_and_line> decoded_sals;
+  symtab_and_line last_sal;
+  gdb::array_view<symtab_and_line> sals;
   if (arg)
     {
-      sals = decode_line_with_current_source (arg,
-					      (DECODE_LINE_FUNFIRSTLINE
-					       | DECODE_LINE_LIST_MODE));
-      make_cleanup (xfree, sals.sals);
+      decoded_sals
+	= decode_line_with_current_source (arg,
+					   (DECODE_LINE_FUNFIRSTLINE
+					    | DECODE_LINE_LIST_MODE));
       default_match = 0;
+      sals = decoded_sals;
     }
   else
     {
-      sals.sals = XNEW (struct symtab_and_line);
-      make_cleanup (xfree, sals.sals);
-      init_sal (&sal);		/* Initialize to zeroes.  */
+      init_sal (&last_sal);		/* Initialize to zeroes.  */
 
       /* Set sal's line, symtab, pc, and pspace to the values
 	 corresponding to the last call to print_frame_info.  If the
 	 codepoint is not valid, this will set all the fields to 0.  */
-      get_last_displayed_sal (&sal);
-      if (sal.symtab == 0)
+      get_last_displayed_sal (&last_sal);
+      if (last_sal.symtab == 0)
 	error (_("No source file specified."));
 
-      sals.sals[0] = sal;
-      sals.nelts = 1;
-
       default_match = 1;
+      sals = last_sal;
     }
 
   /* We don't call resolve_sal_pc here.  That's not as bad as it
@@ -11880,7 +11856,7 @@ clear_command (char *arg, int from_tty)
 
   found = NULL;
   make_cleanup (VEC_cleanup (breakpoint_p), &found);
-  for (i = 0; i < sals.nelts; i++)
+  for (const auto &sal : sals)
     {
       const char *sal_fullname;
 
@@ -11896,7 +11872,6 @@ clear_command (char *arg, int from_tty)
          0              0             line
          1              0             <can't happen> */
 
-      sal = sals.sals[i];
       sal_fullname = (sal.symtab == NULL
 		      ? NULL : symtab_to_fullname (sal.symtab));
 
@@ -12826,11 +12801,10 @@ base_breakpoint_create_breakpoints_sal (struct gdbarch *gdbarch,
   internal_error_pure_virtual_called ();
 }
 
-static void
+static std::vector<symtab_and_line>
 base_breakpoint_decode_location (struct breakpoint *b,
 				 const struct event_location *location,
-				 struct program_space *search_pspace,
-				 struct symtabs_and_lines *sals)
+				 struct program_space *search_pspace)
 {
   internal_error_pure_virtual_called ();
 }
@@ -13081,13 +13055,12 @@ bkpt_create_breakpoints_sal (struct gdbarch *gdbarch,
 				  enabled, internal, flags);
 }
 
-static void
+static std::vector<symtab_and_line>
 bkpt_decode_location (struct breakpoint *b,
 		      const struct event_location *location,
-		      struct program_space *search_pspace,
-		      struct symtabs_and_lines *sals)
+		      struct program_space *search_pspace)
 {
-  decode_location_default (b, location, search_pspace, sals);
+  return decode_location_default (b, location, search_pspace);
 }
 
 /* Virtual table for internal breakpoints.  */
@@ -13272,18 +13245,18 @@ bkpt_probe_create_sals_from_location (const struct event_location *location,
   lsal.sals = parse_probes (location, NULL, canonical);
   lsal.canonical
     = xstrdup (event_location_to_string (canonical->location.get ()));
-  VEC_safe_push (linespec_sals, canonical->sals, &lsal);
+  canonical->lsals.push_back (std::move (lsal));
 }
 
-static void
+static std::vector<symtab_and_line>
 bkpt_probe_decode_location (struct breakpoint *b,
 			    const struct event_location *location,
-			    struct program_space *search_pspace,
-			    struct symtabs_and_lines *sals)
+			    struct program_space *search_pspace)
 {
-  *sals = parse_probes (location, search_pspace, NULL);
-  if (!sals->sals)
+  std::vector<symtab_and_line> sals = parse_probes (location, search_pspace, NULL);
+  if (sals.empty ())
     error (_("probe not found"));
+  return sals;
 }
 
 /* The breakpoint_ops structure to be used in tracepoints.  */
@@ -13401,13 +13374,12 @@ tracepoint_create_breakpoints_sal (struct gdbarch *gdbarch,
 				  enabled, internal, flags);
 }
 
-static void
+static std::vector<symtab_and_line>
 tracepoint_decode_location (struct breakpoint *b,
 			    const struct event_location *location,
-			    struct program_space *search_pspace,
-			    struct symtabs_and_lines *sals)
+			    struct program_space *search_pspace)
 {
-  decode_location_default (b, location, search_pspace, sals);
+  return decode_location_default (b, location, search_pspace);
 }
 
 struct breakpoint_ops tracepoint_breakpoint_ops;
@@ -13425,14 +13397,13 @@ tracepoint_probe_create_sals_from_location
   bkpt_probe_create_sals_from_location (location, canonical, type_wanted);
 }
 
-static void
+static std::vector<symtab_and_line>
 tracepoint_probe_decode_location (struct breakpoint *b,
 				  const struct event_location *location,
-				  struct program_space *search_pspace,
-				  struct symtabs_and_lines *sals)
+				  struct program_space *search_pspace)
 {
   /* We use the same method for breakpoint on probes.  */
-  bkpt_probe_decode_location (b, location, search_pspace, sals);
+  return bkpt_probe_decode_location (b, location, search_pspace);
 }
 
 static struct breakpoint_ops tracepoint_probe_breakpoint_ops;
@@ -13533,7 +13504,7 @@ strace_marker_create_sals_from_location (const struct event_location *location,
 
   lsal.canonical
     = xstrdup (event_location_to_string (canonical->location.get ()));
-  VEC_safe_push (linespec_sals, canonical->sals, &lsal);
+  canonical->lsals.push_back (std::move (lsal));
 }
 
 static void
@@ -13549,9 +13520,7 @@ strace_marker_create_breakpoints_sal (struct gdbarch *gdbarch,
 				      int from_tty, int enabled,
 				      int internal, unsigned flags)
 {
-  int i;
-  struct linespec_sals *lsal = VEC_index (linespec_sals,
-					  canonical->sals, 0);
+  const linespec_sals &lsal = canonical->lsals[0];
 
   /* If the user is creating a static tracepoint by marker id
      (strace -m MARKER_ID), then store the sals index, so that
@@ -13560,19 +13529,13 @@ strace_marker_create_breakpoints_sal (struct gdbarch *gdbarch,
      expand multiple locations for each sal, given than SALS
      already should contain all sals for MARKER_ID.  */
 
-  for (i = 0; i < lsal->sals.nelts; ++i)
+  for (size_t i = 0; i < lsal.sals.size (); i++)
     {
-      struct symtabs_and_lines expanded;
-      struct tracepoint *tp;
-      event_location_up location;
-
-      expanded.nelts = 1;
-      expanded.sals = &lsal->sals.sals[i];
-
-      location = copy_event_location (canonical->location.get ());
+      event_location_up location
+	= copy_event_location (canonical->location.get ());
 
-      tp = new tracepoint ();
-      init_breakpoint_sal (tp, gdbarch, expanded,
+      tracepoint *tp = new tracepoint ();
+      init_breakpoint_sal (tp, gdbarch, lsal.sals[i],
 			   std::move (location), NULL,
 			   std::move (cond_string),
 			   std::move (extra_string),
@@ -13592,20 +13555,20 @@ strace_marker_create_breakpoints_sal (struct gdbarch *gdbarch,
     }
 }
 
-static void
+static std::vector<symtab_and_line>
 strace_marker_decode_location (struct breakpoint *b,
 			       const struct event_location *location,
-			       struct program_space *search_pspace,
-			       struct symtabs_and_lines *sals)
+			       struct program_space *search_pspace)
 {
   struct tracepoint *tp = (struct tracepoint *) b;
   const char *s = get_linespec_location (location);
 
-  *sals = decode_static_tracepoint_spec (&s);
-  if (sals->nelts > tp->static_trace_marker_id_idx)
+  std::vector<symtab_and_line> sals = decode_static_tracepoint_spec (&s);
+  if (sals.size () > tp->static_trace_marker_id_idx)
     {
-      sals->sals[0] = sals->sals[tp->static_trace_marker_id_idx];
-      sals->nelts = 1;
+      sals[0] = sals[tp->static_trace_marker_id_idx];
+      sals.resize (1);
+      return sals;
     }
   else
     error (_("marker %s not found"), tp->static_trace_marker_id);
@@ -14075,13 +14038,13 @@ hoist_existing_locations (struct breakpoint *b, struct program_space *pspace)
 void
 update_breakpoint_locations (struct breakpoint *b,
 			     struct program_space *filter_pspace,
-			     struct symtabs_and_lines sals,
-			     struct symtabs_and_lines sals_end)
+			     gdb::array_view<const symtab_and_line> sals,
+			     gdb::array_view<const symtab_and_line> sals_end)
 {
   int i;
   struct bp_location *existing_locations;
 
-  if (sals_end.nelts != 0 && (sals.nelts != 1 || sals_end.nelts != 1))
+  if (!sals_end.empty () && (sals.size () != 1 || sals_end.size () != 1))
     {
       /* Ranged breakpoints have only one start location and one end
 	 location.  */
@@ -14098,18 +14061,18 @@ update_breakpoint_locations (struct breakpoint *b,
      We'd like to retain the location, so that when the library is
      loaded again, we don't loose the enabled/disabled status of the
      individual locations.  */
-  if (all_locations_are_pending (b, filter_pspace) && sals.nelts == 0)
+  if (all_locations_are_pending (b, filter_pspace) && sals.empty ())
     return;
 
   existing_locations = hoist_existing_locations (b, filter_pspace);
 
-  for (i = 0; i < sals.nelts; ++i)
+  for (const auto &sal : sals)
     {
       struct bp_location *new_loc;
 
-      switch_to_program_space_and_thread (sals.sals[i].pspace);
+      switch_to_program_space_and_thread (sal.pspace);
 
-      new_loc = add_location_to_breakpoint (b, &(sals.sals[i]));
+      new_loc = add_location_to_breakpoint (b, &sal);
 
       /* Reparse conditions, they might contain references to the
 	 old symtab.  */
@@ -14120,8 +14083,8 @@ update_breakpoint_locations (struct breakpoint *b,
 	  s = b->cond_string;
 	  TRY
 	    {
-	      new_loc->cond = parse_exp_1 (&s, sals.sals[i].pc,
-					   block_for_pc (sals.sals[i].pc), 
+	      new_loc->cond = parse_exp_1 (&s, sal.pc,
+					   block_for_pc (sal.pc),
 					   0);
 	    }
 	  CATCH (e, RETURN_MASK_ERROR)
@@ -14134,11 +14097,11 @@ update_breakpoint_locations (struct breakpoint *b,
 	  END_CATCH
 	}
 
-      if (sals_end.nelts)
+      if (!sals_end.empty ())
 	{
-	  CORE_ADDR end = find_breakpoint_range_end (sals_end.sals[0]);
+	  CORE_ADDR end = find_breakpoint_range_end (sals_end[0]);
 
-	  new_loc->length = end - sals.sals[0].pc + 1;
+	  new_loc->length = end - sals[0].pc + 1;
 	}
     }
 
@@ -14188,18 +14151,19 @@ update_breakpoint_locations (struct breakpoint *b,
 /* Find the SaL locations corresponding to the given LOCATION.
    On return, FOUND will be 1 if any SaL was found, zero otherwise.  */
 
-static struct symtabs_and_lines
+static std::vector<symtab_and_line>
 location_to_sals (struct breakpoint *b, struct event_location *location,
 		  struct program_space *search_pspace, int *found)
 {
-  struct symtabs_and_lines sals = {0};
   struct gdb_exception exception = exception_none;
 
   gdb_assert (b->ops != NULL);
 
+  std::vector<symtab_and_line> sals;
+
   TRY
     {
-      b->ops->decode_location (b, location, search_pspace, &sals);
+      sals = b->ops->decode_location (b, location, search_pspace);
     }
   CATCH (e, RETURN_MASK_ERROR)
     {
@@ -14240,16 +14204,14 @@ location_to_sals (struct breakpoint *b, struct event_location *location,
 
   if (exception.reason == 0 || exception.error != NOT_FOUND_ERROR)
     {
-      int i;
-
-      for (i = 0; i < sals.nelts; ++i)
-	resolve_sal_pc (&sals.sals[i]);
+      for (auto &sal : sals)
+	resolve_sal_pc (&sal);
       if (b->condition_not_parsed && b->extra_string != NULL)
 	{
 	  char *cond_string, *extra_string;
 	  int thread, task;
 
-	  find_condition_and_thread (b->extra_string, sals.sals[0].pc,
+	  find_condition_and_thread (b->extra_string, sals[0].pc,
 				     &cond_string, &thread, &task,
 				     &extra_string);
 	  gdb_assert (b->cond_string == NULL);
@@ -14266,7 +14228,7 @@ location_to_sals (struct breakpoint *b, struct event_location *location,
 	}
 
       if (b->type == bp_static_tracepoint && !strace_marker_p (b))
-	sals.sals[0] = update_static_tracepoint (b, sals.sals[0]);
+	sals[0] = update_static_tracepoint (b, sals[0]);
 
       *found = 1;
     }
@@ -14283,28 +14245,22 @@ location_to_sals (struct breakpoint *b, struct event_location *location,
 static void
 breakpoint_re_set_default (struct breakpoint *b)
 {
-  int found;
-  struct symtabs_and_lines sals, sals_end;
-  struct symtabs_and_lines expanded = {0};
-  struct symtabs_and_lines expanded_end = {0};
   struct program_space *filter_pspace = current_program_space;
+  std::vector<symtab_and_line> expanded, expanded_end;
 
-  sals = location_to_sals (b, b->location.get (), filter_pspace, &found);
+  int found;
+  std::vector<symtab_and_line> sals = location_to_sals (b, b->location.get (),
+							filter_pspace, &found);
   if (found)
-    {
-      make_cleanup (xfree, sals.sals);
-      expanded = sals;
-    }
+    expanded = std::move (sals);
 
   if (b->location_range_end != NULL)
     {
-      sals_end = location_to_sals (b, b->location_range_end.get (),
-				   filter_pspace, &found);
+      std::vector<symtab_and_line> sals_end
+	= location_to_sals (b, b->location_range_end.get (),
+			    filter_pspace, &found);
       if (found)
-	{
-	  make_cleanup (xfree, sals_end.sals);
-	  expanded_end = sals_end;
-	}
+	expanded_end = std::move (sals_end);
     }
 
   update_breakpoint_locations (b, filter_pspace, expanded, expanded_end);
@@ -14349,11 +14305,10 @@ create_breakpoints_sal_default (struct gdbarch *gdbarch,
 /* Decode the line represented by S by calling decode_line_full.  This is the
    default function for the `decode_location' method of breakpoint_ops.  */
 
-static void
+static std::vector<symtab_and_line>
 decode_location_default (struct breakpoint *b,
 			 const struct event_location *location,
-			 struct program_space *search_pspace,
-			 struct symtabs_and_lines *sals)
+			 struct program_space *search_pspace)
 {
   struct linespec_result canonical;
 
@@ -14363,18 +14318,14 @@ decode_location_default (struct breakpoint *b,
 		    b->filter);
 
   /* We should get 0 or 1 resulting SALs.  */
-  gdb_assert (VEC_length (linespec_sals, canonical.sals) < 2);
+  gdb_assert (canonical.lsals.size () < 2);
 
-  if (VEC_length (linespec_sals, canonical.sals) > 0)
+  if (!canonical.lsals.empty ())
     {
-      struct linespec_sals *lsal;
-
-      lsal = VEC_index (linespec_sals, canonical.sals, 0);
-      *sals = lsal->sals;
-      /* Arrange it so the destructor does not free the
-	 contents.  */
-      lsal->sals.sals = NULL;
+      const linespec_sals &lsal = canonical.lsals[0];
+      return std::move (lsal.sals);
     }
+  return {};
 }
 
 /* Prepare the global context for a re-set of breakpoint B.  */
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index d955184..79b7dcb 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -28,6 +28,7 @@
 #include "probe.h"
 #include "location.h"
 #include <vector>
+#include "common/array-view.h"
 
 struct value;
 struct block;
@@ -611,15 +612,15 @@ struct breakpoint_ops
 				  int, int, int, unsigned);
 
   /* Given the location (second parameter), this method decodes it and
-     provides the SAL locations related to it.  For ordinary
+     returns the SAL locations related to it.  For ordinary
      breakpoints, it calls `decode_line_full'.  If SEARCH_PSPACE is
      not NULL, symbol search is restricted to just that program space.
 
      This function is called inside `location_to_sals'.  */
-  void (*decode_location) (struct breakpoint *b,
-			   const struct event_location *location,
-			   struct program_space *search_pspace,
-			   struct symtabs_and_lines *sals);
+  std::vector<symtab_and_line> (*decode_location)
+    (struct breakpoint *b,
+     const struct event_location *location,
+     struct program_space *search_pspace);
 
   /* Return true if this breakpoint explains a signal.  See
      bpstat_explains_signal.  */
@@ -1202,10 +1203,11 @@ extern void until_break_command (char *, int, int);
 
 /* Initialize a struct bp_location.  */
 
-extern void update_breakpoint_locations (struct breakpoint *b,
-					 struct program_space *filter_pspace,
-					 struct symtabs_and_lines sals,
-					 struct symtabs_and_lines sals_end);
+extern void update_breakpoint_locations
+  (struct breakpoint *b,
+   struct program_space *filter_pspace,
+   gdb::array_view<const symtab_and_line> sals,
+   gdb::array_view<const symtab_and_line> sals_end);
 
 extern void breakpoint_re_set (void);
 
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 3fa2499..3506254 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -90,9 +90,9 @@ static void list_command (char *, int);
 
 /* Prototypes for local utility functions */
 
-static void ambiguous_line_spec (struct symtabs_and_lines *);
+static void ambiguous_line_spec (gdb::array_view<const symtab_and_line> sals);
 
-static void filter_sals (struct symtabs_and_lines *);
+static void filter_sals (std::vector<symtab_and_line> &);
 
 
 /* Limit the call depth of user-defined commands */
@@ -786,7 +786,6 @@ shell_command (char *arg, int from_tty)
 static void
 edit_command (char *arg, int from_tty)
 {
-  struct symtabs_and_lines sals;
   struct symtab_and_line sal;
   struct symbol *sym;
   const char *editor;
@@ -816,24 +815,23 @@ edit_command (char *arg, int from_tty)
       arg1 = arg;
       event_location_up location = string_to_event_location (&arg1,
 							     current_language);
-      sals = decode_line_1 (location.get (), DECODE_LINE_LIST_MODE,
-			    NULL, NULL, 0);
+      std::vector<symtab_and_line> sals = decode_line_1 (location.get (),
+							 DECODE_LINE_LIST_MODE,
+							 NULL, NULL, 0);
 
-      filter_sals (&sals);
-      if (! sals.nelts)
+      filter_sals (sals);
+      if (sals.empty ())
 	{
 	  /*  C++  */
 	  return;
 	}
-      if (sals.nelts > 1)
+      if (sals.size () > 1)
 	{
-	  ambiguous_line_spec (&sals);
-	  xfree (sals.sals);
+	  ambiguous_line_spec (sals);
 	  return;
 	}
 
-      sal = sals.sals[0];
-      xfree (sals.sals);
+      sal = sals[0];
 
       if (*arg1)
         error (_("Junk at end of line specification."));
@@ -887,7 +885,6 @@ edit_command (char *arg, int from_tty)
 static void
 list_command (char *arg, int from_tty)
 {
-  struct symtabs_and_lines sals, sals_end;
   struct symtab_and_line sal = { 0 };
   struct symtab_and_line sal_end = { 0 };
   struct symtab_and_line cursal = { 0 };
@@ -962,24 +959,23 @@ list_command (char *arg, int from_tty)
     {
       event_location_up location = string_to_event_location (&arg1,
 							     current_language);
-      sals = decode_line_1 (location.get (), DECODE_LINE_LIST_MODE,
-			    NULL, NULL, 0);
+      std::vector<symtab_and_line> sals = decode_line_1 (location.get (),
+							 DECODE_LINE_LIST_MODE,
+							 NULL, NULL, 0);
 
-      filter_sals (&sals);
-      if (!sals.nelts)
+      filter_sals (sals);
+      if (sals.empty ())
 	{
 	  /*  C++  */
 	  return;
 	}
-      if (sals.nelts > 1)
+      if (sals.size () > 1)
 	{
-	  ambiguous_line_spec (&sals);
-	  xfree (sals.sals);
+	  ambiguous_line_spec (sals);
 	  return;
 	}
 
-      sal = sals.sals[0];
-      xfree (sals.sals);
+      sal = sals[0];
     }
 
   /* Record whether the BEG arg is all digits.  */
@@ -1001,24 +997,23 @@ list_command (char *arg, int from_tty)
 	{
 	  event_location_up location
 	    = string_to_event_location (&arg1, current_language);
-	  if (dummy_beg)
-	    sals_end = decode_line_1 (location.get (),
-				      DECODE_LINE_LIST_MODE, NULL, NULL, 0);
-	  else
-	    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)
+	  std::vector<symtab_and_line> sals_end
+	    = (dummy_beg
+	       ? decode_line_1 (location.get (), DECODE_LINE_LIST_MODE,
+				NULL, NULL, 0)
+	       : decode_line_1 (location.get (), DECODE_LINE_LIST_MODE,
+				NULL, sal.symtab, sal.line));
+
+	  filter_sals (sals_end);
+	  if (sals_end.empty ())
 	    return;
-	  if (sals_end.nelts > 1)
+	  if (sals_end.size () > 1)
 	    {
-	      ambiguous_line_spec (&sals_end);
-	      xfree (sals_end.sals);
+	      ambiguous_line_spec (sals_end);
 	      return;
 	    }
-	  sal_end = sals_end.sals[0];
-	  xfree (sals_end.sals);
+	  sal_end = sals_end[0];
 	}
     }
 
@@ -1501,29 +1496,26 @@ alias_command (char *args, int from_tty)
 
 /* Print a list of files and line numbers which a user may choose from
    in order to list a function which was specified ambiguously (as
-   with `list classname::overloadedfuncname', for example).  The
-   vector in SALS provides the filenames and line numbers.  */
+   with `list classname::overloadedfuncname', for example).  The SALS
+   vector provides the filenames and line numbers.  */
 
 static void
-ambiguous_line_spec (struct symtabs_and_lines *sals)
+ambiguous_line_spec (gdb::array_view<const symtab_and_line> sals)
 {
-  int i;
-
-  for (i = 0; i < sals->nelts; ++i)
+  for (const auto &sal : sals)
     printf_filtered (_("file: \"%s\", line number: %d\n"),
-		     symtab_to_filename_for_display (sals->sals[i].symtab),
-		     sals->sals[i].line);
+		     symtab_to_filename_for_display (sal.symtab),
+		     sal.line);
 }
 
-/* Sort function for filter_sals.  */
+/* Comparison function for filter_sals.  Returns a qsort-style
+   result.  */
 
 static int
-compare_symtabs (const void *a, const void *b)
+cmp_symtabs (const symtab_and_line &sala, const symtab_and_line &salb)
 {
-  const struct symtab_and_line *sala = (const struct symtab_and_line *) a;
-  const struct symtab_and_line *salb = (const struct symtab_and_line *) b;
-  const char *dira = SYMTAB_DIRNAME (sala->symtab);
-  const char *dirb = SYMTAB_DIRNAME (salb->symtab);
+  const char *dira = SYMTAB_DIRNAME (sala.symtab);
+  const char *dirb = SYMTAB_DIRNAME (salb.symtab);
   int r;
 
   if (dira == NULL)
@@ -1543,58 +1535,37 @@ compare_symtabs (const void *a, const void *b)
 	return r;
     }
 
-  r = filename_cmp (sala->symtab->filename, salb->symtab->filename);
+  r = filename_cmp (sala.symtab->filename, salb.symtab->filename);
   if (r)
     return r;
 
-  if (sala->line < salb->line)
+  if (sala.line < salb.line)
     return -1;
-  return sala->line == salb->line ? 0 : 1;
+  return sala.line == salb.line ? 0 : 1;
 }
 
 /* Remove any SALs that do not match the current program space, or
    which appear to be "file:line" duplicates.  */
 
 static void
-filter_sals (struct symtabs_and_lines *sals)
+filter_sals (std::vector<symtab_and_line> &sals)
 {
-  int i, out, prev;
-
-  out = 0;
-  for (i = 0; i < sals->nelts; ++i)
-    {
-      if (sals->sals[i].pspace == current_program_space
-	  && sals->sals[i].symtab != NULL)
-	{
-	  sals->sals[out] = sals->sals[i];
-	  ++out;
-	}
-    }
-  sals->nelts = out;
-
-  qsort (sals->sals, sals->nelts, sizeof (struct symtab_and_line),
-	 compare_symtabs);
-
-  out = 1;
-  prev = 0;
-  for (i = 1; i < sals->nelts; ++i)
-    {
-      if (compare_symtabs (&sals->sals[prev], &sals->sals[i]))
-	{
-	  /* Symtabs differ.  */
-	  sals->sals[out] = sals->sals[i];
-	  prev = out;
-	  ++out;
-	}
-    }
-
-  if (sals->nelts == 0)
-    {
-      xfree (sals->sals);
-      sals->sals = NULL;
-    }
-  else
-    sals->nelts = out;
+  /* Remove SALs that do not match.  */
+  auto from = std::remove_if (sals.begin (), sals.end (),
+			      [&] (const symtab_and_line &sal)
+    { return (sal.pspace != current_program_space || sal.symtab == NULL); });
+
+  /* Remove dups.  */
+  std::sort (sals.begin (), from,
+	     [] (const symtab_and_line &sala, const symtab_and_line &salb)
+   { return cmp_symtabs (sala, salb) < 0; });
+
+  from = std::unique (sals.begin (), from,
+		      [&] (const symtab_and_line &sala,
+			   const symtab_and_line &salb)
+    { return cmp_symtabs (sala, salb) == 0; });
+
+  sals.erase (from, sals.end ());
 }
 
 static void
diff --git a/gdb/elfread.c b/gdb/elfread.c
index a654661..ddff16b 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -953,8 +953,6 @@ elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b)
   struct value *func_func;
   struct value *value;
   CORE_ADDR resolved_address, resolved_pc;
-  struct symtab_and_line sal;
-  struct symtabs_and_lines sals, sals_end;
 
   gdb_assert (b->type == bp_gnu_ifunc_resolver_return);
 
@@ -997,13 +995,9 @@ elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b)
   elf_gnu_ifunc_record_cache (event_location_to_string (b->location.get ()),
 			      resolved_pc);
 
-  sal = find_pc_line (resolved_pc, 0);
-  sals.nelts = 1;
-  sals.sals = &sal;
-  sals_end.nelts = 0;
-
   b->type = bp_breakpoint;
-  update_breakpoint_locations (b, current_program_space, sals, sals_end);
+  update_breakpoint_locations (b, current_program_space,
+			       find_pc_line (resolved_pc, 0), {});
 }
 
 /* A helper function for elf_symfile_read that reads the minimal
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index c8a82db..c70a1d5 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1179,8 +1179,6 @@ jump_command (char *arg, int from_tty)
 {
   struct gdbarch *gdbarch = get_current_arch ();
   CORE_ADDR addr;
-  struct symtabs_and_lines sals;
-  struct symtab_and_line sal;
   struct symbol *fn;
   struct symbol *sfn;
   int async_exec;
@@ -1200,18 +1198,16 @@ jump_command (char *arg, int from_tty)
   if (!arg)
     error_no_arg (_("starting address"));
 
-  sals = decode_line_with_last_displayed (arg, DECODE_LINE_FUNFIRSTLINE);
-  if (sals.nelts != 1)
-    {
-      error (_("Unreasonable jump request"));
-    }
-
-  sal = sals.sals[0];
-  xfree (sals.sals);
+  std::vector<symtab_and_line> sals
+    = decode_line_with_last_displayed (arg, DECODE_LINE_FUNFIRSTLINE);
+  if (sals.size () != 1)
+    error (_("Unreasonable jump request"));
 
   /* Done with ARGS.  */
   do_cleanups (args_chain);
 
+  symtab_and_line &sal = sals[0];
+
   if (sal.symtab == 0 && sal.pc == 0)
     error (_("No source file has been specified."));
 
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 136cb65..5396eba 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -173,7 +173,7 @@ struct linespec_state
   /* The 'canonical' value passed to decode_line_full, or NULL.  */
   struct linespec_result *canonical;
 
-  /* Canonical strings that mirror the symtabs_and_lines result.  */
+  /* Canonical strings that mirror the std::vector<symtab_and_line> result.  */
   struct linespec_canonical_name *canonical_names;
 
   /* This is a set of address_entry objects which is used to prevent
@@ -341,9 +341,9 @@ static void initialize_defaults (struct symtab **default_symtab,
 
 CORE_ADDR linespec_expression_to_pc (const char **exp_ptr);
 
-static struct symtabs_and_lines decode_objc (struct linespec_state *self,
-					     linespec_p ls,
-					     const char *arg);
+static std::vector<symtab_and_line> decode_objc (struct linespec_state *self,
+						 linespec_p ls,
+						 const char *arg);
 
 static VEC (symtab_ptr) *symtabs_from_filename (const char *,
 						struct program_space *pspace);
@@ -379,20 +379,20 @@ static VEC (symtab_ptr) *
   collect_symtabs_from_filename (const char *file,
 				 struct program_space *pspace);
 
-static void decode_digits_ordinary (struct linespec_state *self,
-				    linespec_p ls,
-				    int line,
-				    struct symtabs_and_lines *sals,
-				    struct linetable_entry **best_entry);
+static std::vector<symtab_and_line> decode_digits_ordinary
+  (struct linespec_state *self,
+   linespec_p ls,
+   int line,
+   linetable_entry **best_entry);
 
-static void decode_digits_list_mode (struct linespec_state *self,
-				     linespec_p ls,
-				     struct symtabs_and_lines *values,
-				     struct symtab_and_line val);
+static std::vector<symtab_and_line> decode_digits_list_mode
+  (struct linespec_state *self,
+   linespec_p ls,
+   struct symtab_and_line val);
 
 static void minsym_found (struct linespec_state *self, struct objfile *objfile,
 			  struct minimal_symbol *msymbol,
-			  struct symtabs_and_lines *result);
+			  std::vector<symtab_and_line> *result);
 
 static int compare_symbols (const void *a, const void *b);
 
@@ -996,17 +996,6 @@ linespec_lexer_peek_token (linespec_parser *parser)
 
 /* Helper functions.  */
 
-/* Add SAL to SALS.  */
-
-static void
-add_sal_to_sals_basic (struct symtabs_and_lines *sals,
-		       struct symtab_and_line *sal)
-{
-  ++sals->nelts;
-  sals->sals = XRESIZEVEC (struct symtab_and_line, sals->sals, sals->nelts);
-  sals->sals[sals->nelts - 1] = *sal;
-}
-
 /* Add SAL to SALS, and also update SELF->CANONICAL_NAMES to reflect
    the new sal, if needed.  If not NULL, SYMNAME is the name of the
    symbol to use when constructing the new canonical name.
@@ -1016,19 +1005,20 @@ add_sal_to_sals_basic (struct symtabs_and_lines *sals,
 
 static void
 add_sal_to_sals (struct linespec_state *self,
-		 struct symtabs_and_lines *sals,
+		 std::vector<symtab_and_line> *sals,
 		 struct symtab_and_line *sal,
 		 const char *symname, int literal_canonical)
 {
-  add_sal_to_sals_basic (sals, sal);
+  sals->push_back (*sal);
 
   if (self->canonical)
     {
       struct linespec_canonical_name *canonical;
 
       self->canonical_names = XRESIZEVEC (struct linespec_canonical_name,
-					  self->canonical_names, sals->nelts);
-      canonical = &self->canonical_names[sals->nelts - 1];
+					  self->canonical_names,
+					  sals->size ());
+      canonical = &self->canonical_names[sals->size () - 1];
       if (!literal_canonical && sal->symtab)
 	{
 	  symtab_to_fullname (sal->symtab);
@@ -1405,7 +1395,7 @@ canonical_to_fullform (const struct linespec_canonical_name *canonical)
 
 static void
 filter_results (struct linespec_state *self,
-		struct symtabs_and_lines *result,
+		std::vector<symtab_and_line> *result,
 		VEC (const_char_ptr) *filters)
 {
   int i;
@@ -1413,12 +1403,9 @@ filter_results (struct linespec_state *self,
 
   for (i = 0; VEC_iterate (const_char_ptr, filters, i, name); ++i)
     {
-      struct linespec_sals lsal;
-      int j;
-
-      memset (&lsal, 0, sizeof (lsal));
+      linespec_sals lsal;
 
-      for (j = 0; j < result->nelts; ++j)
+      for (size_t j = 0; j < result->size (); ++j)
 	{
 	  const struct linespec_canonical_name *canonical;
 	  char *fullform;
@@ -1429,15 +1416,15 @@ filter_results (struct linespec_state *self,
 	  cleanup = make_cleanup (xfree, fullform);
 
 	  if (strcmp (name, fullform) == 0)
-	    add_sal_to_sals_basic (&lsal.sals, &result->sals[j]);
+	    lsal.sals.push_back ((*result)[j]);
 
 	  do_cleanups (cleanup);
 	}
 
-      if (lsal.sals.nelts > 0)
+      if (!lsal.sals.empty ())
 	{
 	  lsal.canonical = xstrdup (name);
-	  VEC_safe_push (linespec_sals, self->canonical->sals, &lsal);
+	  self->canonical->lsals.push_back (std::move (lsal));
 	}
     }
 
@@ -1448,13 +1435,13 @@ filter_results (struct linespec_state *self,
 
 static void
 convert_results_to_lsals (struct linespec_state *self,
-			  struct symtabs_and_lines *result)
+			  std::vector<symtab_and_line> *result)
 {
   struct linespec_sals lsal;
 
   lsal.canonical = NULL;
-  lsal.sals = *result;
-  VEC_safe_push (linespec_sals, self->canonical->sals, &lsal);
+  lsal.sals = std::move (*result);
+  self->canonical->lsals.push_back (std::move (lsal));
 }
 
 /* A structure that contains two string representations of a struct
@@ -1502,7 +1489,7 @@ decode_line_2_compare_items (const void *ap, const void *bp)
 
 static void
 decode_line_2 (struct linespec_state *self,
-	       struct symtabs_and_lines *result,
+	       std::vector<symtab_and_line> *result,
 	       const char *select_mode)
 {
   char *args;
@@ -1515,12 +1502,12 @@ decode_line_2 (struct linespec_state *self,
 
   gdb_assert (select_mode != multiple_symbols_all);
   gdb_assert (self->canonical != NULL);
-  gdb_assert (result->nelts >= 1);
+  gdb_assert (!result->empty ());
 
   old_chain = make_cleanup (VEC_cleanup (const_char_ptr), &filters);
 
   /* Prepare ITEMS array.  */
-  items_count = result->nelts;
+  items_count = result->size ();
   items = XNEWVEC (struct decode_line_2_item, items_count);
   make_cleanup (xfree, items);
   for (i = 0; i < items_count; ++i)
@@ -2135,17 +2122,14 @@ canonicalize_linespec (struct linespec_state *state, const linespec_p ls)
 
 /* Given a line offset in LS, construct the relevant SALs.  */
 
-static struct symtabs_and_lines
+static std::vector<symtab_and_line>
 create_sals_line_offset (struct linespec_state *self,
 			 linespec_p ls)
 {
-  struct symtabs_and_lines values;
   struct symtab_and_line val;
   int use_default = 0;
 
   init_sal (&val);
-  values.sals = NULL;
-  values.nelts = 0;
 
   /* This is where we need to make sure we have good defaults.
      We must guarantee that this section of code is never executed
@@ -2194,27 +2178,22 @@ create_sals_line_offset (struct linespec_state *self,
       break;			/* No need to adjust val.line.  */
     }
 
+  std::vector<symtab_and_line> values;
   if (self->list_mode)
-    decode_digits_list_mode (self, ls, &values, val);
+    values = decode_digits_list_mode (self, ls, val);
   else
     {
       struct linetable_entry *best_entry = NULL;
       int *filter;
       const struct block **blocks;
-      struct cleanup *cleanup;
-      struct symtabs_and_lines intermediate_results;
       int i, j;
 
-      intermediate_results.sals = NULL;
-      intermediate_results.nelts = 0;
-
-      decode_digits_ordinary (self, ls, val.line, &intermediate_results,
-			      &best_entry);
-      if (intermediate_results.nelts == 0 && best_entry != NULL)
-	decode_digits_ordinary (self, ls, best_entry->line,
-				&intermediate_results, &best_entry);
-
-      cleanup = make_cleanup (xfree, intermediate_results.sals);
+      std::vector<symtab_and_line> intermediate_results
+	= decode_digits_ordinary (self, ls, val.line, &best_entry);
+      if (intermediate_results.empty () && best_entry != NULL)
+	intermediate_results = decode_digits_ordinary (self, ls,
+						       best_entry->line,
+						       &best_entry);
 
       /* For optimized code, the compiler can scatter one source line
 	 across disjoint ranges of PC values, even when no duplicate
@@ -2226,24 +2205,24 @@ create_sals_line_offset (struct linespec_state *self,
 	 above, we see if there are other PCs that are in the same
 	 block.  If yes, the other PCs are filtered out.  */
 
-      filter = XNEWVEC (int, intermediate_results.nelts);
-      make_cleanup (xfree, filter);
-      blocks = XNEWVEC (const struct block *, intermediate_results.nelts);
+      filter = XNEWVEC (int, intermediate_results.size ());
+      struct cleanup *cleanup = make_cleanup (xfree, filter);
+      blocks = XNEWVEC (const struct block *, intermediate_results.size ());
       make_cleanup (xfree, blocks);
 
-      for (i = 0; i < intermediate_results.nelts; ++i)
+      for (i = 0; i < intermediate_results.size (); ++i)
 	{
-	  set_current_program_space (intermediate_results.sals[i].pspace);
+	  set_current_program_space (intermediate_results[i].pspace);
 
 	  filter[i] = 1;
-	  blocks[i] = block_for_pc_sect (intermediate_results.sals[i].pc,
-					 intermediate_results.sals[i].section);
+	  blocks[i] = block_for_pc_sect (intermediate_results[i].pc,
+					 intermediate_results[i].section);
 	}
 
-      for (i = 0; i < intermediate_results.nelts; ++i)
+      for (i = 0; i < intermediate_results.size (); ++i)
 	{
 	  if (blocks[i] != NULL)
-	    for (j = i + 1; j < intermediate_results.nelts; ++j)
+	    for (j = i + 1; j < intermediate_results.size (); ++j)
 	      {
 		if (blocks[j] == blocks[i])
 		  {
@@ -2253,7 +2232,7 @@ create_sals_line_offset (struct linespec_state *self,
 	      }
 	}
 
-      for (i = 0; i < intermediate_results.nelts; ++i)
+      for (i = 0; i < intermediate_results.size (); ++i)
 	if (filter[i])
 	  {
 	    struct symbol *sym = (blocks[i]
@@ -2261,18 +2240,18 @@ create_sals_line_offset (struct linespec_state *self,
 				  : NULL);
 
 	    if (self->funfirstline)
-	      skip_prologue_sal (&intermediate_results.sals[i]);
+	      skip_prologue_sal (&intermediate_results[i]);
 	    /* Make sure the line matches the request, not what was
 	       found.  */
-	    intermediate_results.sals[i].line = val.line;
-	    add_sal_to_sals (self, &values, &intermediate_results.sals[i],
+	    intermediate_results[i].line = val.line;
+	    add_sal_to_sals (self, &values, &intermediate_results[i],
 			     sym ? SYMBOL_NATURAL_NAME (sym) : NULL, 0);
 	  }
 
       do_cleanups (cleanup);
     }
 
-  if (values.nelts == 0)
+  if (values.empty ())
     {
       if (ls->explicit_loc.source_filename)
 	throw_error (NOT_FOUND_ERROR, _("No line %d in file \"%s\"."),
@@ -2287,17 +2266,16 @@ create_sals_line_offset (struct linespec_state *self,
 
 /* Convert the given ADDRESS into SaLs.  */
 
-static struct symtabs_and_lines
+static std::vector<symtab_and_line>
 convert_address_location_to_sals (struct linespec_state *self,
 				  CORE_ADDR address)
 {
-  struct symtab_and_line sal;
-  struct symtabs_and_lines sals = {NULL, 0};
-
-  sal = find_pc_line (address, 0);
+  symtab_and_line sal = find_pc_line (address, 0);
   sal.pc = address;
   sal.section = find_pc_overlay (address);
   sal.explicit_pc = 1;
+
+  std::vector<symtab_and_line> sals;
   add_sal_to_sals (self, &sals, &sal, core_addr_to_string (address), 1);
 
   return sals;
@@ -2305,10 +2283,10 @@ convert_address_location_to_sals (struct linespec_state *self,
 
 /* Create and return SALs from the linespec LS.  */
 
-static struct symtabs_and_lines
+static std::vector<symtab_and_line>
 convert_linespec_to_sals (struct linespec_state *state, linespec_p ls)
 {
-  struct symtabs_and_lines sals = {NULL, 0};
+  std::vector<symtab_and_line> sals;
 
   if (ls->labels.label_symbols != NULL)
     {
@@ -2398,7 +2376,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec_p ls)
 
   canonicalize_linespec (state, ls);
 
-  if (sals.nelts > 0 && state->canonical != NULL)
+  if (!sals.empty () && state->canonical != NULL)
     state->canonical->pre_expanded = 1;
 
   return sals;
@@ -2474,7 +2452,7 @@ convert_explicit_location_to_linespec (struct linespec_state *self,
 
 /* Convert the explicit location EXPLICIT_LOC into SaLs.  */
 
-static struct symtabs_and_lines
+static std::vector<symtab_and_line>
 convert_explicit_location_to_sals (struct linespec_state *self,
 				   linespec_p result,
 				   const struct explicit_location *explicit_loc)
@@ -2537,17 +2515,13 @@ convert_explicit_location_to_sals (struct linespec_state *self,
 
 /* Parse the linespec in ARG.  */
 
-static struct symtabs_and_lines
+static std::vector<symtab_and_line>
 parse_linespec (linespec_parser *parser, const char *arg)
 {
   linespec_token token;
-  struct symtabs_and_lines values;
   struct gdb_exception file_exception = exception_none;
   struct cleanup *cleanup;
 
-  values.nelts = 0;
-  values.sals = NULL;
-
   /* A special case to start.  It has become quite popular for
      IDEs to work around bugs in the previous parser by quoting
      the entire linespec, so we attempt to deal with this nicely.  */
@@ -2580,8 +2554,9 @@ parse_linespec (linespec_parser *parser, const char *arg)
   /* Objective-C shortcut.  */
   if (parser->completion_tracker == NULL)
     {
-      values = decode_objc (PARSER_STATE (parser), PARSER_RESULT (parser), arg);
-      if (values.sals != NULL)
+      std::vector<symtab_and_line> values
+	= decode_objc (PARSER_STATE (parser), PARSER_RESULT (parser), arg);
+      if (!values.empty ())
 	return values;
     }
   else
@@ -2735,10 +2710,10 @@ parse_linespec (linespec_parser *parser, const char *arg)
 
   /* Convert the data in PARSER_RESULT to SALs.  */
   if (parser->completion_tracker == NULL)
-    values = convert_linespec_to_sals (PARSER_STATE (parser),
-				       PARSER_RESULT (parser));
+    return convert_linespec_to_sals (PARSER_STATE (parser),
+				     PARSER_RESULT (parser));
 
-  return values;
+  return {};
 }
 
 
@@ -3194,13 +3169,13 @@ linespec_complete (completion_tracker &tracker, const char *text)
 }
 
 /* A helper function for decode_line_full and decode_line_1 to
-   turn LOCATION into symtabs_and_lines.  */
+   turn LOCATION into std::vector<symtab_and_line>.  */
 
-static struct symtabs_and_lines
+static std::vector<symtab_and_line>
 event_location_to_sals (linespec_parser *parser,
 			const struct event_location *location)
 {
-  struct symtabs_and_lines result = {NULL, 0};
+  std::vector<symtab_and_line> result;
 
   switch (event_location_type (location))
     {
@@ -3276,7 +3251,6 @@ decode_line_full (const struct event_location *location, int flags,
 		  const char *select_mode,
 		  const char *filter)
 {
-  struct symtabs_and_lines result;
   struct cleanup *cleanups;
   VEC (const_char_ptr) *filters = NULL;
   linespec_parser parser;
@@ -3298,19 +3272,20 @@ decode_line_full (const struct event_location *location, int flags,
 
   scoped_restore_current_program_space restore_pspace;
 
-  result = event_location_to_sals (&parser, location);
+  std::vector<symtab_and_line> result = event_location_to_sals (&parser,
+								location);
   state = PARSER_STATE (&parser);
 
-  gdb_assert (result.nelts == 1 || canonical->pre_expanded);
+  gdb_assert (result.size () == 1 || canonical->pre_expanded);
   canonical->pre_expanded = 1;
 
   /* Arrange for allocated canonical names to be freed.  */
-  if (result.nelts > 0)
+  if (!result.empty ())
     {
       int i;
 
       make_cleanup (xfree, state->canonical_names);
-      for (i = 0; i < result.nelts; ++i)
+      for (i = 0; i < result.size (); ++i)
 	{
 	  gdb_assert (state->canonical_names[i].suffix != NULL);
 	  make_cleanup (xfree, state->canonical_names[i].suffix);
@@ -3344,13 +3319,12 @@ decode_line_full (const struct event_location *location, int flags,
 
 /* See linespec.h.  */
 
-struct symtabs_and_lines
+std::vector<symtab_and_line>
 decode_line_1 (const struct event_location *location, int flags,
 	       struct program_space *search_pspace,
 	       struct symtab *default_symtab,
 	       int default_line)
 {
-  struct symtabs_and_lines result;
   linespec_parser parser;
   struct cleanup *cleanups;
 
@@ -3361,7 +3335,8 @@ decode_line_1 (const struct event_location *location, int flags,
 
   scoped_restore_current_program_space restore_pspace;
 
-  result = event_location_to_sals (&parser, location);
+  std::vector<symtab_and_line> result = event_location_to_sals (&parser,
+								location);
 
   do_cleanups (cleanups);
   return result;
@@ -3369,23 +3344,20 @@ decode_line_1 (const struct event_location *location, int flags,
 
 /* See linespec.h.  */
 
-struct symtabs_and_lines
+std::vector<symtab_and_line>
 decode_line_with_current_source (char *string, int flags)
 {
-  struct symtabs_and_lines sals;
-  struct symtab_and_line cursal;
-
   if (string == 0)
     error (_("Empty line specification."));
 
   /* We use whatever is set as the current source line.  We do not try
      and get a default source symtab+line or it will recursively call us!  */
-  cursal = get_current_source_symtab_and_line ();
+  symtab_and_line cursal = get_current_source_symtab_and_line ();
 
   event_location_up location = string_to_event_location (&string,
 							 current_language);
-  sals = decode_line_1 (location.get (), flags, NULL,
-			cursal.symtab, cursal.line);
+  std::vector<symtab_and_line> sals
+    = decode_line_1 (location.get (), flags, NULL, cursal.symtab, cursal.line);
 
   if (*string)
     error (_("Junk at end of line specification: %s"), string);
@@ -3395,23 +3367,21 @@ decode_line_with_current_source (char *string, int flags)
 
 /* See linespec.h.  */
 
-struct symtabs_and_lines
+std::vector<symtab_and_line>
 decode_line_with_last_displayed (char *string, int flags)
 {
-  struct symtabs_and_lines sals;
-
   if (string == 0)
     error (_("Empty line specification."));
 
   event_location_up location = string_to_event_location (&string,
 							 current_language);
-  if (last_displayed_sal_is_valid ())
-    sals = decode_line_1 (location.get (), flags, NULL,
-			  get_last_displayed_symtab (),
-			  get_last_displayed_line ());
-  else
-    sals = decode_line_1 (location.get (), flags, NULL,
-			  (struct symtab *) NULL, 0);
+  std::vector<symtab_and_line> sals
+    = (last_displayed_sal_is_valid ()
+       ? decode_line_1 (location.get (), flags, NULL,
+			get_last_displayed_symtab (),
+			get_last_displayed_line ())
+       : decode_line_1 (location.get (), flags, NULL,
+			(struct symtab *) NULL, 0));
 
   if (*string)
     error (_("Junk at end of line specification: %s"), string);
@@ -3467,12 +3437,11 @@ linespec_expression_to_pc (const char **exp_ptr)
    than one method that could represent the selector, then use some of
    the existing C++ code to let the user choose one.  */
 
-static struct symtabs_and_lines
+static std::vector<symtab_and_line>
 decode_objc (struct linespec_state *self, linespec_p ls, const char *arg)
 {
   struct collect_info info;
   VEC (const_char_ptr) *symbol_names = NULL;
-  struct symtabs_and_lines values;
   const char *new_argptr;
   struct cleanup *cleanup = make_cleanup (VEC_cleanup (const_char_ptr),
 					  &symbol_names);
@@ -3483,18 +3452,17 @@ decode_objc (struct linespec_state *self, linespec_p ls, const char *arg)
   make_cleanup (VEC_cleanup (symtab_ptr), &info.file_symtabs);
   info.result.symbols = NULL;
   info.result.minimal_symbols = NULL;
-  values.nelts = 0;
-  values.sals = NULL;
 
   new_argptr = find_imps (arg, &symbol_names);
   if (VEC_empty (const_char_ptr, symbol_names))
     {
       do_cleanups (cleanup);
-      return values;
+      return {};
     }
 
   add_all_symbol_names_from_pspace (&info, NULL, symbol_names);
 
+  std::vector<symtab_and_line> values;
   if (!VEC_empty (symbolp, info.result.symbols)
       || !VEC_empty (bound_minimal_symbol_d, info.result.minimal_symbols))
     {
@@ -4208,10 +4176,9 @@ find_label_symbols (struct linespec_state *self,
 
 /* A helper for create_sals_line_offset that handles the 'list_mode' case.  */
 
-static void
+static std::vector<symtab_and_line>
 decode_digits_list_mode (struct linespec_state *self,
 			 linespec_p ls,
-			 struct symtabs_and_lines *values,
 			 struct symtab_and_line val)
 {
   int ix;
@@ -4219,6 +4186,8 @@ decode_digits_list_mode (struct linespec_state *self,
 
   gdb_assert (self->list_mode);
 
+  std::vector<symtab_and_line> values;
+
   for (ix = 0; VEC_iterate (symtab_ptr, ls->file_symtabs, ix, elt);
        ++ix)
     {
@@ -4235,23 +4204,25 @@ decode_digits_list_mode (struct linespec_state *self,
       val.pc = 0;
       val.explicit_line = 1;
 
-      add_sal_to_sals (self, values, &val, NULL, 0);
+      add_sal_to_sals (self, &values, &val, NULL, 0);
     }
+
+  return values;
 }
 
 /* A helper for create_sals_line_offset that iterates over the symtabs,
    adding lines to the VEC.  */
 
-static void
+static std::vector<symtab_and_line>
 decode_digits_ordinary (struct linespec_state *self,
 			linespec_p ls,
 			int line,
-			struct symtabs_and_lines *sals,
 			struct linetable_entry **best_entry)
 {
   int ix;
   struct symtab *elt;
 
+  std::vector<symtab_and_line> sals;
   for (ix = 0; VEC_iterate (symtab_ptr, ls->file_symtabs, ix, elt); ++ix)
     {
       std::vector<CORE_ADDR> pcs;
@@ -4271,9 +4242,11 @@ decode_digits_ordinary (struct linespec_state *self,
 	  sal.symtab = elt;
 	  sal.line = line;
 	  sal.pc = pc;
-	  add_sal_to_sals_basic (sals, &sal);
+	  sals.push_back (std::move (sal));
 	}
     }
+
+  return sals;
 }
 
 
@@ -4343,7 +4316,7 @@ linespec_parse_variable (struct linespec_state *self, const char *variable)
 static void
 minsym_found (struct linespec_state *self, struct objfile *objfile,
 	      struct minimal_symbol *msymbol,
-	      struct symtabs_and_lines *result)
+	      std::vector<symtab_and_line> *result)
 {
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   CORE_ADDR pc;
@@ -4674,15 +4647,8 @@ symbol_to_sal (struct symtab_and_line *result,
 
 linespec_result::~linespec_result ()
 {
-  int i;
-  struct linespec_sals *lsal;
-
-  for (i = 0; VEC_iterate (linespec_sals, sals, i, lsal); ++i)
-    {
-      xfree (lsal->canonical);
-      xfree (lsal->sals.sals);
-    }
-  VEC_free (linespec_sals, sals);
+  for (linespec_sals &lsal : lsals)
+    xfree (lsal.canonical);
 }
 
 /* Return the quote characters permitted by the linespec parser.  */
diff --git a/gdb/linespec.h b/gdb/linespec.h
index 27d237a..ce74fe6 100644
--- a/gdb/linespec.h
+++ b/gdb/linespec.h
@@ -46,53 +46,43 @@ struct linespec_sals
      destructor.  */
   char *canonical;
 
-  /* Sals.  The 'sals' field is destroyed by the linespec_result
-     destructor.  */
-  struct symtabs_and_lines sals;
+  /* Sals.  */
+  std::vector<symtab_and_line> sals;
 };
 
-typedef struct linespec_sals linespec_sals;
-DEF_VEC_O (linespec_sals);
-
 /* An instance of this may be filled in by decode_line_1.  The caller
    must make copies of any data that it needs to keep.  */
 
 struct linespec_result
 {
-  linespec_result ()
-    : special_display (0),
-      pre_expanded (0),
-      sals (NULL)
-  {
-  }
-
+  linespec_result () = default;
   ~linespec_result ();
 
   linespec_result (const linespec_result &) = delete;
   linespec_result &operator= (const linespec_result &) = delete;
 
-  /* If non-zero, the linespec should be displayed to the user.  This
+  /* If true, the linespec should be displayed to the user.  This
      is used by "unusual" linespecs where the ordinary `info break'
      display mechanism would do the wrong thing.  */
-  int special_display;
+  bool special_display = false;
 
-  /* If non-zero, the linespec result should be considered to be a
+  /* If true, the linespec result should be considered to be a
      "pre-expanded" multi-location linespec.  A pre-expanded linespec
      holds all matching locations in a single linespec_sals
      object.  */
-  int pre_expanded;
+  bool pre_expanded = false;
 
   /* If PRE_EXPANDED is non-zero, this is set to the location entered
      by the user.  */
   event_location_up location;
 
   /* The sals.  The vector will be freed by the destructor.  */
-  VEC (linespec_sals) *sals;
+  std::vector<linespec_sals> lsals;
 };
 
 /* Decode a linespec using the provided default symtab and line.  */
 
-extern struct symtabs_and_lines
+extern std::vector<symtab_and_line>
 	decode_line_1 (const struct event_location *location, int flags,
 		       struct program_space *search_pspace,
 		       struct symtab *default_symtab, int default_line);
@@ -147,12 +137,12 @@ extern void decode_line_full (const struct event_location *location, int flags,
    source symtab and line as defaults.
    This is for commands like "list" and "breakpoint".  */
 
-extern struct symtabs_and_lines decode_line_with_current_source (char *, int);
+extern std::vector<symtab_and_line> decode_line_with_current_source (char *, int);
 
 /* Given a string, return the line specified by it, using the last displayed
    codepoint's values as defaults, or nothing if they aren't valid.  */
 
-extern struct symtabs_and_lines decode_line_with_last_displayed (char *, int);
+extern std::vector<symtab_and_line> decode_line_with_last_displayed (char *, int);
 
 /* Does P represent one of the keywords?  If so, return
    the keyword.  If not, return NULL.  */
diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c
index c390d63..cb6c38c 100644
--- a/gdb/macrocmd.c
+++ b/gdb/macrocmd.c
@@ -279,11 +279,11 @@ info_macros_command (char *args, int from_tty)
     ms = default_macro_scope ();
   else
     {
-      struct symtabs_and_lines sals =
-	decode_line_with_current_source (args, 0);
+      std::vector<symtab_and_line> sals
+	= decode_line_with_current_source (args, 0);
 
-      if (sals.nelts)
-        ms = sal_macro_scope (sals.sals[0]);
+      if (!sals.empty ())
+	ms = sal_macro_scope (sals[0]);
     }
 
   if (! ms || ! ms->file || ! ms->file->table)
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 0bf587f..c485544 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2526,29 +2526,22 @@ mi_cmd_trace_find (const char *command, char **argv, int argc)
     }
   else if (strcmp (mode, "line") == 0)
     {
-      struct symtabs_and_lines sals;
-      struct symtab_and_line sal;
-      static CORE_ADDR start_pc, end_pc;
-      struct cleanup *back_to;
-
       if (argc != 2)
 	error (_("Line is required"));
 
-      sals = decode_line_with_current_source (argv[1],
-					      DECODE_LINE_FUNFIRSTLINE);
-      back_to = make_cleanup (xfree, sals.sals);
-
-      sal = sals.sals[0];
+      std::vector<symtab_and_line> sals
+	= decode_line_with_current_source (argv[1],
+					   DECODE_LINE_FUNFIRSTLINE);
+      const symtab_and_line &sal = sals[0];
 
       if (sal.symtab == 0)
 	error (_("Could not find the specified line"));
 
+      CORE_ADDR start_pc, end_pc;
       if (sal.line > 0 && find_line_pc_range (sal, &start_pc, &end_pc))
 	tfind_1 (tfind_range, 0, start_pc, end_pc - 1, 0);
       else
 	error (_("Could not find the specified line"));
-
-      do_cleanups (back_to);
     }
   else
     error (_("Invalid mode '%s'"), mode);
diff --git a/gdb/probe.c b/gdb/probe.c
index cb2dcdb..5b5e6f0 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -52,7 +52,7 @@ parse_probes_in_pspace (const struct probe_ops *probe_ops,
 			const char *objfile_namestr,
 			const char *provider,
 			const char *name,
-			struct symtabs_and_lines *result)
+			std::vector<symtab_and_line> *result)
 {
   struct objfile *objfile;
 
@@ -75,8 +75,6 @@ parse_probes_in_pspace (const struct probe_ops *probe_ops,
 
       for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
 	{
-	  struct symtab_and_line *sal;
-
 	  if (probe_ops != &probe_ops_any && probe->pops != probe_ops)
 	    continue;
 
@@ -86,26 +84,25 @@ parse_probes_in_pspace (const struct probe_ops *probe_ops,
 	  if (strcmp (probe->name, name) != 0)
 	    continue;
 
-	  ++result->nelts;
-	  result->sals = XRESIZEVEC (struct symtab_and_line, result->sals,
-				     result->nelts);
-	  sal = &result->sals[result->nelts - 1];
+	  symtab_and_line sal;
+
+	  init_sal (&sal);
 
-	  init_sal (sal);
+	  sal.pc = get_probe_address (probe, objfile);
+	  sal.explicit_pc = 1;
+	  sal.section = find_pc_overlay (sal.pc);
+	  sal.pspace = search_pspace;
+	  sal.probe = probe;
+	  sal.objfile = objfile;
 
-	  sal->pc = get_probe_address (probe, objfile);
-	  sal->explicit_pc = 1;
-	  sal->section = find_pc_overlay (sal->pc);
-	  sal->pspace = search_pspace;
-	  sal->probe = probe;
-	  sal->objfile = objfile;
+	  result->push_back (std::move (sal));
 	}
     }
 }
 
 /* See definition in probe.h.  */
 
-struct symtabs_and_lines
+std::vector<symtab_and_line>
 parse_probes (const struct event_location *location,
 	      struct program_space *search_pspace,
 	      struct linespec_result *canonical)
@@ -113,13 +110,9 @@ parse_probes (const struct event_location *location,
   char *arg_end, *arg;
   char *objfile_namestr = NULL, *provider = NULL, *name, *p;
   struct cleanup *cleanup;
-  struct symtabs_and_lines result;
   const struct probe_ops *probe_ops;
   const char *arg_start, *cs;
 
-  result.sals = NULL;
-  result.nelts = 0;
-
   gdb_assert (event_location_type (location) == PROBE_LOCATION);
   arg_start = get_probe_location (location);
 
@@ -175,6 +168,7 @@ parse_probes (const struct event_location *location,
   if (objfile_namestr && *objfile_namestr == '\0')
     error (_("invalid objfile name"));
 
+  std::vector<symtab_and_line> result;
   if (search_pspace != NULL)
     {
       parse_probes_in_pspace (probe_ops, search_pspace, objfile_namestr,
@@ -189,7 +183,7 @@ parse_probes (const struct event_location *location,
 				provider, name, &result);
     }
 
-  if (result.nelts == 0)
+  if (result.empty ())
     {
       throw_error (NOT_FOUND_ERROR,
 		   _("No probe matching objfile=`%s', provider=`%s', name=`%s'"),
diff --git a/gdb/probe.h b/gdb/probe.h
index a6c10e2..db7f1d1 100644
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -224,12 +224,14 @@ struct bound_probe
     struct objfile *objfile;
   };
 
-/* A helper for linespec that decodes a probe specification.  It returns a
-   symtabs_and_lines object and updates LOC or throws an error.  */
-
-extern struct symtabs_and_lines parse_probes (const struct event_location *loc,
-					      struct program_space *pspace,
-					      struct linespec_result *canon);
+/* A helper for linespec that decodes a probe specification.  It
+   returns a std::vector<symtab_and_line> object and updates LOC or
+   throws an error.  */
+
+extern std::vector<symtab_and_line> parse_probes
+  (const struct event_location *loc,
+   struct program_space *pspace,
+   struct linespec_result *canon);
 
 /* Helper function to register the proper probe_ops to a newly created probe.
    This function is mainly called from `sym_get_probes'.  */
diff --git a/gdb/python/python.c b/gdb/python/python.c
index c53e10f..f40fe89 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -647,10 +647,6 @@ gdbpy_solib_name (PyObject *self, PyObject *args)
 static PyObject *
 gdbpy_decode_line (PyObject *self, PyObject *args)
 {
-  struct gdb_exception except = exception_none;
-  struct symtabs_and_lines sals = { NULL, 0 }; /* Initialize to
-						  appease gcc.  */
-  struct symtab_and_line sal;
   char *arg = NULL;
   gdbpy_ref<> result;
   gdbpy_ref<> unparsed;
@@ -659,54 +655,43 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
   if (! PyArg_ParseTuple (args, "|s", &arg))
     return NULL;
 
-  sals.sals = NULL;
-
   if (arg != NULL)
     location = string_to_event_location_basic (&arg, python_language);
 
+  std::vector<symtab_and_line> decoded_sals;
+  symtab_and_line def_sal;
+  gdb::array_view<symtab_and_line> sals;
   TRY
     {
       if (location != NULL)
-	sals = decode_line_1 (location.get (), 0, NULL, NULL, 0);
+	{
+	  decoded_sals = decode_line_1 (location.get (), 0, NULL, NULL, 0);
+	  sals = decoded_sals;
+	}
       else
 	{
 	  set_default_source_symtab_and_line ();
-	  sal = get_current_source_symtab_and_line ();
-	  sals.sals = &sal;
-	  sals.nelts = 1;
+	  def_sal = get_current_source_symtab_and_line ();
+	  sals = def_sal;
 	}
     }
   CATCH (ex, RETURN_MASK_ALL)
     {
-      except = ex;
-    }
-  END_CATCH
-
-  /* Ensure that the sals data is freed, when needed.  */
-  gdb::unique_xmalloc_ptr<struct symtab_and_line> free_sals;
-  if (sals.sals != NULL && sals.sals != &sal)
-    free_sals.reset (sals.sals);
-
-  if (except.reason < 0)
-    {
       /* We know this will always throw.  */
-      gdbpy_convert_exception (except);
+      gdbpy_convert_exception (ex);
       return NULL;
     }
+  END_CATCH
 
-  if (sals.nelts)
+  if (!sals.empty ())
     {
-      int i;
-
-      result.reset (PyTuple_New (sals.nelts));
+      result.reset (PyTuple_New (sals.size ()));
       if (result == NULL)
 	return NULL;
-      for (i = 0; i < sals.nelts; ++i)
+      for (size_t i = 0; i < sals.size (); ++i)
 	{
-	  PyObject *obj;
-
-	  obj = symtab_and_line_to_sal_object (sals.sals[i]);
-	  if (! obj)
+	  PyObject *obj = symtab_and_line_to_sal_object (sals[i]);
+	  if (obj == NULL)
 	    return NULL;
 
 	  PyTuple_SetItem (result.get (), i, obj);
diff --git a/gdb/source.c b/gdb/source.c
index 769d9ef..0c44879 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -258,8 +258,6 @@ clear_current_source_symtab_and_line (void)
 void
 select_source_symtab (struct symtab *s)
 {
-  struct symtabs_and_lines sals;
-  struct symtab_and_line sal;
   struct objfile *ofp;
   struct compunit_symtab *cu;
 
@@ -278,10 +276,10 @@ select_source_symtab (struct symtab *s)
      if one exists.  */
   if (lookup_symbol (main_name (), 0, VAR_DOMAIN, 0).symbol)
     {
-      sals = decode_line_with_current_source (main_name (),
-					      DECODE_LINE_FUNFIRSTLINE);
-      sal = sals.sals[0];
-      xfree (sals.sals);
+      std::vector<symtab_and_line> sals
+	= decode_line_with_current_source (main_name (),
+					   DECODE_LINE_FUNFIRSTLINE);
+      const symtab_and_line &sal = sals[0];
       current_source_pspace = sal.pspace;
       current_source_symtab = sal.symtab;
       current_source_line = std::max (sal.line - (lines_to_list - 1), 1);
@@ -1504,41 +1502,37 @@ print_source_lines (struct symtab *s, int line, int stopline,
 static void
 line_info (char *arg, int from_tty)
 {
-  struct symtabs_and_lines sals;
-  struct symtab_and_line sal;
   CORE_ADDR start_pc, end_pc;
-  int i;
-  struct cleanup *cleanups;
 
-  init_sal (&sal);		/* initialize to zeroes */
+  std::vector<symtab_and_line> decoded_sals;
+  symtab_and_line curr_sal;
+  gdb::array_view<symtab_and_line> sals;
 
   if (arg == 0)
     {
-      sal.symtab = current_source_symtab;
-      sal.pspace = current_program_space;
+      init_sal (&curr_sal);		/* initialize to zeroes */
+      curr_sal.symtab = current_source_symtab;
+      curr_sal.pspace = current_program_space;
       if (last_line_listed != 0)
-	sal.line = last_line_listed;
+	curr_sal.line = last_line_listed;
       else
-	sal.line = current_source_line;
+	curr_sal.line = current_source_line;
 
-      sals.nelts = 1;
-      sals.sals = XNEW (struct symtab_and_line);
-      sals.sals[0] = sal;
+      sals = curr_sal;
     }
   else
     {
-      sals = decode_line_with_last_displayed (arg, DECODE_LINE_LIST_MODE);
+      decoded_sals = decode_line_with_last_displayed (arg,
+						      DECODE_LINE_LIST_MODE);
+      sals = decoded_sals;
 
       dont_repeat ();
     }
 
-  cleanups = make_cleanup (xfree, sals.sals);
-
   /* C++  More than one line may have been specified, as when the user
      specifies an overloaded function name.  Print info on them all.  */
-  for (i = 0; i < sals.nelts; i++)
+  for (const auto &sal : sals)
     {
-      sal = sals.sals[i];
       if (sal.pspace != current_program_space)
 	continue;
 
@@ -1599,7 +1593,7 @@ line_info (char *arg, int from_tty)
 
 	  /* If this is the only line, show the source code.  If it could
 	     not find the file, don't do anything special.  */
-	  if (annotation_level && sals.nelts == 1)
+	  if (annotation_level && sals.size () == 1)
 	    identify_source_line (sal.symtab, sal.line, 0, start_pc);
 	}
       else
@@ -1609,7 +1603,6 @@ line_info (char *arg, int from_tty)
 	printf_filtered (_("Line number %d is out of range for \"%s\".\n"),
 			 sal.line, symtab_to_filename_for_display (sal.symtab));
     }
-  do_cleanups (cleanups);
 }
 
 /* Commands to search the source file for a regexp.  */
diff --git a/gdb/stack.c b/gdb/stack.c
index 3e9dca2..82600ec 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -2527,26 +2527,23 @@ func_command (char *arg, int from_tty)
 {
   struct frame_info *frame;
   int found = 0;
-  struct symtabs_and_lines sals;
-  int i;
   int level = 1;
   struct function_bounds *func_bounds = NULL;
-  struct cleanup *cleanups;
 
   if (arg == NULL)
     return;
 
   frame = get_current_frame ();
-  sals = decode_line_with_current_source (arg, DECODE_LINE_FUNFIRSTLINE);
-  cleanups = make_cleanup (xfree, sals.sals);
-  func_bounds = XNEWVEC (struct function_bounds, sals.nelts);
-  make_cleanup (xfree, func_bounds);
-  for (i = 0; (i < sals.nelts && !found); i++)
+  std::vector<symtab_and_line> sals
+    = decode_line_with_current_source (arg, DECODE_LINE_FUNFIRSTLINE);
+  func_bounds = XNEWVEC (struct function_bounds, sals.size ());
+  struct cleanup *cleanups = make_cleanup (xfree, func_bounds);
+  for (size_t i = 0; (i < sals.size () && !found); i++)
     {
-      if (sals.sals[i].pspace != current_program_space)
+      if (sals[i].pspace != current_program_space)
 	func_bounds[i].low = func_bounds[i].high = 0;
-      else if (sals.sals[i].pc == 0
-	       || find_pc_partial_function (sals.sals[i].pc, NULL,
+      else if (sals[i].pc == 0
+	       || find_pc_partial_function (sals[i].pc, NULL,
 					    &func_bounds[i].low,
 					    &func_bounds[i].high) == 0)
 	{
@@ -2556,7 +2553,7 @@ func_command (char *arg, int from_tty)
 
   do
     {
-      for (i = 0; (i < sals.nelts && !found); i++)
+      for (size_t i = 0; (i < sals.size () && !found); i++)
 	found = (get_frame_pc (frame) >= func_bounds[i].low
 		 && get_frame_pc (frame) < func_bounds[i].high);
       if (!found)
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 35949f0..37cfe05 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1441,11 +1441,6 @@ struct symtab_and_line
 
 extern void init_sal (struct symtab_and_line *sal);
 
-struct symtabs_and_lines
-{
-  struct symtab_and_line *sals;
-  int nelts;
-};
 
 
 /* Given a pc value, return line number it is in.  Second arg nonzero means
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 86acdbe..8f4de36 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2433,30 +2433,24 @@ tfind_tracepoint_command (char *args, int from_tty)
 static void
 tfind_line_command (char *args, int from_tty)
 {
-  static CORE_ADDR start_pc, end_pc;
-  struct symtabs_and_lines sals;
-  struct symtab_and_line sal;
-  struct cleanup *old_chain;
-
   check_trace_running (current_trace_status ());
 
+  symtab_and_line sal;
   if (args == 0 || *args == 0)
     {
       sal = find_pc_line (get_frame_pc (get_current_frame ()), 0);
-      sals.nelts = 1;
-      sals.sals = XNEW (struct symtab_and_line);
-      sals.sals[0] = sal;
     }
   else
     {
-      sals = decode_line_with_current_source (args, DECODE_LINE_FUNFIRSTLINE);
-      sal = sals.sals[0];
+      std::vector<symtab_and_line> sals
+	= decode_line_with_current_source (args, DECODE_LINE_FUNFIRSTLINE);
+      sal = sals[0];
     }
-  
-  old_chain = make_cleanup (xfree, sals.sals);
+
   if (sal.symtab == 0)
     error (_("No line number information available."));
 
+  CORE_ADDR start_pc, end_pc;
   if (sal.line > 0 && find_line_pc_range (sal, &start_pc, &end_pc))
     {
       if (start_pc == end_pc)
@@ -2491,7 +2485,6 @@ tfind_line_command (char *args, int from_tty)
     tfind_1 (tfind_range, 0, start_pc, end_pc - 1, from_tty);
   else
     tfind_1 (tfind_outside, 0, start_pc, end_pc - 1, from_tty);
-  do_cleanups (old_chain);
 }
 
 /* tfind range command */
@@ -2562,7 +2555,6 @@ tfind_outside_command (char *args, int from_tty)
 static void
 scope_info (char *args, int from_tty)
 {
-  struct symtabs_and_lines sals;
   struct symbol *sym;
   struct bound_minimal_symbol msym;
   const struct block *block;
@@ -2579,17 +2571,18 @@ scope_info (char *args, int from_tty)
 
   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)
+  std::vector<symtab_and_line> sals
+    = decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE,
+		     NULL, NULL, 0);
+  if (sals.empty ())
     {
       /* Presumably decode_line_1 has already warned.  */
       return;
     }
 
   /* Resolve line numbers to PC.  */
-  resolve_sal_pc (&sals.sals[0]);
-  block = block_for_pc (sals.sals[0].pc);
+  resolve_sal_pc (&sals[0]);
+  block = block_for_pc (sals[0].pc);
 
   while (block != 0)
     {
-- 
2.5.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]