gdb/mi: New commands to catch C++ exceptions
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index 4272378a6942d73cbb4359a3118eebb7f720d734..ccd778b7a13ef8fe52d6e9dab44517d41988bf60 100644 (file)
@@ -1,6 +1,6 @@
 /* Everything about breakpoints, for GDB.
 
-   Copyright (C) 1986-2017 Free Software Foundation, Inc.
+   Copyright (C) 1986-2019 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -49,7 +49,7 @@
 #include "block.h"
 #include "solib.h"
 #include "solist.h"
-#include "observer.h"
+#include "observable.h"
 #include "memattr.h"
 #include "ada-lang.h"
 #include "top.h"
 #include "ax-gdb.h"
 #include "dummy-frame.h"
 #include "interps.h"
-#include "format.h"
+#include "common/format.h"
 #include "thread-fsm.h"
 #include "tid-parse.h"
+#include "cli/cli-style.h"
+#include "mi/mi-main.h"
 
 /* readline include files */
 #include "readline/readline.h"
 #include "common/array-view.h"
 #include "common/gdb_optional.h"
 
-/* Enums for exception-handling support.  */
-enum exception_event_kind
-{
-  EX_EVENT_THROW,
-  EX_EVENT_RETHROW,
-  EX_EVENT_CATCH
-};
-
 /* Prototypes for local functions.  */
 
 static void map_breakpoint_numbers (const char *,
@@ -117,7 +111,8 @@ static std::vector<symtab_and_line> decode_location_default
   (struct breakpoint *b, const struct event_location *location,
    struct program_space *search_pspace);
 
-static int can_use_hardware_watchpoint (struct value *);
+static int can_use_hardware_watchpoint
+    (const std::vector<value_ref_ptr> &vals);
 
 static void mention (struct breakpoint *);
 
@@ -161,8 +156,6 @@ static int breakpoint_location_address_range_overlap (struct bp_location *,
                                                      const address_space *,
                                                      CORE_ADDR, int);
 
-static void info_watchpoints_command (char *, int);
-
 static int remove_breakpoint (struct bp_location *);
 static int remove_breakpoint_1 (struct bp_location *, enum remove_bp_reason);
 
@@ -228,12 +221,6 @@ static int is_hardware_watchpoint (const struct breakpoint *bpt);
 
 static void insert_breakpoint_locations (void);
 
-static void info_tracepoints_command (char *, int);
-
-static void enable_trace_command (char *, int);
-
-static void disable_trace_command (char *, int);
-
 static void trace_pass_command (const char *, int);
 
 static void set_tracepoint_count (int num);
@@ -407,8 +394,6 @@ breakpoints_should_be_inserted_now (void)
     }
   else if (target_has_execution)
     {
-      struct thread_info *tp;
-
       if (always_inserted_mode)
        {
          /* The user wants breakpoints inserted even if all threads
@@ -421,7 +406,7 @@ breakpoints_should_be_inserted_now (void)
 
       /* Don't remove breakpoints yet if, even though all threads are
         stopped, we still have events to process.  */
-      ALL_NON_EXITED_THREADS (tp)
+      for (thread_info *tp : all_non_exited_threads ())
        if (tp->resumed
            && tp->suspend.waitstatus_pending_p)
          return 1;
@@ -567,7 +552,7 @@ static CORE_ADDR bp_locations_shadow_len_after_address_max;
 /* The locations that no longer correspond to any breakpoint, unlinked
    from the bp_locations array, but for which a hit may still be
    reported by a target.  */
-VEC(bp_location_p) *moribund_locations = NULL;
+static std::vector<bp_location *> moribund_locations;
 
 /* Number of last breakpoint made.  */
 
@@ -718,7 +703,7 @@ mark_breakpoint_location_modified (struct bp_location *loc)
    condition_evaluation_mode.  */
 
 static void
-set_condition_evaluation_mode (char *args, int from_tty,
+set_condition_evaluation_mode (const char *args, int from_tty,
                               struct cmd_list_element *c)
 {
   const char *old_mode, *new_mode;
@@ -887,12 +872,12 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp,
        {
          struct watchpoint *w = (struct watchpoint *) b;
 
-         innermost_block = NULL;
+         innermost_block_tracker tracker;
          arg = exp;
-         w->cond_exp = parse_exp_1 (&arg, 0, 0, 0);
+         w->cond_exp = parse_exp_1 (&arg, 0, 0, 0, &tracker);
          if (*arg)
            error (_("Junk at end of expression"));
-         w->cond_exp_valid_block = innermost_block;
+         w->cond_exp_valid_block = tracker.block ();
        }
       else
        {
@@ -911,7 +896,7 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp,
     }
   mark_breakpoint_modified (b);
 
-  observer_notify_breakpoint_modified (b);
+  gdb::observers::breakpoint_modified.notify (b);
 }
 
 /* Completion for the "condition" command.  */
@@ -929,7 +914,6 @@ condition_completer (struct cmd_list_element *cmd,
     {
       int len;
       struct breakpoint *b;
-      VEC (char_ptr) *result = NULL;
 
       if (text[0] == '$')
        {
@@ -949,10 +933,7 @@ condition_completer (struct cmd_list_element *cmd,
          xsnprintf (number, sizeof (number), "%d", b->number);
 
          if (strncmp (number, text, len) == 0)
-           {
-             gdb::unique_xmalloc_ptr<char> copy (xstrdup (number));
-             tracker.add_completion (std::move (copy));
-           }
+           tracker.add_completion (make_unique_xstrdup (number));
        }
 
       return;
@@ -1017,14 +998,12 @@ check_no_tracepoint_commands (struct command_line *commands)
 
   for (c = commands; c; c = c->next)
     {
-      int i;
-
       if (c->control_type == while_stepping_control)
        error (_("The 'while-stepping' command can "
                 "only be used for tracepoints"));
 
-      for (i = 0; i < c->body_count; ++i)
-       check_no_tracepoint_commands ((c->body_list)[i]);
+      check_no_tracepoint_commands (c->body_list_0.get ());
+      check_no_tracepoint_commands (c->body_list_1.get ());
 
       /* Not that command parsing removes leading whitespace and comment
         lines and also empty lines.  So, we only need to check for
@@ -1135,8 +1114,8 @@ validate_commands_for_breakpoint (struct breakpoint *b,
        {
          struct command_line *c2;
 
-         gdb_assert (while_stepping->body_count == 1);
-         c2 = while_stepping->body_list[0];
+         gdb_assert (while_stepping->body_list_1 == nullptr);
+         c2 = while_stepping->body_list_0.get ();
          for (; c2; c2 = c2->next)
            {
              if (c2->control_type == while_stepping_control)
@@ -1153,11 +1132,11 @@ validate_commands_for_breakpoint (struct breakpoint *b,
 /* Return a vector of all the static tracepoints set at ADDR.  The
    caller is responsible for releasing the vector.  */
 
-VEC(breakpoint_p) *
+std::vector<breakpoint *>
 static_tracepoints_here (CORE_ADDR addr)
 {
   struct breakpoint *b;
-  VEC(breakpoint_p) *found = 0;
+  std::vector<breakpoint *> found;
   struct bp_location *loc;
 
   ALL_BREAKPOINTS (b)
@@ -1165,7 +1144,7 @@ static_tracepoints_here (CORE_ADDR addr)
       {
        for (loc = b->loc; loc; loc = loc->next)
          if (loc->address == addr)
-           VEC_safe_push(breakpoint_p, found, b);
+           found.push_back (b);
       }
 
   return found;
@@ -1176,12 +1155,12 @@ static_tracepoints_here (CORE_ADDR addr)
 
 void
 breakpoint_set_commands (struct breakpoint *b, 
-                        command_line_up &&commands)
+                        counted_command_line &&commands)
 {
   validate_commands_for_breakpoint (b, commands.get ());
 
   b->commands = std::move (commands);
-  observer_notify_breakpoint_modified (b);
+  gdb::observers::breakpoint_modified.notify (b);
 }
 
 /* Set the internal `silent' flag on the breakpoint.  Note that this
@@ -1195,7 +1174,7 @@ breakpoint_set_silent (struct breakpoint *b, int silent)
 
   b->silent = silent;
   if (old_silent != silent)
-    observer_notify_breakpoint_modified (b);
+    gdb::observers::breakpoint_modified.notify (b);
 }
 
 /* Set the thread for this breakpoint.  If THREAD is -1, make the
@@ -1208,7 +1187,7 @@ breakpoint_set_thread (struct breakpoint *b, int thread)
 
   b->thread = thread;
   if (old_thread != thread)
-    observer_notify_breakpoint_modified (b);
+    gdb::observers::breakpoint_modified.notify (b);
 }
 
 /* Set the task for this breakpoint.  If TASK is 0, make the
@@ -1221,15 +1200,7 @@ breakpoint_set_task (struct breakpoint *b, int task)
 
   b->task = task;
   if (old_task != task)
-    observer_notify_breakpoint_modified (b);
-}
-
-void
-check_tracepoint_command (char *line, void *closure)
-{
-  struct breakpoint *b = (struct breakpoint *) closure;
-
-  validate_actionline (line, b);
+    gdb::observers::breakpoint_modified.notify (b);
 }
 
 static void
@@ -1237,6 +1208,10 @@ commands_command_1 (const char *arg, int from_tty,
                    struct command_line *control)
 {
   counted_command_line cmd;
+  /* cmd_read will be true once we have read cmd.  Note that cmd might still be
+     NULL after the call to read_command_lines if the user provides an empty
+     list of command by just typing "end".  */
+  bool cmd_read = false;
 
   std::string new_arg;
 
@@ -1253,10 +1228,11 @@ commands_command_1 (const char *arg, int from_tty,
   map_breakpoint_numbers
     (arg, [&] (breakpoint *b)
      {
-       if (cmd == NULL)
+       if (!cmd_read)
         {
+          gdb_assert (cmd == NULL);
           if (control != NULL)
-            cmd = copy_command_lines (control->body_list[0]);
+            cmd = control->body_list_0;
           else
             {
               std::string str
@@ -1264,12 +1240,17 @@ commands_command_1 (const char *arg, int from_tty,
                                    "%s, one per line."),
                                  arg);
 
-              cmd = read_command_lines (&str[0],
-                                        from_tty, 1,
-                                        (is_tracepoint (b)
-                                         ? check_tracepoint_command : 0),
-                                        b);
+              auto do_validate = [=] (const char *line)
+                                 {
+                                   validate_actionline (line, b);
+                                 };
+              gdb::function_view<void (const char *)> validator;
+              if (is_tracepoint (b))
+                validator = do_validate;
+
+              cmd = read_command_lines (str.c_str (), from_tty, 1, validator);
             }
+          cmd_read = true;
         }
 
        /* If a breakpoint was on the list more than once, we don't need to
@@ -1278,12 +1259,9 @@ commands_command_1 (const char *arg, int from_tty,
         {
           validate_commands_for_breakpoint (b, cmd.get ());
           b->commands = cmd;
-          observer_notify_breakpoint_modified (b);
+          gdb::observers::breakpoint_modified.notify (b);
         }
      });
-
-  if (cmd == NULL)
-    error (_("No breakpoints specified."));
 }
 
 static void
@@ -1561,9 +1539,9 @@ static int
 watchpoint_in_thread_scope (struct watchpoint *b)
 {
   return (b->pspace == current_program_space
-         && (ptid_equal (b->watchpoint_thread, null_ptid)
-             || (ptid_equal (inferior_ptid, b->watchpoint_thread)
-                 && !is_executing (inferior_ptid))));
+         && (b->watchpoint_thread == null_ptid
+             || (inferior_ptid == b->watchpoint_thread
+                 && !inferior_thread ()->executing)));
 }
 
 /* Set watchpoint B to disp_del_at_next_stop, even including its possible
@@ -1752,7 +1730,6 @@ update_watchpoint (struct watchpoint *b, int reparse)
         no longer relevant.  We don't want to report a watchpoint hit
         to the user when the old value and the new value may actually
         be completely different objects.  */
-      value_free (b->val);
       b->val = NULL;
       b->val_valid = 0;
 
@@ -1790,7 +1767,8 @@ update_watchpoint (struct watchpoint *b, int reparse)
   else if (within_current_scope && b->exp)
     {
       int pc = 0;
-      struct value *val_chain, *v, *result, *next;
+      std::vector<value_ref_ptr> val_chain;
+      struct value *v, *result;
       struct program_space *frame_pspace;
 
       fetch_subexp_value (b->exp.get (), &pc, &v, &result, &val_chain, 0);
@@ -1804,27 +1782,26 @@ update_watchpoint (struct watchpoint *b, int reparse)
       if (!b->val_valid && !is_masked_watchpoint (b))
        {
          if (b->val_bitsize != 0)
-           {
-             v = extract_bitfield_from_watchpoint_value (b, v);
-             if (v != NULL)
-               release_value (v);
-           }
-         b->val = v;
+           v = extract_bitfield_from_watchpoint_value (b, v);
+         b->val = release_value (v);
          b->val_valid = 1;
        }
 
       frame_pspace = get_frame_program_space (get_selected_frame (NULL));
 
       /* Look at each value on the value chain.  */
-      for (v = val_chain; v; v = value_next (v))
+      gdb_assert (!val_chain.empty ());
+      for (const value_ref_ptr &iter : val_chain)
        {
+         v = iter.get ();
+
          /* If it's a memory location, and GDB actually needed
             its contents to evaluate the expression, then we
             must watch it.  If the first value returned is
             still lazy, that means an error occurred reading it;
             watch it anyway in case it becomes readable.  */
          if (VALUE_LVAL (v) == lval_memory
-             && (v == val_chain || ! value_lazy (v)))
+             && (v == val_chain[0] || ! value_lazy (v)))
            {
              struct type *vtype = check_typedef (value_type (v));
 
@@ -1876,7 +1853,7 @@ update_watchpoint (struct watchpoint *b, int reparse)
                  loc->gdbarch = get_type_arch (value_type (v));
 
                  loc->pspace = frame_pspace;
-                 loc->address = addr;
+                 loc->address = address_significant (loc->gdbarch, addr);
 
                  if (bitsize != 0)
                    {
@@ -1979,13 +1956,6 @@ update_watchpoint (struct watchpoint *b, int reparse)
            bl->loc_type = loc_type;
        }
 
-      for (v = val_chain; v; v = next)
-       {
-         next = value_next (v);
-         if (v != b->val)
-           value_free (v);
-       }
-
       /* If a software watchpoint is not watching any memory, then the
         above left it without any location set up.  But,
         bpstat_stop_status requires a location to be able to report
@@ -2116,18 +2086,17 @@ parse_cond_to_aexpr (CORE_ADDR scope, struct expression *cond)
 
   /* We don't want to stop processing, so catch any errors
      that may show up.  */
-  TRY
+  try
     {
       aexpr = gen_eval_for_expr (scope, cond);
     }
 
-  CATCH (ex, RETURN_MASK_ERROR)
+  catch (const gdb_exception_error &ex)
     {
       /* If we got here, it means the condition could not be parsed to a valid
         bytecode expression and thus can't be evaluated on the target's side.
         It's no use iterating through the conditions.  */
     }
-  END_CATCH
 
   /* We have a valid agent expression.  */
   return aexpr;
@@ -2238,12 +2207,8 @@ build_target_condition_list (struct bp_location *bl)
 static agent_expr_up
 parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
 {
-  struct cleanup *old_cleanups = 0;
-  struct expression **argvec;
   const char *cmdrest;
   const char *format_start, *format_end;
-  struct format_piece *fpieces;
-  int nargs;
   struct gdbarch *gdbarch = get_current_arch ();
 
   if (cmd == NULL)
@@ -2260,9 +2225,7 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
 
   format_start = cmdrest;
 
-  fpieces = parse_format_string (&cmdrest);
-
-  old_cleanups = make_cleanup (free_format_pieces_cleanup, &fpieces);
+  format_pieces fpieces (&cmdrest);
 
   format_end = cmdrest;
 
@@ -2280,17 +2243,14 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
 
   /* For each argument, make an expression.  */
 
-  argvec = (struct expression **) alloca (strlen (cmd)
-                                        * sizeof (struct expression *));
-
-  nargs = 0;
+  std::vector<struct expression *> argvec;
   while (*cmdrest != '\0')
     {
       const char *cmd1;
 
       cmd1 = cmdrest;
       expression_up expr = parse_exp_1 (&cmd1, scope, block_for_pc (scope), 1);
-      argvec[nargs++] = expr.release ();
+      argvec.push_back (expr.release ());
       cmdrest = cmd1;
       if (*cmdrest == ',')
        ++cmdrest;
@@ -2300,21 +2260,18 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
 
   /* We don't want to stop processing, so catch any errors
      that may show up.  */
-  TRY
+  try
     {
       aexpr = gen_printf (scope, gdbarch, 0, 0,
                          format_start, format_end - format_start,
-                         fpieces, nargs, argvec);
+                         argvec.size (), argvec.data ());
     }
-  CATCH (ex, RETURN_MASK_ERROR)
+  catch (const gdb_exception_error &ex)
     {
       /* If we got here, it means the command could not be parsed to a valid
         bytecode expression and thus can't be evaluated on the target's side.
         It's no use iterating through the other commands.  */
     }
-  END_CATCH
-
-  do_cleanups (old_cleanups);
 
   /* We have a valid agent expression, return it.  */
   return aexpr;
@@ -2442,7 +2399,7 @@ breakpoint_kind (struct bp_location *bl, CORE_ADDR *addr)
       struct thread_info *thr = find_thread_global_id (bl->owner->thread);
       struct regcache *regcache;
 
-      regcache = get_thread_regcache (thr->ptid);
+      regcache = get_thread_regcache (thr);
 
       return gdbarch_breakpoint_kind_from_current_state (bl->gdbarch,
                                                         regcache, addr);
@@ -2466,8 +2423,7 @@ insert_bp_location (struct bp_location *bl,
                    int *hw_breakpoint_error,
                    int *hw_bp_error_explained_already)
 {
-  enum errors bp_err = GDB_NO_ERROR;
-  const char *bp_err_message = NULL;
+  gdb_exception bp_excpt;
 
   if (!should_be_inserted (bl) || (bl->inserted && !bl->needs_update))
     return 0;
@@ -2570,20 +2526,18 @@ insert_bp_location (struct bp_location *bl,
          || !(section_is_overlay (bl->section)))
        {
          /* No overlay handling: just set the breakpoint.  */
-         TRY
+         try
            {
              int val;
 
              val = bl->owner->ops->insert_location (bl);
              if (val)
-               bp_err = GENERIC_ERROR;
+               bp_excpt = gdb_exception {RETURN_ERROR, GENERIC_ERROR};
            }
-         CATCH (e, RETURN_MASK_ALL)
+         catch (gdb_exception &e)
            {
-             bp_err = e.error;
-             bp_err_message = e.message;
+             bp_excpt = std::move (e);
            }
-         END_CATCH
        }
       else
        {
@@ -2606,7 +2560,7 @@ insert_bp_location (struct bp_location *bl,
                  bl->overlay_target_info.reqstd_address = addr;
 
                  /* No overlay handling: just set the breakpoint.  */
-                 TRY
+                 try
                    {
                      int val;
 
@@ -2616,16 +2570,15 @@ insert_bp_location (struct bp_location *bl,
                      val = target_insert_breakpoint (bl->gdbarch,
                                                      &bl->overlay_target_info);
                      if (val)
-                       bp_err = GENERIC_ERROR;
+                       bp_excpt
+                         = gdb_exception {RETURN_ERROR, GENERIC_ERROR};
                    }
-                 CATCH (e, RETURN_MASK_ALL)
+                 catch (gdb_exception &e)
                    {
-                     bp_err = e.error;
-                     bp_err_message = e.message;
+                     bp_excpt = std::move (e);
                    }
-                 END_CATCH
 
-                 if (bp_err != GDB_NO_ERROR)
+                 if (bp_excpt.reason != 0)
                    fprintf_unfiltered (tmp_error_stream,
                                        "Overlay breakpoint %d "
                                        "failed: in ROM?\n",
@@ -2636,20 +2589,18 @@ insert_bp_location (struct bp_location *bl,
          if (section_is_mapped (bl->section))
            {
              /* Yes.  This overlay section is mapped into memory.  */
-             TRY
+             try
                {
                  int val;
 
                  val = bl->owner->ops->insert_location (bl);
                  if (val)
-                   bp_err = GENERIC_ERROR;
+                   bp_excpt = gdb_exception {RETURN_ERROR, GENERIC_ERROR};
                }
-             CATCH (e, RETURN_MASK_ALL)
+             catch (gdb_exception &e)
                {
-                 bp_err = e.error;
-                 bp_err_message = e.message;
+                 bp_excpt = std::move (e);
                }
-             END_CATCH
            }
          else
            {
@@ -2659,7 +2610,7 @@ insert_bp_location (struct bp_location *bl,
            }
        }
 
-      if (bp_err != GDB_NO_ERROR)
+      if (bp_excpt.reason != 0)
        {
          /* Can't set the breakpoint.  */
 
@@ -2671,7 +2622,9 @@ insert_bp_location (struct bp_location *bl,
             breakpoint insertion failed (e.g., the remote target
             doesn't define error codes), so we must treat generic
             errors as memory errors.  */
-         if ((bp_err == GENERIC_ERROR || bp_err == MEMORY_ERROR)
+         if (bp_excpt.reason == RETURN_ERROR
+             && (bp_excpt.error == GENERIC_ERROR
+                 || bp_excpt.error == MEMORY_ERROR)
              && bl->loc_type == bp_loc_software_breakpoint
              && (solib_name_from_address (bl->pspace, bl->address)
                  || shared_objfile_contains_address_p (bl->pspace,
@@ -2679,7 +2632,7 @@ insert_bp_location (struct bp_location *bl,
            {
              /* See also: disable_breakpoints_in_shlibs.  */
              bl->shlib_disabled = 1;
-             observer_notify_breakpoint_modified (bl->owner);
+             gdb::observers::breakpoint_modified.notify (bl->owner);
              if (!*disabled_breaks)
                {
                  fprintf_unfiltered (tmp_error_stream, 
@@ -2699,16 +2652,18 @@ insert_bp_location (struct bp_location *bl,
              if (bl->loc_type == bp_loc_hardware_breakpoint)
                {
                  *hw_breakpoint_error = 1;
-                 *hw_bp_error_explained_already = bp_err_message != NULL;
+                 *hw_bp_error_explained_already = bp_excpt.message != NULL;
                   fprintf_unfiltered (tmp_error_stream,
                                       "Cannot insert hardware breakpoint %d%s",
-                                      bl->owner->number, bp_err_message ? ":" : ".\n");
-                  if (bp_err_message != NULL)
-                    fprintf_unfiltered (tmp_error_stream, "%s.\n", bp_err_message);
+                                      bl->owner->number,
+                                     bp_excpt.message ? ":" : ".\n");
+                  if (bp_excpt.message != NULL)
+                    fprintf_unfiltered (tmp_error_stream, "%s.\n",
+                                       bp_excpt.what ());
                }
              else
                {
-                 if (bp_err_message == NULL)
+                 if (bp_excpt.message == NULL)
                    {
                      std::string message
                        = memory_error_message (TARGET_XFER_E_IO,
@@ -2724,7 +2679,7 @@ insert_bp_location (struct bp_location *bl,
                      fprintf_unfiltered (tmp_error_stream,
                                          "Cannot insert breakpoint %d: %s\n",
                                          bl->owner->number,
-                                         bp_err_message);
+                                         bp_excpt.what ());
                    }
                }
              return 1;
@@ -2927,7 +2882,7 @@ update_inserted_breakpoint_locations (void)
       /* We only want to update locations that are already inserted
         and need updating.  This is to avoid unwanted insertion during
         deletion of breakpoints.  */
-      if (!bl->inserted || (bl->inserted && !bl->needs_update))
+      if (!bl->inserted || !bl->needs_update)
        continue;
 
       switch_to_program_space_and_thread (bl->pspace);
@@ -2937,7 +2892,7 @@ update_inserted_breakpoint_locations (void)
         if we aren't attached to any process yet, we should still
         insert breakpoints.  */
       if (!gdbarch_has_global_breakpoints (target_gdbarch ())
-         && ptid_equal (inferior_ptid, null_ptid))
+         && inferior_ptid == null_ptid)
        continue;
 
       val = insert_bp_location (bl, &tmp_error_stream, &disabled_breaks,
@@ -2993,7 +2948,7 @@ insert_breakpoint_locations (void)
         if we aren't attached to any process yet, we should still
         insert breakpoints.  */
       if (!gdbarch_has_global_breakpoints (target_gdbarch ())
-         && ptid_equal (inferior_ptid, null_ptid))
+         && inferior_ptid == null_ptid)
        continue;
 
       val = insert_bp_location (bl, &tmp_error_stream, &disabled_breaks,
@@ -3094,14 +3049,13 @@ Thread-specific breakpoint %d deleted - thread %s no longer in the thread list.\
     }
 }
 
-/* Remove breakpoints of process PID.  */
+/* Remove breakpoints of inferior INF.  */
 
 int
-remove_breakpoints_pid (int pid)
+remove_breakpoints_inf (inferior *inf)
 {
   struct bp_location *bl, **blp_tmp;
   int val;
-  struct inferior *inf = find_inferior_pid (pid);
 
   ALL_BP_LOCATIONS (bl, blp_tmp)
   {
@@ -3191,7 +3145,8 @@ struct breakpoint_objfile_data
   std::vector<probe *> exception_probes;
 };
 
-static const struct objfile_data *breakpoint_objfile_key;
+static const struct objfile_key<breakpoint_objfile_data>
+  breakpoint_objfile_key;
 
 /* Minimal symbol not found sentinel.  */
 static struct minimal_symbol msym_not_found;
@@ -3212,32 +3167,18 @@ get_breakpoint_objfile_data (struct objfile *objfile)
 {
   struct breakpoint_objfile_data *bp_objfile_data;
 
-  bp_objfile_data = ((struct breakpoint_objfile_data *)
-                    objfile_data (objfile, breakpoint_objfile_key));
+  bp_objfile_data = breakpoint_objfile_key.get (objfile);
   if (bp_objfile_data == NULL)
-    {
-      bp_objfile_data = new breakpoint_objfile_data ();
-      set_objfile_data (objfile, breakpoint_objfile_key, bp_objfile_data);
-    }
+    bp_objfile_data = breakpoint_objfile_key.emplace (objfile);
   return bp_objfile_data;
 }
 
-static void
-free_breakpoint_objfile_data (struct objfile *obj, void *data)
-{
-  struct breakpoint_objfile_data *bp_objfile_data
-    = (struct breakpoint_objfile_data *) data;
-
-  delete bp_objfile_data;
-}
-
 static void
 create_overlay_event_breakpoint (void)
 {
-  struct objfile *objfile;
   const char *const func_name = "_ovly_debug_event";
 
-  ALL_OBJFILES (objfile)
+  for (objfile *objfile : current_program_space->objfiles ())
     {
       struct breakpoint *b;
       struct breakpoint_objfile_data *bp_objfile_data;
@@ -3293,97 +3234,93 @@ create_longjmp_master_breakpoint (void)
 
   ALL_PSPACES (pspace)
   {
-    struct objfile *objfile;
-
     set_current_program_space (pspace);
 
-    ALL_OBJFILES (objfile)
-    {
-      int i;
-      struct gdbarch *gdbarch;
-      struct breakpoint_objfile_data *bp_objfile_data;
-
-      gdbarch = get_objfile_arch (objfile);
+    for (objfile *objfile : current_program_space->objfiles ())
+      {
+       int i;
+       struct gdbarch *gdbarch;
+       struct breakpoint_objfile_data *bp_objfile_data;
 
-      bp_objfile_data = get_breakpoint_objfile_data (objfile);
+       gdbarch = get_objfile_arch (objfile);
 
-      if (!bp_objfile_data->longjmp_searched)
-       {
-         std::vector<probe *> ret
-           = find_probes_in_objfile (objfile, "libc", "longjmp");
+       bp_objfile_data = get_breakpoint_objfile_data (objfile);
 
-         if (!ret.empty ())
-           {
-             /* We are only interested in checking one element.  */
-             probe *p = ret[0];
+       if (!bp_objfile_data->longjmp_searched)
+         {
+           std::vector<probe *> ret
+             = find_probes_in_objfile (objfile, "libc", "longjmp");
 
-             if (!can_evaluate_probe_arguments (p))
-               {
-                 /* We cannot use the probe interface here, because it does
-                    not know how to evaluate arguments.  */
-                 ret.clear ();
-               }
-           }
-         bp_objfile_data->longjmp_probes = ret;
-         bp_objfile_data->longjmp_searched = 1;
-       }
+           if (!ret.empty ())
+             {
+               /* We are only interested in checking one element.  */
+               probe *p = ret[0];
 
-      if (!bp_objfile_data->longjmp_probes.empty ())
-       {
-         struct gdbarch *gdbarch = get_objfile_arch (objfile);
+               if (!p->can_evaluate_arguments ())
+                 {
+                   /* We cannot use the probe interface here, because it does
+                      not know how to evaluate arguments.  */
+                   ret.clear ();
+                 }
+             }
+           bp_objfile_data->longjmp_probes = ret;
+           bp_objfile_data->longjmp_searched = 1;
+         }
 
-         for (probe *p : bp_objfile_data->longjmp_probes)
-           {
-             struct breakpoint *b;
+       if (!bp_objfile_data->longjmp_probes.empty ())
+         {
+           for (probe *p : bp_objfile_data->longjmp_probes)
+             {
+               struct breakpoint *b;
+
+               b = create_internal_breakpoint (gdbarch,
+                                               p->get_relocated_address (objfile),
+                                               bp_longjmp_master,
+                                               &internal_breakpoint_ops);
+               b->location = new_probe_location ("-probe-stap libc:longjmp");
+               b->enable_state = bp_disabled;
+             }
 
-             b = create_internal_breakpoint (gdbarch,
-                                             get_probe_address (p, objfile),
-                                             bp_longjmp_master,
-                                             &internal_breakpoint_ops);
-             b->location = new_probe_location ("-probe-stap libc:longjmp");
-             b->enable_state = bp_disabled;
-           }
+           continue;
+         }
 
+       if (!gdbarch_get_longjmp_target_p (gdbarch))
          continue;
-       }
-
-      if (!gdbarch_get_longjmp_target_p (gdbarch))
-       continue;
 
-      for (i = 0; i < NUM_LONGJMP_NAMES; i++)
-       {
-         struct breakpoint *b;
-         const char *func_name;
-         CORE_ADDR addr;
-         struct explicit_location explicit_loc;
+       for (i = 0; i < NUM_LONGJMP_NAMES; i++)
+         {
+           struct breakpoint *b;
+           const char *func_name;
+           CORE_ADDR addr;
+           struct explicit_location explicit_loc;
 
-         if (msym_not_found_p (bp_objfile_data->longjmp_msym[i].minsym))
-           continue;
+           if (msym_not_found_p (bp_objfile_data->longjmp_msym[i].minsym))
+             continue;
 
-         func_name = longjmp_names[i];
-         if (bp_objfile_data->longjmp_msym[i].minsym == NULL)
-           {
-             struct bound_minimal_symbol m;
+           func_name = longjmp_names[i];
+           if (bp_objfile_data->longjmp_msym[i].minsym == NULL)
+             {
+               struct bound_minimal_symbol m;
 
-             m = lookup_minimal_symbol_text (func_name, objfile);
-             if (m.minsym == NULL)
-               {
-                 /* Prevent future lookups in this objfile.  */
-                 bp_objfile_data->longjmp_msym[i].minsym = &msym_not_found;
-                 continue;
-               }
-             bp_objfile_data->longjmp_msym[i] = m;
-           }
+               m = lookup_minimal_symbol_text (func_name, objfile);
+               if (m.minsym == NULL)
+                 {
+                   /* Prevent future lookups in this objfile.  */
+                   bp_objfile_data->longjmp_msym[i].minsym = &msym_not_found;
+                   continue;
+                 }
+               bp_objfile_data->longjmp_msym[i] = m;
+             }
 
-         addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->longjmp_msym[i]);
-         b = create_internal_breakpoint (gdbarch, addr, bp_longjmp_master,
-                                         &internal_breakpoint_ops);
-         initialize_explicit_location (&explicit_loc);
-         explicit_loc.function_name = ASTRDUP (func_name);
-         b->location = new_explicit_location (&explicit_loc);
-         b->enable_state = bp_disabled;
-       }
-    }
+           addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->longjmp_msym[i]);
+           b = create_internal_breakpoint (gdbarch, addr, bp_longjmp_master,
+                                           &internal_breakpoint_ops);
+           initialize_explicit_location (&explicit_loc);
+           explicit_loc.function_name = ASTRDUP (func_name);
+           b->location = new_explicit_location (&explicit_loc);
+           b->enable_state = bp_disabled;
+         }
+      }
   }
 }
 
@@ -3398,46 +3335,45 @@ create_std_terminate_master_breakpoint (void)
 
   ALL_PSPACES (pspace)
   {
-    struct objfile *objfile;
     CORE_ADDR addr;
 
     set_current_program_space (pspace);
 
-    ALL_OBJFILES (objfile)
-    {
-      struct breakpoint *b;
-      struct breakpoint_objfile_data *bp_objfile_data;
-      struct explicit_location explicit_loc;
+    for (objfile *objfile : current_program_space->objfiles ())
+      {
+       struct breakpoint *b;
+       struct breakpoint_objfile_data *bp_objfile_data;
+       struct explicit_location explicit_loc;
 
-      bp_objfile_data = get_breakpoint_objfile_data (objfile);
+       bp_objfile_data = get_breakpoint_objfile_data (objfile);
 
-      if (msym_not_found_p (bp_objfile_data->terminate_msym.minsym))
-       continue;
+       if (msym_not_found_p (bp_objfile_data->terminate_msym.minsym))
+         continue;
 
-      if (bp_objfile_data->terminate_msym.minsym == NULL)
-       {
-         struct bound_minimal_symbol m;
+       if (bp_objfile_data->terminate_msym.minsym == NULL)
+         {
+           struct bound_minimal_symbol m;
 
-         m = lookup_minimal_symbol (func_name, NULL, objfile);
-         if (m.minsym == NULL || (MSYMBOL_TYPE (m.minsym) != mst_text
-                                  && MSYMBOL_TYPE (m.minsym) != mst_file_text))
-           {
-             /* Prevent future lookups in this objfile.  */
-             bp_objfile_data->terminate_msym.minsym = &msym_not_found;
-             continue;
-           }
-         bp_objfile_data->terminate_msym = m;
-       }
+           m = lookup_minimal_symbol (func_name, NULL, objfile);
+           if (m.minsym == NULL || (MSYMBOL_TYPE (m.minsym) != mst_text
+                                    && MSYMBOL_TYPE (m.minsym) != mst_file_text))
+             {
+               /* Prevent future lookups in this objfile.  */
+               bp_objfile_data->terminate_msym.minsym = &msym_not_found;
+               continue;
+             }
+           bp_objfile_data->terminate_msym = m;
+         }
 
-      addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->terminate_msym);
-      b = create_internal_breakpoint (get_objfile_arch (objfile), addr,
-                                      bp_std_terminate_master,
-                                     &internal_breakpoint_ops);
-      initialize_explicit_location (&explicit_loc);
-      explicit_loc.function_name = ASTRDUP (func_name);
-      b->location = new_explicit_location (&explicit_loc);
-      b->enable_state = bp_disabled;
-    }
+       addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->terminate_msym);
+       b = create_internal_breakpoint (get_objfile_arch (objfile), addr,
+                                       bp_std_terminate_master,
+                                       &internal_breakpoint_ops);
+       initialize_explicit_location (&explicit_loc);
+       explicit_loc.function_name = ASTRDUP (func_name);
+       b->location = new_explicit_location (&explicit_loc);
+       b->enable_state = bp_disabled;
+      }
   }
 }
 
@@ -3446,10 +3382,9 @@ create_std_terminate_master_breakpoint (void)
 static void
 create_exception_master_breakpoint (void)
 {
-  struct objfile *objfile;
   const char *const func_name = "_Unwind_DebugHook";
 
-  ALL_OBJFILES (objfile)
+  for (objfile *objfile : current_program_space->objfiles ())
     {
       struct breakpoint *b;
       struct gdbarch *gdbarch;
@@ -3470,7 +3405,7 @@ create_exception_master_breakpoint (void)
              /* We are only interested in checking one element.  */
              probe *p = ret[0];
 
-             if (!can_evaluate_probe_arguments (p))
+             if (!p->can_evaluate_arguments ())
                {
                  /* We cannot use the probe interface here, because it does
                     not know how to evaluate arguments.  */
@@ -3483,14 +3418,12 @@ create_exception_master_breakpoint (void)
 
       if (!bp_objfile_data->exception_probes.empty ())
        {
-         struct gdbarch *gdbarch = get_objfile_arch (objfile);
+         gdbarch = get_objfile_arch (objfile);
 
          for (probe *p : bp_objfile_data->exception_probes)
            {
-             struct breakpoint *b;
-
              b = create_internal_breakpoint (gdbarch,
-                                             get_probe_address (p, objfile),
+                                             p->get_relocated_address (objfile),
                                              bp_exception_master,
                                              &internal_breakpoint_ops);
              b->location = new_probe_location ("-probe-stap libgcc:unwind");
@@ -3523,7 +3456,7 @@ create_exception_master_breakpoint (void)
 
       addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->exception_msym);
       addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr,
-                                                &current_target);
+                                                current_top_target ());
       b = create_internal_breakpoint (gdbarch, addr, bp_exception_master,
                                      &internal_breakpoint_ops);
       initialize_explicit_location (&explicit_loc);
@@ -3671,7 +3604,7 @@ detach_breakpoints (ptid_t ptid)
   scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
   struct inferior *inf = current_inferior ();
 
-  if (ptid_get_pid (ptid) == ptid_get_pid (inferior_ptid))
+  if (ptid.pid () == inferior_ptid.pid ())
     error (_("Cannot detach breakpoints of inferior_ptid"));
 
   /* Set inferior_ptid; remove_breakpoint_1 uses this global.  */
@@ -3894,8 +3827,6 @@ void
 breakpoint_init_inferior (enum inf_context context)
 {
   struct breakpoint *b, *b_tmp;
-  struct bp_location *bl;
-  int ix;
   struct program_space *pspace = current_program_space;
 
   /* If breakpoint locations are shared across processes, then there's
@@ -3973,9 +3904,7 @@ breakpoint_init_inferior (enum inf_context context)
                {
                  /* Reset val field to force reread of starting value in
                     insert_breakpoints.  */
-                 if (w->val)
-                   value_free (w->val);
-                 w->val = NULL;
+                 w->val.reset (nullptr);
                  w->val_valid = 0;
                }
            }
@@ -3987,9 +3916,9 @@ breakpoint_init_inferior (enum inf_context context)
   }
 
   /* Get rid of the moribund locations.  */
-  for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, bl); ++ix)
+  for (bp_location *bl : moribund_locations)
     decref_bp_location (&bl);
-  VEC_free (bp_location_p, moribund_locations);
+  moribund_locations.clear ();
 }
 
 /* These functions concern about actual breakpoints inserted in the
@@ -4077,10 +4006,7 @@ breakpoint_in_range_p (const address_space *aspace,
 int
 moribund_breakpoint_here_p (const address_space *aspace, CORE_ADDR pc)
 {
-  struct bp_location *loc;
-  int ix;
-
-  for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix)
+  for (bp_location *loc : moribund_locations)
     if (breakpoint_location_address_match (loc, aspace, pc))
       return 1;
 
@@ -4221,8 +4147,6 @@ is_catchpoint (struct breakpoint *ep)
 
 bpstats::~bpstats ()
 {
-  if (old_val != NULL)
-    value_free (old_val);
   if (bp_location_at != NULL)
     decref_bp_location (&bp_location_at);
 }
@@ -4253,16 +4177,12 @@ bpstats::bpstats (const bpstats &other)
     bp_location_at (other.bp_location_at),
     breakpoint_at (other.breakpoint_at),
     commands (other.commands),
-    old_val (other.old_val),
     print (other.print),
     stop (other.stop),
     print_it (other.print_it)
 {
-  if (old_val != NULL)
-    {
-      old_val = value_copy (old_val);
-      release_value (old_val);
-    }
+  if (other.old_val != NULL)
+    old_val = release_value (value_copy (other.old_val.get ()));
   incref_bp_location (bp_location_at);
 }
 
@@ -4370,25 +4290,16 @@ bpstat_num (bpstat *bsp, int *num)
 void
 bpstat_clear_actions (void)
 {
-  struct thread_info *tp;
   bpstat bs;
 
-  if (ptid_equal (inferior_ptid, null_ptid))
-    return;
-
-  tp = find_thread_ptid (inferior_ptid);
-  if (tp == NULL)
+  if (inferior_ptid == null_ptid)
     return;
 
+  thread_info *tp = inferior_thread ();
   for (bs = tp->control.stop_bpstat; bs != NULL; bs = bs->next)
     {
       bs->commands = NULL;
-
-      if (bs->old_val != NULL)
-       {
-         value_free (bs->old_val);
-         bs->old_val = NULL;
-       }
+      bs->old_val.reset (nullptr);
     }
 }
 
@@ -4397,7 +4308,7 @@ bpstat_clear_actions (void)
 static void
 breakpoint_about_to_proceed (void)
 {
-  if (!ptid_equal (inferior_ptid, null_ptid))
+  if (inferior_ptid != null_ptid)
     {
       struct thread_info *tp = inferior_thread ();
 
@@ -4512,24 +4423,39 @@ bpstat_do_actions_1 (bpstat *bsp)
   return again;
 }
 
+/* Helper for bpstat_do_actions.  Get the current thread, if there's
+   one, is alive and has execution.  Return NULL otherwise.  */
+
+static thread_info *
+get_bpstat_thread ()
+{
+  if (inferior_ptid == null_ptid || !target_has_execution)
+    return NULL;
+
+  thread_info *tp = inferior_thread ();
+  if (tp->state == THREAD_EXITED || tp->executing)
+    return NULL;
+  return tp;
+}
+
 void
 bpstat_do_actions (void)
 {
-  struct cleanup *cleanup_if_error = make_bpstat_clear_actions_cleanup ();
+  auto cleanup_if_error = make_scope_exit (bpstat_clear_actions);
+  thread_info *tp;
 
   /* Do any commands attached to breakpoint we are stopped at.  */
-  while (!ptid_equal (inferior_ptid, null_ptid)
-        && target_has_execution
-        && !is_exited (inferior_ptid)
-        && !is_executing (inferior_ptid))
-    /* Since in sync mode, bpstat_do_actions may resume the inferior,
-       and only return when it is stopped at the next breakpoint, we
-       keep doing breakpoint actions until it returns false to
-       indicate the inferior was not resumed.  */
-    if (!bpstat_do_actions_1 (&inferior_thread ()->control.stop_bpstat))
-      break;
+  while ((tp = get_bpstat_thread ()) != NULL)
+    {
+      /* Since in sync mode, bpstat_do_actions may resume the
+        inferior, and only return when it is stopped at the next
+        breakpoint, we keep doing breakpoint actions until it returns
+        false to indicate the inferior was not resumed.  */
+      if (!bpstat_do_actions_1 (&tp->control.stop_bpstat))
+       break;
+    }
 
-  discard_cleanups (cleanup_if_error);
+  cleanup_if_error.release ();
 }
 
 /* Print out the (old or new) value associated with a watchpoint.  */
@@ -4626,10 +4552,8 @@ print_bp_stop_message (bpstat bs)
 static void
 print_solib_event (int is_catchpoint)
 {
-  int any_deleted
-    = !VEC_empty (char_ptr, current_program_space->deleted_solibs);
-  int any_added
-    = !VEC_empty (so_list_ptr, current_program_space->added_solibs);
+  bool any_deleted = !current_program_space->deleted_solibs.empty ();
+  bool any_added = !current_program_space->added_solibs.empty ();
 
   if (!is_catchpoint)
     {
@@ -4646,16 +4570,12 @@ print_solib_event (int is_catchpoint)
 
   if (any_deleted)
     {
-      char *name;
-      int ix;
-
       current_uiout->text (_("  Inferior unloaded "));
       ui_out_emit_list list_emitter (current_uiout, "removed");
-      for (ix = 0;
-          VEC_iterate (char_ptr, current_program_space->deleted_solibs,
-                       ix, name);
-          ++ix)
+      for (int ix = 0; ix < current_program_space->deleted_solibs.size (); ix++)
        {
+         const std::string &name = current_program_space->deleted_solibs[ix];
+
          if (ix > 0)
            current_uiout->text ("    ");
          current_uiout->field_string ("library", name);
@@ -4665,18 +4585,14 @@ print_solib_event (int is_catchpoint)
 
   if (any_added)
     {
-      struct so_list *iter;
-      int ix;
-
       current_uiout->text (_("  Inferior loaded "));
       ui_out_emit_list list_emitter (current_uiout, "added");
-      for (ix = 0;
-          VEC_iterate (so_list_ptr, current_program_space->added_solibs,
-                       ix, iter);
-          ++ix)
+      bool first = true;
+      for (so_list *iter : current_program_space->added_solibs)
        {
-         if (ix > 0)
+         if (!first)
            current_uiout->text ("    ");
+         first = false;
          current_uiout->field_string ("library", iter->so_name);
          current_uiout->text ("\n");
        }
@@ -4755,7 +4671,6 @@ bpstats::bpstats (struct bp_location *bl, bpstat **bs_link_pointer)
     bp_location_at (bl),
     breakpoint_at (bl->owner),
     commands (NULL),
-    old_val (NULL),
     print (0),
     stop (0),
     print_it (print_it_normal)
@@ -4770,7 +4685,6 @@ bpstats::bpstats ()
     bp_location_at (NULL),
     breakpoint_at (NULL),
     commands (NULL),
-    old_val (NULL),
     print (0),
     stop (0),
     print_it (print_it_normal)
@@ -4783,7 +4697,7 @@ bpstats::bpstats ()
 int
 watchpoints_triggered (struct target_waitstatus *ws)
 {
-  int stopped_by_watchpoint = target_stopped_by_watchpoint ();
+  bool stopped_by_watchpoint = target_stopped_by_watchpoint ();
   CORE_ADDR addr;
   struct breakpoint *b;
 
@@ -4802,7 +4716,7 @@ watchpoints_triggered (struct target_waitstatus *ws)
       return 0;
     }
 
-  if (!target_stopped_data_address (&current_target, &addr))
+  if (!target_stopped_data_address (current_top_target (), &addr))
     {
       /* We were stopped by a watchpoint, but we don't know where.
         Mark all watchpoints as unknown.  */
@@ -4842,7 +4756,7 @@ watchpoints_triggered (struct target_waitstatus *ws)
                  }
              }
            /* Exact match not required.  Within range is sufficient.  */
-           else if (target_watchpoint_addr_within_range (&current_target,
+           else if (target_watchpoint_addr_within_range (current_top_target (),
                                                         addr, loc->address,
                                                         loc->length))
              {
@@ -4965,16 +4879,14 @@ watchpoint_check (bpstat bs)
         the address of the array instead of its contents.  This is
         not what we want.  */
       if ((b->val != NULL) != (new_val != NULL)
-         || (b->val != NULL && !value_equal_contents (b->val, new_val)))
+         || (b->val != NULL && !value_equal_contents (b->val.get (),
+                                                      new_val)))
        {
-         if (new_val != NULL)
-           {
-             release_value (new_val);
-             value_free_to_mark (mark);
-           }
          bs->old_val = b->val;
-         b->val = new_val;
+         b->val = release_value (new_val);
          b->val_valid = 1;
+         if (new_val != NULL)
+           value_free_to_mark (mark);
          return WP_VALUE_CHANGED;
        }
       else
@@ -5077,11 +4989,11 @@ bpstat_check_watchpoint (bpstat bs)
        {
          wp_check_result e;
 
-         TRY
+         try
            {
              e = watchpoint_check (bs);
            }
-         CATCH (ex, RETURN_MASK_ALL)
+         catch (const gdb_exception &ex)
            {
              exception_fprintf (gdb_stderr, ex,
                                 "Error evaluating expression "
@@ -5096,7 +5008,6 @@ bpstat_check_watchpoint (bpstat bs)
              watchpoint_del_at_next_stop (b);
              e = WP_DELETED;
            }
-         END_CATCH
 
          switch (e)
            {
@@ -5214,7 +5125,7 @@ bpstat_check_watchpoint (bpstat bs)
    breakpoint, set BS->stop to 0.  */
 
 static void
-bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
+bpstat_check_breakpoint_conditions (bpstat bs, thread_info *thread)
 {
   const struct bp_location *bl;
   struct breakpoint *b;
@@ -5244,9 +5155,8 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
   /* If this is a thread/task-specific breakpoint, don't waste cpu
      evaluating the condition if this isn't the specified
      thread/task.  */
-  if ((b->thread != -1 && b->thread != ptid_to_global_thread_id (ptid))
-      || (b->task != 0 && b->task != ada_get_task_number (ptid)))
-
+  if ((b->thread != -1 && b->thread != thread->global_num)
+      || (b->task != 0 && b->task != ada_get_task_number (thread)))
     {
       bs->stop = 0;
       return;
@@ -5316,16 +5226,15 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
        }
       if (within_current_scope)
        {
-         TRY
+         try
            {
              condition_result = breakpoint_cond_eval (cond);
            }
-         CATCH (ex, RETURN_MASK_ALL)
+         catch (const gdb_exception &ex)
            {
              exception_fprintf (gdb_stderr, ex,
                                 "Error in testing breakpoint condition:\n");
            }
-         END_CATCH
        }
       else
        {
@@ -5348,7 +5257,7 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
       bs->stop = 0;
       /* Increase the hit count even though we don't stop.  */
       ++(b->hit_count);
-      observer_notify_breakpoint_modified (b);
+      gdb::observers::breakpoint_modified.notify (b);
     }  
 }
 
@@ -5364,54 +5273,21 @@ need_moribund_for_location_type (struct bp_location *loc)
              && !target_supports_stopped_by_hw_breakpoint ()));
 }
 
-
-/* Get a bpstat associated with having just stopped at address
-   BP_ADDR in thread PTID.
-
-   Determine whether we stopped at a breakpoint, etc, or whether we
-   don't understand this stop.  Result is a chain of bpstat's such
-   that:
-
-   if we don't understand the stop, the result is a null pointer.
-
-   if we understand why we stopped, the result is not null.
-
-   Each element of the chain refers to a particular breakpoint or
-   watchpoint at which we have stopped.  (We may have stopped for
-   several reasons concurrently.)
-
-   Each element of the chain has valid next, breakpoint_at,
-   commands, FIXME??? fields.  */
+/* See breakpoint.h.  */
 
 bpstat
-bpstat_stop_status (const address_space *aspace,
-                   CORE_ADDR bp_addr, ptid_t ptid,
+build_bpstat_chain (const address_space *aspace, CORE_ADDR bp_addr,
                    const struct target_waitstatus *ws)
 {
-  struct breakpoint *b = NULL;
-  struct bp_location *bl;
-  struct bp_location *loc;
-  /* First item of allocated bpstat's.  */
+  struct breakpoint *b;
   bpstat bs_head = NULL, *bs_link = &bs_head;
-  /* Pointer to the last thing in the chain currently.  */
-  bpstat bs;
-  int ix;
-  int need_remove_insert;
-  int removed_any;
-
-  /* First, build the bpstat chain with locations that explain a
-     target stop, while being careful to not set the target running,
-     as that may invalidate locations (in particular watchpoint
-     locations are recreated).  Resuming will happen here with
-     breakpoint conditions or watchpoint expressions that include
-     inferior function calls.  */
 
   ALL_BREAKPOINTS (b)
     {
       if (!breakpoint_enabled (b))
        continue;
 
-      for (bl = b->loc; bl != NULL; bl = bl->next)
+      for (bp_location *bl = b->loc; bl != NULL; bl = bl->next)
        {
          /* For hardware watchpoints, we look only at the first
             location.  The watchpoint_check function will work on the
@@ -5430,8 +5306,8 @@ bpstat_stop_status (const address_space *aspace,
          /* Come here if it's a watchpoint, or if the break address
             matches.  */
 
-         bs = new bpstats (bl, &bs_link);      /* Alloc a bpstat to
-                                                  explain stop.  */
+         bpstat bs = new bpstats (bl, &bs_link);       /* Alloc a bpstat to
+                                                          explain stop.  */
 
          /* Assume we stop.  Should we find a watchpoint that is not
             actually triggered, or if the condition of the breakpoint
@@ -5456,12 +5332,12 @@ bpstat_stop_status (const address_space *aspace,
   if (!target_supports_stopped_by_sw_breakpoint ()
       || !target_supports_stopped_by_hw_breakpoint ())
     {
-      for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix)
+      for (bp_location *loc : moribund_locations)
        {
          if (breakpoint_location_address_match (loc, aspace, bp_addr)
              && need_moribund_for_location_type (loc))
            {
-             bs = new bpstats (loc, &bs_link);
+             bpstat bs = new bpstats (loc, &bs_link);
              /* For hits of moribund locations, we should just proceed.  */
              bs->stop = 0;
              bs->print = 0;
@@ -5470,6 +5346,33 @@ bpstat_stop_status (const address_space *aspace,
        }
     }
 
+  return bs_head;
+}
+
+/* See breakpoint.h.  */
+
+bpstat
+bpstat_stop_status (const address_space *aspace,
+                   CORE_ADDR bp_addr, thread_info *thread,
+                   const struct target_waitstatus *ws,
+                   bpstat stop_chain)
+{
+  struct breakpoint *b = NULL;
+  /* First item of allocated bpstat's.  */
+  bpstat bs_head = stop_chain;
+  bpstat bs;
+  int need_remove_insert;
+  int removed_any;
+
+  /* First, build the bpstat chain with locations that explain a
+     target stop, while being careful to not set the target running,
+     as that may invalidate locations (in particular watchpoint
+     locations are recreated).  Resuming will happen here with
+     breakpoint conditions or watchpoint expressions that include
+     inferior function calls.  */
+  if (bs_head == NULL)
+    bs_head = build_bpstat_chain (aspace, bp_addr, ws);
+
   /* A bit of special processing for shlib breakpoints.  We need to
      process solib loading here, so that the lists of loaded and
      unloaded libraries are correct before we handle "catch load" and
@@ -5498,12 +5401,12 @@ bpstat_stop_status (const address_space *aspace,
       b->ops->check_status (bs);
       if (bs->stop)
        {
-         bpstat_check_breakpoint_conditions (bs, ptid);
+         bpstat_check_breakpoint_conditions (bs, thread);
 
          if (bs->stop)
            {
              ++(b->hit_count);
-             observer_notify_breakpoint_modified (b);
+             gdb::observers::breakpoint_modified.notify (b);
 
              /* We will stop here.  */
              if (b->disposition == disp_disable)
@@ -5921,19 +5824,18 @@ print_breakpoint_location (struct breakpoint *b,
     {
       const struct symbol *sym = loc->symbol;
 
-      if (sym == NULL)
-       sym = find_pc_sect_function (loc->address, loc->section);
-
       if (sym)
        {
          uiout->text ("in ");
-         uiout->field_string ("func", SYMBOL_PRINT_NAME (sym));
+         uiout->field_string ("func", SYMBOL_PRINT_NAME (sym),
+                              ui_out_style_kind::FUNCTION);
          uiout->text (" ");
          uiout->wrap_hint (wrap_indent_at_field (uiout, "what"));
          uiout->text ("at ");
        }
       uiout->field_string ("file",
-                          symtab_to_filename_for_display (loc->symtab));
+                          symtab_to_filename_for_display (loc->symtab),
+                          ui_out_style_kind::FILE);
       uiout->text (":");
 
       if (uiout->is_mi_like_p ())
@@ -6038,12 +5940,10 @@ bptype_string (enum bptype type)
 static void
 output_thread_groups (struct ui_out *uiout,
                      const char *field_name,
-                     VEC(int) *inf_num,
+                     const std::vector<int> &inf_nums,
                      int mi_only)
 {
   int is_mi = uiout->is_mi_like_p ();
-  int inf;
-  int i;
 
   /* For backward compatibility, don't display inferiors in CLI unless
      there are several.  Always display them for MI. */
@@ -6052,13 +5952,13 @@ output_thread_groups (struct ui_out *uiout,
 
   ui_out_emit_list list_emitter (uiout, field_name);
 
-  for (i = 0; VEC_iterate (int, inf_num, i, inf); ++i)
+  for (size_t i = 0; i < inf_nums.size (); i++)
     {
       if (is_mi)
        {
          char mi_group[10];
 
-         xsnprintf (mi_group, sizeof (mi_group), "i%d", inf);
+         xsnprintf (mi_group, sizeof (mi_group), "i%d", inf_nums[i]);
          uiout->field_string (NULL, mi_group);
        }
       else
@@ -6068,7 +5968,7 @@ output_thread_groups (struct ui_out *uiout,
          else
            uiout->text (", ");
        
-         uiout->text (plongest (inf));
+         uiout->text (plongest (inf_nums[i]));
        }
     }
 }
@@ -6107,16 +6007,9 @@ print_one_breakpoint_location (struct breakpoint *b,
   /* 1 */
   annotate_field (0);
   if (part_of_multiple)
-    {
-      char *formatted;
-      formatted = xstrprintf ("%d.%d", b->number, loc_number);
-      uiout->field_string ("number", formatted);
-      xfree (formatted);
-    }
+    uiout->field_fmt ("number", "%d.%d", b->number, loc_number);
   else
-    {
-      uiout->field_int ("number", b->number);
-    }
+    uiout->field_int ("number", b->number);
 
   /* 2 */
   annotate_field (1);
@@ -6132,16 +6025,13 @@ print_one_breakpoint_location (struct breakpoint *b,
   else
     uiout->field_string ("disp", bpdisp_text (b->disposition));
 
-
   /* 4 */
   annotate_field (3);
   if (part_of_multiple)
     uiout->field_string ("enabled", loc->enabled ? "y" : "n");
   else
     uiout->field_fmt ("enabled", "%c", bpenables[(int) b->enable_state]);
-  uiout->spaces (2);
 
-  
   /* 5 and 6 */
   if (b->ops != NULL && b->ops->print_one != NULL)
     {
@@ -6226,14 +6116,13 @@ print_one_breakpoint_location (struct breakpoint *b,
 
   if (loc != NULL && !header_of_multiple)
     {
-      struct inferior *inf;
-      VEC(int) *inf_num = NULL;
+      std::vector<int> inf_nums;
       int mi_only = 1;
 
-      ALL_INFERIORS (inf)
+      for (inferior *inf : all_inferiors ())
        {
          if (inf->pspace == loc->pspace)
-           VEC_safe_push (int, inf_num, inf->num);
+           inf_nums.push_back (inf->num);
        }
 
         /* For backward compatibility, don't display inferiors in CLI unless
@@ -6246,8 +6135,7 @@ print_one_breakpoint_location (struct breakpoint *b,
                   moribund_locations and thus having NULL OWNER.  */
                && loc->owner->type != bp_catchpoint))
        mi_only = 0;
-      output_thread_groups (uiout, "thread-groups", inf_num, mi_only);
-      VEC_free (int, inf_num);
+      output_thread_groups (uiout, "thread-groups", inf_nums, mi_only);
     }
 
   if (!part_of_multiple)
@@ -6438,18 +6326,27 @@ print_one_breakpoint_location (struct breakpoint *b,
     }
 }
 
+/* See breakpoint.h. */
+
+bool fix_multi_location_breakpoint_output_globally = false;
+
 static void
 print_one_breakpoint (struct breakpoint *b,
                      struct bp_location **last_loc, 
                      int allflag)
 {
   struct ui_out *uiout = current_uiout;
+  bool use_fixed_output
+    = (uiout->test_flags (fix_multi_location_breakpoint_output)
+       || fix_multi_location_breakpoint_output_globally);
 
-  {
-    ui_out_emit_tuple tuple_emitter (uiout, "bkpt");
+  gdb::optional<ui_out_emit_tuple> bkpt_tuple_emitter (gdb::in_place, uiout, "bkpt");
+  print_one_breakpoint_location (b, NULL, 0, last_loc, allflag);
 
-    print_one_breakpoint_location (b, NULL, 0, last_loc, allflag);
-  }
+  /* The mi2 broken format: the main breakpoint tuple ends here, the locations
+     are outside.  */
+  if (!use_fixed_output)
+    bkpt_tuple_emitter.reset ();
 
   /* If this breakpoint has custom print function,
      it's already printed.  Otherwise, print individual
@@ -6467,12 +6364,18 @@ print_one_breakpoint (struct breakpoint *b,
          && !is_hardware_watchpoint (b)
          && (b->loc->next || !b->loc->enabled))
        {
-         struct bp_location *loc;
-         int n = 1;
+         gdb::optional<ui_out_emit_list> locations_list;
 
-         for (loc = b->loc; loc; loc = loc->next, ++n)
+         /* For MI version <= 2, keep the behavior where GDB outputs an invalid
+            MI record.  For later versions, place breakpoint locations in a
+            list.  */
+         if (uiout->is_mi_like_p () && use_fixed_output)
+           locations_list.emplace (uiout, "locations");
+
+         int n = 1;
+         for (bp_location *loc = b->loc; loc != NULL; loc = loc->next, ++n)
            {
-             ui_out_emit_tuple tuple_emitter (uiout, NULL);
+             ui_out_emit_tuple loc_tuple_emitter (uiout, NULL);
              print_one_breakpoint_location (b, loc, n, last_loc, allflag);
            }
        }
@@ -6705,16 +6608,8 @@ info_breakpoints_command (const char *args, int from_tty)
   default_collect_info ();
 }
 
-/* Temporary non-const overload.  */
-
-static void
-info_breakpoints_command (char *args, int from_tty)
-{
-  info_breakpoints_command ((const char *) args, from_tty);
-}
-
 static void
-info_watchpoints_command (char *args, int from_tty)
+info_watchpoints_command (const char *args, int from_tty)
 {
   int num_printed = breakpoint_1 (args, 0, is_watchpoint);
   struct ui_out *uiout = current_uiout;
@@ -6792,7 +6687,7 @@ describe_other_breakpoints (struct gdbarch *gdbarch,
                             : ((others == 1) ? " and" : ""));
          }
       printf_filtered (_("also set at pc "));
-      fputs_filtered (paddress (gdbarch, pc), gdb_stdout);
+      fputs_styled (paddress (gdbarch, pc), address_style.style (), gdb_stdout);
       printf_filtered (".\n");
     }
 }
@@ -7006,16 +6901,11 @@ static CORE_ADDR
 adjust_breakpoint_address (struct gdbarch *gdbarch,
                           CORE_ADDR bpaddr, enum bptype bptype)
 {
-  if (!gdbarch_adjust_breakpoint_address_p (gdbarch))
-    {
-      /* Very few targets need any kind of breakpoint adjustment.  */
-      return bpaddr;
-    }
-  else if (bptype == bp_watchpoint
-           || bptype == bp_hardware_watchpoint
-           || bptype == bp_read_watchpoint
-           || bptype == bp_access_watchpoint
-           || bptype == bp_catchpoint)
+  if (bptype == bp_watchpoint
+      || bptype == bp_hardware_watchpoint
+      || bptype == bp_read_watchpoint
+      || bptype == bp_access_watchpoint
+      || bptype == bp_catchpoint)
     {
       /* Watchpoints and the various bp_catch_* eventpoints should not
          have their addresses modified.  */
@@ -7033,11 +6923,16 @@ adjust_breakpoint_address (struct gdbarch *gdbarch,
     }
   else
     {
-      CORE_ADDR adjusted_bpaddr;
+      CORE_ADDR adjusted_bpaddr = bpaddr;
+
+      if (gdbarch_adjust_breakpoint_address_p (gdbarch))
+       {
+         /* Some targets have architectural constraints on the placement
+            of breakpoint instructions.  Obtain the adjusted address.  */
+         adjusted_bpaddr = gdbarch_adjust_breakpoint_address (gdbarch, bpaddr);
+       }
 
-      /* Some targets have architectural constraints on the placement
-         of breakpoint instructions.  Obtain the adjusted address.  */
-      adjusted_bpaddr = gdbarch_adjust_breakpoint_address (gdbarch, bpaddr);
+      adjusted_bpaddr = address_significant (gdbarch, adjusted_bpaddr);
 
       /* An adjusted breakpoint address can significantly alter
          a user's expectations.  Print a warning if an adjustment
@@ -7049,13 +6944,10 @@ adjust_breakpoint_address (struct gdbarch *gdbarch,
     }
 }
 
-bp_location::bp_location (const bp_location_ops *ops, breakpoint *owner)
+bp_location::bp_location (breakpoint *owner)
 {
   bp_location *loc = this;
 
-  gdb_assert (ops != NULL);
-
-  loc->ops = ops;
   loc->owner = owner;
   loc->cond_bytecode = NULL;
   loc->shlib_disabled = 0;
@@ -7124,7 +7016,6 @@ allocate_bp_location (struct breakpoint *bpt)
 static void
 free_bp_location (struct bp_location *loc)
 {
-  loc->ops->dtor (loc);
   delete loc;
 }
 
@@ -7218,37 +7109,30 @@ set_breakpoint_location_function (struct bp_location *loc, int explicit_loc)
       || loc->owner->type == bp_hardware_breakpoint
       || is_tracepoint (loc->owner))
     {
-      int is_gnu_ifunc;
       const char *function_name;
-      CORE_ADDR func_addr;
 
-      find_pc_partial_function_gnu_ifunc (loc->address, &function_name,
-                                         &func_addr, NULL, &is_gnu_ifunc);
-
-      if (is_gnu_ifunc && !explicit_loc)
+      if (loc->msymbol != NULL
+         && (MSYMBOL_TYPE (loc->msymbol) == mst_text_gnu_ifunc
+             || MSYMBOL_TYPE (loc->msymbol) == mst_data_gnu_ifunc)
+         && !explicit_loc)
        {
          struct breakpoint *b = loc->owner;
 
-         gdb_assert (loc->pspace == current_program_space);
-         if (gnu_ifunc_resolve_name (function_name,
-                                     &loc->requested_address))
-           {
-             /* Recalculate ADDRESS based on new REQUESTED_ADDRESS.  */
-             loc->address = adjust_breakpoint_address (loc->gdbarch,
-                                                       loc->requested_address,
-                                                       b->type);
-           }
-         else if (b->type == bp_breakpoint && b->loc == loc
-                  && loc->next == NULL && b->related_breakpoint == b)
+         function_name = MSYMBOL_LINKAGE_NAME (loc->msymbol);
+
+         if (b->type == bp_breakpoint && b->loc == loc
+             && loc->next == NULL && b->related_breakpoint == b)
            {
              /* Create only the whole new breakpoint of this type but do not
                 mess more complicated breakpoints with multiple locations.  */
              b->type = bp_gnu_ifunc_resolver;
              /* Remember the resolver's address for use by the return
                 breakpoint.  */
-             loc->related_address = func_addr;
+             loc->related_address = loc->address;
            }
        }
+      else
+       find_pc_partial_function (loc->address, &function_name, NULL, NULL);
 
       if (function_name)
        loc->function_name = xstrdup (function_name);
@@ -7397,7 +7281,7 @@ set_longjmp_breakpoint_for_call_dummy (void)
        new_b = momentary_breakpoint_from_master (b, bp_longjmp_call_dummy,
                                                  &momentary_breakpoint_ops,
                                                  1);
-       new_b->thread = ptid_to_global_thread_id (inferior_ptid);
+       new_b->thread = inferior_thread ()->global_num;
 
        /* Link NEW_B into the chain of RETVAL breakpoints.  */
 
@@ -7437,7 +7321,7 @@ check_longjmp_breakpoint_for_call_dummy (struct thread_info *tp)
            || frame_find_by_id (dummy_b->frame_id) != NULL)
          continue;
        
-       dummy_frame_discard (dummy_b->frame_id, tp->ptid);
+       dummy_frame_discard (dummy_b->frame_id, tp);
 
        while (b->related_breakpoint != b)
          {
@@ -7677,7 +7561,7 @@ disable_breakpoints_in_unloaded_shlib (struct so_list *solib)
        loc->inserted = 0;
 
        /* This may cause duplicate notifications for the same breakpoint.  */
-       observer_notify_breakpoint_modified (b);
+       gdb::observers::breakpoint_modified.notify (b);
 
        if (!disabled_shlib_breaks)
          {
@@ -7760,7 +7644,7 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile)
        }
 
       if (bp_modified)
-       observer_notify_breakpoint_modified (b);
+       gdb::observers::breakpoint_modified.notify (b);
     }
 }
 
@@ -7784,7 +7668,7 @@ struct fork_catchpoint : public breakpoint
 static int
 insert_catch_fork (struct bp_location *bl)
 {
-  return target_insert_fork_catchpoint (ptid_get_pid (inferior_ptid));
+  return target_insert_fork_catchpoint (inferior_ptid.pid ());
 }
 
 /* Implement the "remove" breakpoint_ops method for fork
@@ -7793,7 +7677,7 @@ insert_catch_fork (struct bp_location *bl)
 static int
 remove_catch_fork (struct bp_location *bl, enum remove_bp_reason reason)
 {
-  return target_remove_fork_catchpoint (ptid_get_pid (inferior_ptid));
+  return target_remove_fork_catchpoint (inferior_ptid.pid ());
 }
 
 /* Implement the "breakpoint_hit" breakpoint_ops method for fork
@@ -7836,7 +7720,7 @@ print_it_catch_fork (bpstat bs)
     }
   uiout->field_int ("bkptno", b->number);
   uiout->text (" (forked process ");
-  uiout->field_int ("newpid", ptid_get_pid (c->forked_inferior_pid));
+  uiout->field_int ("newpid", c->forked_inferior_pid.pid ());
   uiout->text ("), ");
   return PRINT_SRC_AND_LOC;
 }
@@ -7860,10 +7744,10 @@ print_one_catch_fork (struct breakpoint *b, struct bp_location **last_loc)
     uiout->field_skip ("addr");
   annotate_field (5);
   uiout->text ("fork");
-  if (!ptid_equal (c->forked_inferior_pid, null_ptid))
+  if (c->forked_inferior_pid != null_ptid)
     {
       uiout->text (", process ");
-      uiout->field_int ("what", ptid_get_pid (c->forked_inferior_pid));
+      uiout->field_int ("what", c->forked_inferior_pid.pid ());
       uiout->spaces (1);
     }
 
@@ -7900,7 +7784,7 @@ static struct breakpoint_ops catch_fork_breakpoint_ops;
 static int
 insert_catch_vfork (struct bp_location *bl)
 {
-  return target_insert_vfork_catchpoint (ptid_get_pid (inferior_ptid));
+  return target_insert_vfork_catchpoint (inferior_ptid.pid ());
 }
 
 /* Implement the "remove" breakpoint_ops method for vfork
@@ -7909,7 +7793,7 @@ insert_catch_vfork (struct bp_location *bl)
 static int
 remove_catch_vfork (struct bp_location *bl, enum remove_bp_reason reason)
 {
-  return target_remove_vfork_catchpoint (ptid_get_pid (inferior_ptid));
+  return target_remove_vfork_catchpoint (inferior_ptid.pid ());
 }
 
 /* Implement the "breakpoint_hit" breakpoint_ops method for vfork
@@ -7952,7 +7836,7 @@ print_it_catch_vfork (bpstat bs)
     }
   uiout->field_int ("bkptno", b->number);
   uiout->text (" (vforked process ");
-  uiout->field_int ("newpid", ptid_get_pid (c->forked_inferior_pid));
+  uiout->field_int ("newpid", c->forked_inferior_pid.pid ());
   uiout->text ("), ");
   return PRINT_SRC_AND_LOC;
 }
@@ -7975,10 +7859,10 @@ print_one_catch_vfork (struct breakpoint *b, struct bp_location **last_loc)
     uiout->field_skip ("addr");
   annotate_field (5);
   uiout->text ("vfork");
-  if (!ptid_equal (c->forked_inferior_pid, null_ptid))
+  if (c->forked_inferior_pid != null_ptid)
     {
       uiout->text (", process ");
-      uiout->field_int ("what", ptid_get_pid (c->forked_inferior_pid));
+      uiout->field_int ("what", c->forked_inferior_pid.pid ());
       uiout->spaces (1);
     }
 
@@ -8083,16 +7967,10 @@ check_status_catch_solib (struct bpstats *bs)
 {
   struct solib_catchpoint *self
     = (struct solib_catchpoint *) bs->breakpoint_at;
-  int ix;
 
   if (self->is_load)
     {
-      struct so_list *iter;
-
-      for (ix = 0;
-          VEC_iterate (so_list_ptr, current_program_space->added_solibs,
-                       ix, iter);
-          ++ix)
+      for (so_list *iter : current_program_space->added_solibs)
        {
          if (!self->regex
              || self->compiled->exec (iter->so_name, 0, NULL, 0) == 0)
@@ -8101,15 +7979,10 @@ check_status_catch_solib (struct bpstats *bs)
     }
   else
     {
-      char *iter;
-
-      for (ix = 0;
-          VEC_iterate (char_ptr, current_program_space->deleted_solibs,
-                       ix, iter);
-          ++ix)
+      for (const std::string &iter : current_program_space->deleted_solibs)
        {
          if (!self->regex
-             || self->compiled->exec (iter, 0, NULL, 0) == 0)
+             || self->compiled->exec (iter.c_str (), 0, NULL, 0) == 0)
            return;
        }
     }
@@ -8144,7 +8017,6 @@ print_one_catch_solib (struct breakpoint *b, struct bp_location **locs)
   struct solib_catchpoint *self = (struct solib_catchpoint *) b;
   struct value_print_options opts;
   struct ui_out *uiout = current_uiout;
-  char *msg;
 
   get_user_print_options (&opts);
   /* Field 4, the address, is omitted (which makes the columns not
@@ -8156,23 +8028,23 @@ print_one_catch_solib (struct breakpoint *b, struct bp_location **locs)
       uiout->field_skip ("addr");
     }
 
+  std::string msg;
   annotate_field (5);
   if (self->is_load)
     {
       if (self->regex)
-       msg = xstrprintf (_("load of library matching %s"), self->regex);
+       msg = string_printf (_("load of library matching %s"), self->regex);
       else
-       msg = xstrdup (_("load of library"));
+       msg = _("load of library");
     }
   else
     {
       if (self->regex)
-       msg = xstrprintf (_("unload of library matching %s"), self->regex);
+       msg = string_printf (_("unload of library matching %s"), self->regex);
       else
-       msg = xstrdup (_("unload of library"));
+       msg = _("unload of library");
     }
   uiout->field_string ("what", msg);
-  xfree (msg);
 
   if (uiout->is_mi_like_p ())
     uiout->field_string ("catch-type", self->is_load ? "load" : "unload");
@@ -8240,7 +8112,7 @@ add_solib_catchpoint (const char *arg, int is_load, int is_temp, int enabled)
    "catch unload".  */
 
 static void
-catch_load_or_unload (char *arg, int from_tty, int is_load,
+catch_load_or_unload (const char *arg, int from_tty, int is_load,
                      struct cmd_list_element *command)
 {
   int tempflag;
@@ -8252,14 +8124,14 @@ catch_load_or_unload (char *arg, int from_tty, int is_load,
 }
 
 static void
-catch_load_command_1 (char *arg, int from_tty,
+catch_load_command_1 (const char *arg, int from_tty,
                      struct cmd_list_element *command)
 {
   catch_load_or_unload (arg, from_tty, 1, command);
 }
 
 static void
-catch_unload_command_1 (char *arg, int from_tty,
+catch_unload_command_1 (const char *arg, int from_tty,
                        struct cmd_list_element *command)
 {
   catch_load_or_unload (arg, from_tty, 0, command);
@@ -8294,7 +8166,7 @@ install_breakpoint (int internal, std::unique_ptr<breakpoint> &&arg, int update_
     set_tracepoint_count (breakpoint_count);
   if (!internal)
     mention (b);
-  observer_notify_breakpoint_created (b);
+  gdb::observers::breakpoint_created.notify (b);
 
   if (update_gll)
     update_global_location_list (UGLL_MAY_INSERT);
@@ -8340,13 +8212,13 @@ exec_catchpoint::~exec_catchpoint ()
 static int
 insert_catch_exec (struct bp_location *bl)
 {
-  return target_insert_exec_catchpoint (ptid_get_pid (inferior_ptid));
+  return target_insert_exec_catchpoint (inferior_ptid.pid ());
 }
 
 static int
 remove_catch_exec (struct bp_location *bl, enum remove_bp_reason reason)
 {
-  return target_remove_exec_catchpoint (ptid_get_pid (inferior_ptid));
+  return target_remove_exec_catchpoint (inferior_ptid.pid ());
 }
 
 static int
@@ -8589,11 +8461,7 @@ set_momentary_breakpoint (struct gdbarch *gdbarch, struct symtab_and_line sal,
   b->disposition = disp_donttouch;
   b->frame_id = frame_id;
 
-  /* If we're debugging a multi-threaded program, then we want
-     momentary breakpoints to be active in only a single thread of
-     control.  */
-  if (in_thread_list (inferior_ptid))
-    b->thread = ptid_to_global_thread_id (inferior_ptid);
+  b->thread = inferior_thread ()->global_num;
 
   update_global_location_list_nothrow (UGLL_MAY_INSERT);
 
@@ -8671,9 +8539,7 @@ static void
 mention (struct breakpoint *b)
 {
   b->ops->print_mention (b);
-  if (current_uiout->is_mi_like_p ())
-    return;
-  printf_filtered ("\n");
+  current_uiout->text ("\n");
 }
 \f
 
@@ -8710,7 +8576,7 @@ add_location_to_breakpoint (struct breakpoint *b,
   loc->requested_address = sal->pc;
   loc->address = adjusted_address;
   loc->pspace = sal->pspace;
-  loc->probe.probe = sal->probe;
+  loc->probe.prob = sal->prob;
   loc->probe.objfile = sal->objfile;
   gdb_assert (loc->pspace != NULL);
   loc->section = sal->section;
@@ -8718,6 +8584,8 @@ add_location_to_breakpoint (struct breakpoint *b,
   loc->line_number = sal->line;
   loc->symtab = sal->symtab;
   loc->symbol = sal->symbol;
+  loc->msymbol = sal->msymbol;
+  loc->objfile = sal->objfile;
 
   set_breakpoint_location_function (loc,
                                    sal->explicit_pc || sal->explicit_line);
@@ -8849,25 +8717,19 @@ update_dprintf_command_list (struct breakpoint *b)
                    _("Invalid dprintf style."));
 
   gdb_assert (printf_line != NULL);
-  /* Manufacture a printf sequence.  */
-  {
-    struct command_line *printf_cmd_line = XNEW (struct command_line);
 
-    printf_cmd_line->control_type = simple_control;
-    printf_cmd_line->body_count = 0;
-    printf_cmd_line->body_list = NULL;
-    printf_cmd_line->next = NULL;
-    printf_cmd_line->line = printf_line;
-
-    breakpoint_set_commands (b, command_line_up (printf_cmd_line));
-  }
+  /* Manufacture a printf sequence.  */
+  struct command_line *printf_cmd_line
+    = new struct command_line (simple_control, printf_line);
+  breakpoint_set_commands (b, counted_command_line (printf_cmd_line,
+                                                   command_lines_deleter ()));
 }
 
 /* Update all dprintf commands, making their command lists reflect
    current style settings.  */
 
 static void
-update_dprintf_commands (char *args, int from_tty,
+update_dprintf_commands (const char *args, int from_tty,
                         struct cmd_list_element *c)
 {
   struct breakpoint *b;
@@ -8956,27 +8818,24 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
                  const char *p
                    = &event_location_to_string (b->location.get ())[3];
                  const char *endp;
-                 char *marker_str;
 
                  p = skip_spaces (p);
 
                  endp = skip_to_space (p);
 
-                 marker_str = savestring (p, endp - p);
-                 t->static_trace_marker_id = marker_str;
+                 t->static_trace_marker_id.assign (p, endp - p);
 
                  printf_filtered (_("Probed static tracepoint "
                                     "marker \"%s\"\n"),
-                                  t->static_trace_marker_id);
+                                  t->static_trace_marker_id.c_str ());
                }
              else if (target_static_tracepoint_marker_at (sal.pc, &marker))
                {
-                 t->static_trace_marker_id = xstrdup (marker.str_id);
-                 release_static_tracepoint_marker (&marker);
+                 t->static_trace_marker_id = std::move (marker.str_id);
 
                  printf_filtered (_("Probed static tracepoint "
                                     "marker \"%s\"\n"),
-                                  t->static_trace_marker_id);
+                                  t->static_trace_marker_id.c_str ());
                }
              else
                warning (_("Couldn't determine the static "
@@ -9118,9 +8977,9 @@ parse_breakpoint_sals (const struct event_location *location,
 
   if (event_location_type (location) == LINESPEC_LOCATION)
     {
-      const char *address = get_linespec_location (location);
+      const char *spec = get_linespec_location (location)->spec_string;
 
-      if (address == NULL)
+      if (spec == NULL)
        {
          /* The last displayed codepoint, if it's valid, is our default
             breakpoint address.  */
@@ -9166,15 +9025,15 @@ parse_breakpoint_sals (const struct event_location *location,
   cursal = get_current_source_symtab_and_line ();
   if (last_displayed_sal_is_valid ())
     {
-      const char *address = NULL;
+      const char *spec = NULL;
 
       if (event_location_type (location) == LINESPEC_LOCATION)
-       address = get_linespec_location (location);
+       spec = get_linespec_location (location)->spec_string;
 
       if (!cursal.symtab
-         || (address != NULL
-             && strchr ("+-", address[0]) != NULL
-             && address[1] != '['))
+         || (spec != NULL
+             && strchr ("+-", spec[0]) != NULL
+             && spec[1] != '['))
        {
          decode_line_full (location, DECODE_LINE_FUNFIRSTLINE, NULL,
                            get_last_displayed_symtab (),
@@ -9210,10 +9069,6 @@ static void
 check_fast_tracepoint_sals (struct gdbarch *gdbarch,
                            gdb::array_view<const symtab_and_line> sals)
 {
-  int rslt;
-  char *msg;
-  struct cleanup *old_chain;
-
   for (const auto &sal : sals)
     {
       struct gdbarch *sarch;
@@ -9223,14 +9078,10 @@ check_fast_tracepoint_sals (struct gdbarch *gdbarch,
         associated with SAL.  */
       if (sarch == NULL)
        sarch = gdbarch;
-      rslt = gdbarch_fast_tracepoint_valid_at (sarch, sal.pc, &msg);
-      old_chain = make_cleanup (xfree, msg);
-
-      if (!rslt)
+      std::string msg;
+      if (!gdbarch_fast_tracepoint_valid_at (sarch, sal.pc, &msg))
        error (_("May not have a fast tracepoint at %s%s"),
-              paddress (sarch, sal.pc), (msg ? msg : ""));
-
-      do_cleanups (old_chain);
+              paddress (sarch, sal.pc), msg.c_str ());
     }
 }
 
@@ -9316,10 +9167,8 @@ find_condition_and_thread (const char *tok, CORE_ADDR pc,
 static std::vector<symtab_and_line>
 decode_static_tracepoint_spec (const char **arg_p)
 {
-  VEC(static_tracepoint_marker_p) *markers = NULL;
   const char *p = &(*arg_p)[3];
   const char *endp;
-  int i;
 
   p = skip_spaces (p);
 
@@ -9327,26 +9176,21 @@ decode_static_tracepoint_spec (const char **arg_p)
 
   std::string marker_str (p, endp - p);
 
-  markers = target_static_tracepoint_markers_by_strid (marker_str.c_str ());
-  if (VEC_empty(static_tracepoint_marker_p, markers))
+  std::vector<static_tracepoint_marker> markers
+    = target_static_tracepoint_markers_by_strid (marker_str.c_str ());
+  if (markers.empty ())
     error (_("No known static tracepoint marker named %s"),
           marker_str.c_str ());
 
   std::vector<symtab_and_line> sals;
-  sals.reserve (VEC_length(static_tracepoint_marker_p, markers));
+  sals.reserve (markers.size ());
 
-  for (i = 0; i < VEC_length(static_tracepoint_marker_p, markers); i++)
+  for (const static_tracepoint_marker &marker : markers)
     {
-      struct static_tracepoint_marker *marker;
-
-      marker = VEC_index (static_tracepoint_marker_p, markers, i);
-
-      symtab_and_line sal = find_pc_line (marker->address, 0);
-      sal.pc = marker->address;
+      symtab_and_line sal = find_pc_line (marker.address, 0);
+      sal.pc = marker.address;
       sals.push_back (sal);
-
-      release_static_tracepoint_marker (marker);
-    }
+   }
 
   *arg_p = endp;
   return sals;
@@ -9368,7 +9212,6 @@ create_breakpoint (struct gdbarch *gdbarch,
                   unsigned flags)
 {
   struct linespec_result canonical;
-  struct cleanup *bkpt_chain = NULL;
   int pending = 0;
   int task = 0;
   int prev_bkpt_count = breakpoint_count;
@@ -9379,11 +9222,11 @@ create_breakpoint (struct gdbarch *gdbarch,
   if (extra_string != NULL && *extra_string == '\0')
     extra_string = NULL;
 
-  TRY
+  try
     {
       ops->create_sals_from_location (location, &canonical, type_wanted);
     }
-  CATCH (e, RETURN_MASK_ERROR)
+  catch (const gdb_exception_error &e)
     {
       /* If caller is interested in rc value from parse, set
         value.  */
@@ -9393,7 +9236,7 @@ create_breakpoint (struct gdbarch *gdbarch,
             error.  */
 
          if (pending_break_support == AUTO_BOOLEAN_FALSE)
-           throw_exception (e);
+           throw;
 
          exception_print (gdb_stderr, e);
 
@@ -9411,19 +9254,12 @@ create_breakpoint (struct gdbarch *gdbarch,
          pending = 1;
        }
       else
-       throw_exception (e);
+       throw;
     }
-  END_CATCH
 
   if (!pending && canonical.lsals.empty ())
     return 0;
 
-  /* ----------------------------- SNIP -----------------------------
-     Anything added to the cleanup chain beyond this point is assumed
-     to be part of a breakpoint.  If the breakpoint create succeeds
-     then the memory is not reclaimed.  */
-  bkpt_chain = make_cleanup (null_cleanup, 0);
-
   /* Resolve all line numbers to PC's and verify that the addresses
      are ok for the target.  */
   if (!pending)
@@ -9522,11 +9358,6 @@ create_breakpoint (struct gdbarch *gdbarch,
       prev_breakpoint_count = prev_bkpt_count;
     }
 
-  /* That's it.  Discard the cleanups for data inserted into the
-     breakpoint.  */
-  discard_cleanups (bkpt_chain);
-
-  /* error call may happen here - have BKPT_CHAIN already discarded.  */
   update_global_location_list (UGLL_MAY_INSERT);
 
   return 1;
@@ -9717,7 +9548,7 @@ stopat_command (const char *arg, int from_tty)
     }
 
   if (badInput)
-    printf_filtered (_("Usage: stop at <line>\n"));
+    printf_filtered (_("Usage: stop at LINE\n"));
   else
     break_command_1 (arg, 0, from_tty);
 }
@@ -9886,12 +9717,9 @@ print_mention_ranged_breakpoint (struct breakpoint *b)
   gdb_assert (bl);
   gdb_assert (b->type == bp_hardware_breakpoint);
 
-  if (uiout->is_mi_like_p ())
-    return;
-
-  printf_filtered (_("Hardware assisted ranged breakpoint %d from %s to %s."),
-                  b->number, paddress (bl->gdbarch, bl->address),
-                  paddress (bl->gdbarch, bl->address + bl->length - 1));
+  uiout->message (_("Hardware assisted ranged breakpoint %d from %s to %s."),
+                 b->number, paddress (bl->gdbarch, bl->address),
+                 paddress (bl->gdbarch, bl->address + bl->length - 1));
 }
 
 /* Implement the "print_recreate" breakpoint_ops method for
@@ -10041,7 +9869,7 @@ break_range_command (const char *arg, int from_tty)
   b->loc->length = length;
 
   mention (b);
-  observer_notify_breakpoint_created (b);
+  gdb::observers::breakpoint_created.notify (b);
   update_global_location_list (UGLL_MAY_INSERT);
 }
 
@@ -10164,7 +9992,6 @@ watchpoint::~watchpoint ()
 {
   xfree (this->exp_string);
   xfree (this->exp_string_reparse);
-  value_free (this->val);
 }
 
 /* Implement the "re_set" breakpoint_ops method for watchpoints.  */
@@ -10306,10 +10133,10 @@ print_it_watchpoint (bpstat bs)
       mention (b);
       tuple_emitter.emplace (uiout, "value");
       uiout->text ("\nOld value = ");
-      watchpoint_value_print (bs->old_val, &stb);
+      watchpoint_value_print (bs->old_val.get (), &stb);
       uiout->field_stream ("old", stb);
       uiout->text ("\nNew value = ");
-      watchpoint_value_print (w->val, &stb);
+      watchpoint_value_print (w->val.get (), &stb);
       uiout->field_stream ("new", stb);
       uiout->text ("\n");
       /* More than one watchpoint may have been triggered.  */
@@ -10323,7 +10150,7 @@ print_it_watchpoint (bpstat bs)
       mention (b);
       tuple_emitter.emplace (uiout, "value");
       uiout->text ("\nValue = ");
-      watchpoint_value_print (w->val, &stb);
+      watchpoint_value_print (w->val.get (), &stb);
       uiout->field_stream ("value", stb);
       uiout->text ("\n");
       result = PRINT_UNKNOWN;
@@ -10339,7 +10166,7 @@ print_it_watchpoint (bpstat bs)
          mention (b);
          tuple_emitter.emplace (uiout, "value");
          uiout->text ("\nOld value = ");
-         watchpoint_value_print (bs->old_val, &stb);
+         watchpoint_value_print (bs->old_val.get (), &stb);
          uiout->field_stream ("old", stb);
          uiout->text ("\nNew value = ");
        }
@@ -10353,7 +10180,7 @@ print_it_watchpoint (bpstat bs)
          tuple_emitter.emplace (uiout, "value");
          uiout->text ("\nValue = ");
        }
-      watchpoint_value_print (w->val, &stb);
+      watchpoint_value_print (w->val.get (), &stb);
       uiout->field_stream ("new", stb);
       uiout->text ("\n");
       result = PRINT_UNKNOWN;
@@ -10648,7 +10475,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
 {
   struct breakpoint *scope_breakpoint = NULL;
   const struct block *exp_valid_block = NULL, *cond_exp_valid_block = NULL;
-  struct value *val, *mark, *result;
+  struct value *result;
   int saved_bitpos = 0, saved_bitsize = 0;
   const char *exp_start = NULL;
   const char *exp_end = NULL;
@@ -10750,10 +10577,10 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
   /* Parse the rest of the arguments.  From here on out, everything
      is in terms of a newly allocated string instead of the original
      ARG.  */
-  innermost_block = NULL;
   std::string expression (arg, exp_end - arg);
   exp_start = arg = expression.c_str ();
-  expression_up exp = parse_exp_1 (&arg, 0, 0, 0);
+  innermost_block_tracker tracker;
+  expression_up exp = parse_exp_1 (&arg, 0, 0, 0, &tracker);
   exp_end = arg;
   /* Remove trailing whitespace from the expression before saving it.
      This makes the eventual display of the expression string a bit
@@ -10772,28 +10599,30 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
       error (_("Cannot watch constant value `%.*s'."), len, exp_start);
     }
 
-  exp_valid_block = innermost_block;
-  mark = value_mark ();
-  fetch_subexp_value (exp.get (), &pc, &val, &result, NULL, just_location);
+  exp_valid_block = tracker.block ();
+  struct value *mark = value_mark ();
+  struct value *val_as_value = nullptr;
+  fetch_subexp_value (exp.get (), &pc, &val_as_value, &result, NULL,
+                     just_location);
 
-  if (val != NULL && just_location)
+  if (val_as_value != NULL && just_location)
     {
-      saved_bitpos = value_bitpos (val);
-      saved_bitsize = value_bitsize (val);
+      saved_bitpos = value_bitpos (val_as_value);
+      saved_bitsize = value_bitsize (val_as_value);
     }
 
+  value_ref_ptr val;
   if (just_location)
     {
       int ret;
 
       exp_valid_block = NULL;
-      val = value_addr (result);
-      release_value (val);
+      val = release_value (value_addr (result));
       value_free_to_mark (mark);
 
       if (use_mask)
        {
-         ret = target_masked_watch_num_registers (value_as_address (val),
+         ret = target_masked_watch_num_registers (value_as_address (val.get ()),
                                                   mask);
          if (ret == -1)
            error (_("This target does not support masked watchpoints."));
@@ -10801,8 +10630,8 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
            error (_("Invalid mask or memory region."));
        }
     }
-  else if (val != NULL)
-    release_value (val);
+  else if (val_as_value != NULL)
+    val = release_value (val_as_value);
 
   tok = skip_spaces (arg);
   end_tok = skip_to_space (tok);
@@ -10810,13 +10639,13 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
   toklen = end_tok - tok;
   if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
     {
-      innermost_block = NULL;
       tok = cond_start = end_tok + 1;
-      parse_exp_1 (&tok, 0, 0, 0);
+      innermost_block_tracker if_tracker;
+      parse_exp_1 (&tok, 0, 0, 0, &if_tracker);
 
       /* The watchpoint expression may not be local, but the condition
         may still be.  E.g.: `watch global if local > 0'.  */
-      cond_exp_valid_block = innermost_block;
+      cond_exp_valid_block = if_tracker.block ();
 
       cond_end = tok;
     }
@@ -10896,8 +10725,8 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
   w->cond_exp_valid_block = cond_exp_valid_block;
   if (just_location)
     {
-      struct type *t = value_type (val);
-      CORE_ADDR addr = value_as_address (val);
+      struct type *t = value_type (val.get ());
+      CORE_ADDR addr = value_as_address (val.get ());
 
       w->exp_string_reparse
        = current_language->la_watch_location_expression (t, addr).release ();
@@ -10958,15 +10787,17 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
    If the watchpoint cannot be handled in hardware return zero.  */
 
 static int
-can_use_hardware_watchpoint (struct value *v)
+can_use_hardware_watchpoint (const std::vector<value_ref_ptr> &vals)
 {
   int found_memory_cnt = 0;
-  struct value *head = v;
 
   /* Did the user specifically forbid us to use hardware watchpoints? */
   if (!can_use_hw_watchpoints)
     return 0;
 
+  gdb_assert (!vals.empty ());
+  struct value *head = vals[0].get ();
+
   /* Make sure that the value of the expression depends only upon
      memory contents, and values computed from them within GDB.  If we
      find any register references or function calls, we can't use a
@@ -10986,8 +10817,10 @@ can_use_hardware_watchpoint (struct value *v)
      function calls are special in any way.  So this function may not
      notice that an expression involving an inferior function call
      can't be watched with hardware watchpoints.  FIXME.  */
-  for (; v; v = value_next (v))
+  for (const value_ref_ptr &iter : vals)
     {
+      struct value *v = iter.get ();
+
       if (VALUE_LVAL (v) == lval_memory)
        {
          if (v != head && value_lazy (v))
@@ -11055,10 +10888,7 @@ watch_maybe_just_location (const char *arg, int accessflag, int from_tty)
   if (arg
       && (check_for_argument (&arg, "-location", sizeof ("-location") - 1)
          || check_for_argument (&arg, "-l", sizeof ("-l") - 1)))
-    {
-      arg = skip_spaces (arg);
-      just_location = 1;
-    }
+    just_location = 1;
 
   watch_command_1 (arg, accessflag, from_tty, just_location, 0);
 }
@@ -11098,106 +10928,66 @@ awatch_command (const char *arg, int from_tty)
    in infcmd.c.  Here because it uses the mechanisms of
    breakpoints.  */
 
-struct until_break_fsm
+struct until_break_fsm : public thread_fsm
 {
-  /* The base class.  */
-  struct thread_fsm thread_fsm;
-
-  /* The thread that as current when the command was executed.  */
+  /* The thread that was current when the command was executed.  */
   int thread;
 
   /* The breakpoint set at the destination location.  */
-  struct breakpoint *location_breakpoint;
+  breakpoint_up location_breakpoint;
 
   /* Breakpoint set at the return address in the caller frame.  May be
      NULL.  */
-  struct breakpoint *caller_breakpoint;
-};
-
-static void until_break_fsm_clean_up (struct thread_fsm *self,
-                                     struct thread_info *thread);
-static int until_break_fsm_should_stop (struct thread_fsm *self,
-                                       struct thread_info *thread);
-static enum async_reply_reason
-  until_break_fsm_async_reply_reason (struct thread_fsm *self);
+  breakpoint_up caller_breakpoint;
 
-/* until_break_fsm's vtable.  */
+  until_break_fsm (struct interp *cmd_interp, int thread,
+                  breakpoint_up &&location_breakpoint,
+                  breakpoint_up &&caller_breakpoint)
+    : thread_fsm (cmd_interp),
+      thread (thread),
+      location_breakpoint (std::move (location_breakpoint)),
+      caller_breakpoint (std::move (caller_breakpoint))
+  {
+  }
 
-static struct thread_fsm_ops until_break_fsm_ops =
-{
-  NULL, /* dtor */
-  until_break_fsm_clean_up,
-  until_break_fsm_should_stop,
-  NULL, /* return_value */
-  until_break_fsm_async_reply_reason,
+  void clean_up (struct thread_info *thread) override;
+  bool should_stop (struct thread_info *thread) override;
+  enum async_reply_reason do_async_reply_reason () override;
 };
 
-/* Allocate a new until_break_command_fsm.  */
-
-static struct until_break_fsm *
-new_until_break_fsm (struct interp *cmd_interp, int thread,
-                    breakpoint_up &&location_breakpoint,
-                    breakpoint_up &&caller_breakpoint)
-{
-  struct until_break_fsm *sm;
-
-  sm = XCNEW (struct until_break_fsm);
-  thread_fsm_ctor (&sm->thread_fsm, &until_break_fsm_ops, cmd_interp);
-
-  sm->thread = thread;
-  sm->location_breakpoint = location_breakpoint.release ();
-  sm->caller_breakpoint = caller_breakpoint.release ();
-
-  return sm;
-}
-
 /* Implementation of the 'should_stop' FSM method for the
    until(location)/advance commands.  */
 
-static int
-until_break_fsm_should_stop (struct thread_fsm *self,
-                            struct thread_info *tp)
+bool
+until_break_fsm::should_stop (struct thread_info *tp)
 {
-  struct until_break_fsm *sm = (struct until_break_fsm *) self;
-
   if (bpstat_find_breakpoint (tp->control.stop_bpstat,
-                             sm->location_breakpoint) != NULL
-      || (sm->caller_breakpoint != NULL
+                             location_breakpoint.get ()) != NULL
+      || (caller_breakpoint != NULL
          && bpstat_find_breakpoint (tp->control.stop_bpstat,
-                                    sm->caller_breakpoint) != NULL))
-    thread_fsm_set_finished (self);
+                                    caller_breakpoint.get ()) != NULL))
+    set_finished ();
 
-  return 1;
+  return true;
 }
 
 /* Implementation of the 'clean_up' FSM method for the
    until(location)/advance commands.  */
 
-static void
-until_break_fsm_clean_up (struct thread_fsm *self,
-                         struct thread_info *thread)
+void
+until_break_fsm::clean_up (struct thread_info *)
 {
-  struct until_break_fsm *sm = (struct until_break_fsm *) self;
-
   /* Clean up our temporary breakpoints.  */
-  if (sm->location_breakpoint != NULL)
-    {
-      delete_breakpoint (sm->location_breakpoint);
-      sm->location_breakpoint = NULL;
-    }
-  if (sm->caller_breakpoint != NULL)
-    {
-      delete_breakpoint (sm->caller_breakpoint);
-      sm->caller_breakpoint = NULL;
-    }
-  delete_longjmp_breakpoint (sm->thread);
+  location_breakpoint.reset ();
+  caller_breakpoint.reset ();
+  delete_longjmp_breakpoint (thread);
 }
 
 /* Implementation of the 'async_reply_reason' FSM method for the
    until(location)/advance commands.  */
 
-static enum async_reply_reason
-until_break_fsm_async_reply_reason (struct thread_fsm *self)
+enum async_reply_reason
+until_break_fsm::do_async_reply_reason ()
 {
   return EXEC_ASYNC_LOCATION_REACHED;
 }
@@ -11209,10 +10999,8 @@ until_break_command (const char *arg, int from_tty, int anywhere)
   struct gdbarch *frame_gdbarch;
   struct frame_id stack_frame_id;
   struct frame_id caller_frame_id;
-  struct cleanup *old_chain;
   int thread;
   struct thread_info *tp;
-  struct until_break_fsm *sm;
 
   clear_proceed_status (0);
 
@@ -11242,8 +11030,6 @@ until_break_command (const char *arg, int from_tty, int anywhere)
   tp = inferior_thread ();
   thread = tp->global_num;
 
-  old_chain = make_cleanup (null_cleanup, NULL);
-
   /* Note linespec handling above invalidates the frame chain.
      Installing a breakpoint also invalidates the frame chain (as it
      may need to switch threads), so do any frame handling before
@@ -11258,6 +11044,9 @@ until_break_command (const char *arg, int from_tty, int anywhere)
      one.  */
 
   breakpoint_up caller_breakpoint;
+
+  gdb::optional<delete_longjmp_breakpoint_cleanup> lj_deleter;
+
   if (frame_id_p (caller_frame_id))
     {
       struct symtab_and_line sal2;
@@ -11272,7 +11061,7 @@ until_break_command (const char *arg, int from_tty, int anywhere)
                                                    bp_until);
 
       set_longjmp_breakpoint (tp, caller_frame_id);
-      make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
+      lj_deleter.emplace (thread);
     }
 
   /* set_momentary_breakpoint could invalidate FRAME.  */
@@ -11290,12 +11079,12 @@ until_break_command (const char *arg, int from_tty, int anywhere)
     location_breakpoint = set_momentary_breakpoint (frame_gdbarch, sal,
                                                    stack_frame_id, bp_until);
 
-  sm = new_until_break_fsm (command_interp (), tp->global_num,
-                           std::move (location_breakpoint),
-                           std::move (caller_breakpoint));
-  tp->thread_fsm = &sm->thread_fsm;
+  tp->thread_fsm = new until_break_fsm (command_interp (), tp->global_num,
+                                       std::move (location_breakpoint),
+                                       std::move (caller_breakpoint));
 
-  discard_cleanups (old_chain);
+  if (lj_deleter)
+    lj_deleter->release ();
 
   proceed (-1, GDB_SIGNAL_DEFAULT);
 }
@@ -11342,10 +11131,9 @@ typedef enum
 catch_fork_kind;
 
 static void
-catch_fork_command_1 (char *arg_entry, int from_tty,
+catch_fork_command_1 (const char *arg, int from_tty,
                      struct cmd_list_element *command)
 {
-  const char *arg = arg_entry;
   struct gdbarch *gdbarch = get_current_arch ();
   const char *cond_string = NULL;
   catch_fork_kind fork_kind;
@@ -11390,10 +11178,9 @@ catch_fork_command_1 (char *arg_entry, int from_tty,
 }
 
 static void
-catch_exec_command_1 (char *arg_entry, int from_tty,
+catch_exec_command_1 (const char *arg, int from_tty,
                      struct cmd_list_element *command)
 {
-  const char *arg = arg_entry;
   struct gdbarch *gdbarch = get_current_arch ();
   int tempflag;
   const char *cond_string = NULL;
@@ -11499,7 +11286,6 @@ clear_command (const char *arg, int from_tty)
 {
   struct breakpoint *b;
   int default_match;
-  int i;
 
   std::vector<symtab_and_line> decoded_sals;
   symtab_and_line last_sal;
@@ -11621,14 +11407,14 @@ clear_command (const char *arg, int from_tty)
 
   /* Remove duplicates from the vec.  */
   std::sort (found.begin (), found.end (),
-            [] (const breakpoint *a, const breakpoint *b)
+            [] (const breakpoint *bp_a, const breakpoint *bp_b)
             {
-              return compare_breakpoints (a, b) < 0;
+              return compare_breakpoints (bp_a, bp_b) < 0;
             });
   found.erase (std::unique (found.begin (), found.end (),
-                           [] (const breakpoint *a, const breakpoint *b)
+                           [] (const breakpoint *bp_a, const breakpoint *bp_b)
                            {
-                             return compare_breakpoints (a, b) == 0;
+                             return compare_breakpoints (bp_a, bp_b) == 0;
                            }),
               found.end ());
 
@@ -11799,7 +11585,7 @@ download_tracepoint_locations (void)
       t = (struct tracepoint *) b;
       t->number_on_target = b->number;
       if (bp_location_downloaded)
-       observer_notify_breakpoint_modified (b);
+       gdb::observers::breakpoint_modified.notify (b);
     }
 }
 
@@ -12127,7 +11913,7 @@ update_global_location_list (enum ugll_insert_mode insert_mode)
              old_loc->events_till_retirement = 3 * (thread_count () + 1);
              old_loc->owner = NULL;
 
-             VEC_safe_push (bp_location_p, moribund_locations, old_loc);
+             moribund_locations.push_back (old_loc);
            }
          else
            {
@@ -12230,30 +12016,29 @@ update_global_location_list (enum ugll_insert_mode insert_mode)
 void
 breakpoint_retire_moribund (void)
 {
-  struct bp_location *loc;
-  int ix;
-
-  for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix)
-    if (--(loc->events_till_retirement) == 0)
-      {
-       decref_bp_location (&loc);
-       VEC_unordered_remove (bp_location_p, moribund_locations, ix);
-       --ix;
-      }
+  for (int ix = 0; ix < moribund_locations.size (); ++ix)
+    {
+      struct bp_location *loc = moribund_locations[ix];
+      if (--(loc->events_till_retirement) == 0)
+       {
+         decref_bp_location (&loc);
+         unordered_remove (moribund_locations, ix);
+         --ix;
+       }
+    }
 }
 
 static void
 update_global_location_list_nothrow (enum ugll_insert_mode insert_mode)
 {
 
-  TRY
+  try
     {
       update_global_location_list (insert_mode);
     }
-  CATCH (e, RETURN_MASK_ERROR)
+  catch (const gdb_exception_error &e)
     {
     }
-  END_CATCH
 }
 
 /* Clear BKP from a BPS.  */
@@ -12322,17 +12107,23 @@ say_where (struct breakpoint *b)
       if (opts.addressprint || b->loc->symtab == NULL)
        {
          printf_filtered (" at ");
-         fputs_filtered (paddress (b->loc->gdbarch, b->loc->address),
-                         gdb_stdout);
+         fputs_styled (paddress (b->loc->gdbarch, b->loc->address),
+                       address_style.style (),
+                       gdb_stdout);
        }
       if (b->loc->symtab != NULL)
        {
          /* If there is a single location, we can print the location
             more nicely.  */
          if (b->loc->next == NULL)
-           printf_filtered (": file %s, line %d.",
-                            symtab_to_filename_for_display (b->loc->symtab),
-                            b->loc->line_number);
+           {
+             puts_filtered (": file ");
+             fputs_styled (symtab_to_filename_for_display (b->loc->symtab),
+                           file_name_style.style (),
+                           gdb_stdout);
+             printf_filtered (", line %d.",
+                              b->loc->line_number);
+           }
          else
            /* This is not ideal, but each location may have a
               different file name, and this at least reflects the
@@ -12352,19 +12143,11 @@ say_where (struct breakpoint *b)
     }
 }
 
-/* Default bp_location_ops methods.  */
-
-static void
-bp_location_dtor (struct bp_location *self)
+bp_location::~bp_location ()
 {
-  xfree (self->function_name);
+  xfree (function_name);
 }
 
-static const struct bp_location_ops bp_location_ops =
-{
-  bp_location_dtor
-};
-
 /* Destructor for the breakpoint base class.  */
 
 breakpoint::~breakpoint ()
@@ -12377,7 +12160,7 @@ breakpoint::~breakpoint ()
 static struct bp_location *
 base_breakpoint_allocate_location (struct breakpoint *self)
 {
-  return new bp_location (&bp_location_ops, self);
+  return new bp_location (self);
 }
 
 static void
@@ -12897,10 +12680,7 @@ bkpt_probe_insert_location (struct bp_location *bl)
     {
       /* The insertion was successful, now let's set the probe's semaphore
         if needed.  */
-      if (bl->probe.probe->pops->set_semaphore != NULL)
-       bl->probe.probe->pops->set_semaphore (bl->probe.probe,
-                                             bl->probe.objfile,
-                                             bl->gdbarch);
+      bl->probe.prob->set_semaphore (bl->probe.objfile, bl->gdbarch);
     }
 
   return v;
@@ -12911,10 +12691,7 @@ bkpt_probe_remove_location (struct bp_location *bl,
                            enum remove_bp_reason reason)
 {
   /* Let's clear the semaphore before removing the location.  */
-  if (bl->probe.probe->pops->clear_semaphore != NULL)
-    bl->probe.probe->pops->clear_semaphore (bl->probe.probe,
-                                           bl->probe.objfile,
-                                           bl->gdbarch);
+  bl->probe.prob->clear_semaphore (bl->probe.objfile, bl->gdbarch);
 
   return bkpt_remove_location (bl, reason);
 }
@@ -12966,7 +12743,7 @@ tracepoint_print_one_detail (const struct breakpoint *self,
                             struct ui_out *uiout)
 {
   struct tracepoint *tp = (struct tracepoint *) self;
-  if (tp->static_trace_marker_id)
+  if (!tp->static_trace_marker_id.empty ())
     {
       gdb_assert (self->type == bp_static_tracepoint);
 
@@ -13173,12 +12950,13 @@ strace_marker_create_sals_from_location (const struct event_location *location,
   struct linespec_sals lsal;
   const char *arg_start, *arg;
 
-  arg = arg_start = get_linespec_location (location);
+  arg = arg_start = get_linespec_location (location)->spec_string;
   lsal.sals = decode_static_tracepoint_spec (&arg);
 
   std::string str (arg_start, arg - arg_start);
   const char *ptr = str.c_str ();
-  canonical->location = new_linespec_location (&ptr);
+  canonical->location
+    = new_linespec_location (&ptr, symbol_name_match_type::FULL);
 
   lsal.canonical
     = xstrdup (event_location_to_string (canonical->location.get ()));
@@ -13239,7 +13017,7 @@ strace_marker_decode_location (struct breakpoint *b,
                               struct program_space *search_pspace)
 {
   struct tracepoint *tp = (struct tracepoint *) b;
-  const char *s = get_linespec_location (location);
+  const char *s = get_linespec_location (location)->spec_string;
 
   std::vector<symtab_and_line> sals = decode_static_tracepoint_spec (&s);
   if (sals.size () > tp->static_trace_marker_id_idx)
@@ -13249,7 +13027,7 @@ strace_marker_decode_location (struct breakpoint *b,
       return sals;
     }
   else
-    error (_("marker %s not found"), tp->static_trace_marker_id);
+    error (_("marker %s not found"), tp->static_trace_marker_id.c_str ());
 }
 
 static struct breakpoint_ops strace_marker_breakpoint_ops;
@@ -13317,7 +13095,7 @@ delete_breakpoint (struct breakpoint *bpt)
      a problem in that process, we'll be asked to delete the half-created
      watchpoint.  In that case, don't announce the deletion.  */
   if (bpt->number)
-    observer_notify_breakpoint_deleted (bpt);
+    gdb::observers::breakpoint_deleted.notify (bpt);
 
   if (breakpoint_chain == bpt)
     breakpoint_chain = bpt->next;
@@ -13422,9 +13200,9 @@ delete_command (const char *arg, int from_tty)
     }
   else
     map_breakpoint_numbers
-      (arg, [&] (breakpoint *b)
+      (arg, [&] (breakpoint *br)
        {
-        iterate_over_related_breakpoints (b, delete_breakpoint);
+        iterate_over_related_breakpoints (br, delete_breakpoint);
        });
 }
 
@@ -13454,10 +13232,8 @@ static int
 ambiguous_names_p (struct bp_location *loc)
 {
   struct bp_location *l;
-  htab_t htab = htab_create_alloc (13, htab_hash_string,
-                                  (int (*) (const void *, 
-                                            const void *)) streq,
-                                  NULL, xcalloc, xfree);
+  htab_t htab = htab_create_alloc (13, htab_hash_string, streq_hash, NULL,
+                                  xcalloc, xfree);
 
   for (l = loc; l != NULL; l = l->next)
     {
@@ -13530,14 +13306,12 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
 
   if (target_static_tracepoint_marker_at (pc, &marker))
     {
-      if (strcmp (tp->static_trace_marker_id, marker.str_id) != 0)
+      if (tp->static_trace_marker_id != marker.str_id)
        warning (_("static tracepoint %d changed probed marker from %s to %s"),
-                b->number,
-                tp->static_trace_marker_id, marker.str_id);
+                b->number, tp->static_trace_marker_id.c_str (),
+                marker.str_id.c_str ());
 
-      xfree (tp->static_trace_marker_id);
-      tp->static_trace_marker_id = xstrdup (marker.str_id);
-      release_static_tracepoint_marker (&marker);
+      tp->static_trace_marker_id = std::move (marker.str_id);
 
       return sal;
     }
@@ -13547,39 +13321,39 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
   if (!sal.explicit_pc
       && sal.line != 0
       && sal.symtab != NULL
-      && tp->static_trace_marker_id != NULL)
+      && !tp->static_trace_marker_id.empty ())
     {
-      VEC(static_tracepoint_marker_p) *markers;
-
-      markers
-       = target_static_tracepoint_markers_by_strid (tp->static_trace_marker_id);
+      std::vector<static_tracepoint_marker> markers
+       = target_static_tracepoint_markers_by_strid
+           (tp->static_trace_marker_id.c_str ());
 
-      if (!VEC_empty(static_tracepoint_marker_p, markers))
+      if (!markers.empty ())
        {
          struct symbol *sym;
          struct static_tracepoint_marker *tpmarker;
          struct ui_out *uiout = current_uiout;
          struct explicit_location explicit_loc;
 
-         tpmarker = VEC_index (static_tracepoint_marker_p, markers, 0);
+         tpmarker = &markers[0];
 
-         xfree (tp->static_trace_marker_id);
-         tp->static_trace_marker_id = xstrdup (tpmarker->str_id);
+         tp->static_trace_marker_id = std::move (tpmarker->str_id);
 
          warning (_("marker for static tracepoint %d (%s) not "
                     "found at previous line number"),
-                  b->number, tp->static_trace_marker_id);
+                  b->number, tp->static_trace_marker_id.c_str ());
 
          symtab_and_line sal2 = find_pc_line (tpmarker->address, 0);
          sym = find_pc_sect_function (tpmarker->address, NULL);
          uiout->text ("Now in ");
          if (sym)
            {
-             uiout->field_string ("func", SYMBOL_PRINT_NAME (sym));
+             uiout->field_string ("func", SYMBOL_PRINT_NAME (sym),
+                                  ui_out_style_kind::FUNCTION);
              uiout->text (" at ");
            }
          uiout->field_string ("file",
-                              symtab_to_filename_for_display (sal2.symtab));
+                              symtab_to_filename_for_display (sal2.symtab),
+                              ui_out_style_kind::FILE);
          uiout->text (":");
 
          if (uiout->is_mi_like_p ())
@@ -13605,8 +13379,6 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
 
          /* Might be nice to check if function changed, and warn if
             so.  */
-
-         release_static_tracepoint_marker (tpmarker);
        }
     }
   return sal;
@@ -13689,7 +13461,6 @@ update_breakpoint_locations (struct breakpoint *b,
                             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.empty () && (sals.size () != 1 || sals_end.size () != 1))
@@ -13729,20 +13500,19 @@ update_breakpoint_locations (struct breakpoint *b,
          const char *s;
 
          s = b->cond_string;
-         TRY
+         try
            {
              new_loc->cond = parse_exp_1 (&s, sal.pc,
                                           block_for_pc (sal.pc),
                                           0);
            }
-         CATCH (e, RETURN_MASK_ERROR)
+         catch (const gdb_exception_error &e)
            {
              warning (_("failed to reevaluate condition "
                         "for breakpoint %d: %s"), 
-                      b->number, e.message);
+                      b->number, e.what ());
              new_loc->enabled = 0;
            }
-         END_CATCH
        }
 
       if (!sals_end.empty ())
@@ -13793,7 +13563,7 @@ update_breakpoint_locations (struct breakpoint *b,
   }
 
   if (!locations_are_equal (existing_locations, b->loc))
-    observer_notify_breakpoint_modified (b);
+    gdb::observers::breakpoint_modified.notify (b);
 }
 
 /* Find the SaL locations corresponding to the given LOCATION.
@@ -13803,22 +13573,20 @@ static std::vector<symtab_and_line>
 location_to_sals (struct breakpoint *b, struct event_location *location,
                  struct program_space *search_pspace, int *found)
 {
-  struct gdb_exception exception = exception_none;
+  struct gdb_exception exception;
 
   gdb_assert (b->ops != NULL);
 
   std::vector<symtab_and_line> sals;
 
-  TRY
+  try
     {
       sals = b->ops->decode_location (b, location, search_pspace);
     }
-  CATCH (e, RETURN_MASK_ERROR)
+  catch (gdb_exception_error &e)
     {
       int not_found_and_ok = 0;
 
-      exception = e;
-
       /* For pending breakpoints, it's expected that parsing will
         fail until the right shared library is loaded.  User has
         already told to create pending breakpoints and don't need
@@ -13845,10 +13613,11 @@ location_to_sals (struct breakpoint *b, struct event_location *location,
             happens only when a binary has changed, I don't know
             which approach is better.  */
          b->enable_state = bp_disabled;
-         throw_exception (e);
+         throw;
        }
+
+      exception = std::move (e);
     }
-  END_CATCH
 
   if (exception.reason == 0 || exception.error != NOT_FOUND_ERROR)
     {
@@ -14000,6 +13769,19 @@ breakpoint_re_set (void)
     scoped_restore save_input_radix = make_scoped_restore (&input_radix);
     scoped_restore_current_pspace_and_thread restore_pspace_thread;
 
+    /* breakpoint_re_set_one sets the current_language to the language
+       of the breakpoint it is resetting (see prepare_re_set_context)
+       before re-evaluating the breakpoint's location.  This change can
+       unfortunately get undone by accident if the language_mode is set
+       to auto, and we either switch frames, or more likely in this context,
+       we select the current frame.
+
+       We prevent this by temporarily turning the language_mode to
+       language_mode_manual.  We restore it once all breakpoints
+       have been reset.  */
+    scoped_restore save_language_mode = make_scoped_restore (&language_mode);
+    language_mode = language_mode_manual;
+
     /* Note: we must not try to insert locations until after all
        breakpoints have been re-set.  Otherwise, e.g., when re-setting
        breakpoint 1, we'd insert the locations of breakpoint 2, which
@@ -14007,17 +13789,16 @@ breakpoint_re_set (void)
 
     ALL_BREAKPOINTS_SAFE (b, b_tmp)
       {
-       TRY
+       try
          {
            breakpoint_re_set_one (b);
          }
-       CATCH (ex, RETURN_MASK_ALL)
+       catch (const gdb_exception &ex)
          {
            exception_fprintf (gdb_stderr, ex,
                               "Error in re-setting breakpoint %d: ",
                               b->number);
          }
-       END_CATCH
       }
 
     jit_breakpoint_re_set ();
@@ -14041,8 +13822,7 @@ breakpoint_re_set_thread (struct breakpoint *b)
 {
   if (b->thread != -1)
     {
-      if (in_thread_list (inferior_ptid))
-       b->thread = ptid_to_global_thread_id (inferior_ptid);
+      b->thread = inferior_thread ()->global_num;
 
       /* We're being called after following a fork.  The new fork is
         selected as current, and unless this was a vfork will have a
@@ -14090,7 +13870,7 @@ set_ignore_count (int bptnum, int count, int from_tty)
                               "crossings of breakpoint %d."),
                             count, bptnum);
        }
-      observer_notify_breakpoint_modified (b);
+      gdb::observers::breakpoint_modified.notify (b);
       return;
     }
 
@@ -14347,6 +14127,8 @@ enable_disable_bp_num_loc (int bp_num, int loc_num, bool enable)
        target_disable_tracepoint (loc);
     }
   update_global_location_list (UGLL_DONT_INSERT);
+
+  gdb::observers::breakpoint_modified.notify (loc->owner);
 }
 
 /* Enable or disable a range of breakpoint locations.  BP_NUM is the
@@ -14393,7 +14175,7 @@ disable_breakpoint (struct breakpoint *bpt)
 
   update_global_location_list (UGLL_DONT_INSERT);
 
-  observer_notify_breakpoint_modified (bpt);
+  gdb::observers::breakpoint_modified.notify (bpt);
 }
 
 /* Enable or disable the breakpoint(s) or breakpoint location(s)
@@ -14483,7 +14265,7 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition,
       /* Initialize it just to avoid a GCC false warning.  */
       enum enable_state orig_enable_state = bp_disabled;
 
-      TRY
+      try
        {
          struct watchpoint *w = (struct watchpoint *) bpt;
 
@@ -14491,14 +14273,13 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition,
          bpt->enable_state = bp_enabled;
          update_watchpoint (w, 1 /* reparse */);
        }
-      CATCH (e, RETURN_MASK_ALL)
+      catch (const gdb_exception &e)
        {
          bpt->enable_state = orig_enable_state;
          exception_fprintf (gdb_stderr, e, _("Cannot enable watchpoint %d: "),
                             bpt->number);
          return;
        }
-      END_CATCH
     }
 
   bpt->enable_state = bp_enabled;
@@ -14519,7 +14300,7 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition,
   bpt->enable_count = count;
   update_global_location_list (UGLL_MAY_INSERT);
 
-  observer_notify_breakpoint_modified (bpt);
+  gdb::observers::breakpoint_modified.notify (bpt);
 }
 
 
@@ -14616,7 +14397,7 @@ invalidate_bp_value_on_memory_change (struct inferior *inferior,
       {
        struct watchpoint *wp = (struct watchpoint *) bp;
 
-       if (wp->val_valid && wp->val)
+       if (wp->val_valid && wp->val != nullptr)
          {
            struct bp_location *loc;
 
@@ -14625,7 +14406,6 @@ invalidate_bp_value_on_memory_change (struct inferior *inferior,
                  && loc->address + loc->length > addr
                  && addr + len > loc->address)
                {
-                 value_free (wp->val);
                  wp->val = NULL;
                  wp->val_valid = 0;
                }
@@ -14785,7 +14565,7 @@ strace_command (const char *arg, int from_tty)
   if (arg && startswith (arg, "-m") && isspace (arg[2]))
     {
       ops = &strace_marker_breakpoint_ops;
-      location = new_linespec_location (&arg);
+      location = new_linespec_location (&arg, symbol_name_match_type::FULL);
     }
   else
     {
@@ -14815,11 +14595,13 @@ static int next_cmd;
 static char *
 read_uploaded_action (void)
 {
-  char *rslt;
-
-  VEC_iterate (char_ptr, this_utp->cmd_strings, next_cmd, rslt);
+  char *rslt = nullptr;
 
-  next_cmd++;
+  if (next_cmd < this_utp->cmd_strings.size ())
+    {
+      rslt = this_utp->cmd_strings[next_cmd].get ();
+      next_cmd++;
+    }
 
   return rslt;
 }
@@ -14838,7 +14620,7 @@ create_tracepoint_from_upload (struct uploaded_tp *utp)
   struct tracepoint *tp;
 
   if (utp->at_string)
-    addr_str = utp->at_string;
+    addr_str = utp->at_string.get ();
   else
     {
       /* In the absence of a source location, fall back to raw
@@ -14862,7 +14644,7 @@ create_tracepoint_from_upload (struct uploaded_tp *utp)
                                                         current_language);
   if (!create_breakpoint (get_current_arch (),
                          location.get (),
-                         utp->cond_string, -1, addr_str,
+                         utp->cond_string.get (), -1, addr_str,
                          0 /* parse cond/thread */,
                          0 /* tempflag */,
                          utp->type /* type_wanted */,
@@ -14891,19 +14673,19 @@ create_tracepoint_from_upload (struct uploaded_tp *utp)
      special-purpose "reader" function and call the usual command line
      reader, then pass the result to the breakpoint command-setting
      function.  */
-  if (!VEC_empty (char_ptr, utp->cmd_strings))
+  if (!utp->cmd_strings.empty ())
     {
-      command_line_up cmd_list;
+      counted_command_line cmd_list;
 
       this_utp = utp;
       next_cmd = 0;
 
-      cmd_list = read_command_lines_1 (read_uploaded_action, 1, NULL, NULL);
+      cmd_list = read_command_lines_1 (read_uploaded_action, 1, NULL);
 
       breakpoint_set_commands (tp, std::move (cmd_list));
     }
-  else if (!VEC_empty (char_ptr, utp->actions)
-          || !VEC_empty (char_ptr, utp->step_actions))
+  else if (!utp->actions.empty ()
+          || !utp->step_actions.empty ())
     warning (_("Uploaded tracepoint %d actions "
               "have no source form, ignoring them"),
             utp->number);
@@ -14919,7 +14701,7 @@ create_tracepoint_from_upload (struct uploaded_tp *utp)
    omitted.  */
 
 static void
-info_tracepoints_command (char *args, int from_tty)
+info_tracepoints_command (const char *args, int from_tty)
 {
   struct ui_out *uiout = current_uiout;
   int num_printed;
@@ -14940,7 +14722,7 @@ info_tracepoints_command (char *args, int from_tty)
 /* The 'enable trace' command enables tracepoints.
    Not supported by all targets.  */
 static void
-enable_trace_command (char *args, int from_tty)
+enable_trace_command (const char *args, int from_tty)
 {
   enable_command (args, from_tty);
 }
@@ -14948,7 +14730,7 @@ enable_trace_command (char *args, int from_tty)
 /* The 'disable trace' command disables tracepoints.
    Not supported by all targets.  */
 static void
-disable_trace_command (char *args, int from_tty)
+disable_trace_command (const char *args, int from_tty)
 {
   disable_command (args, from_tty);
 }
@@ -14987,9 +14769,9 @@ delete_trace_command (const char *arg, int from_tty)
     }
   else
     map_breakpoint_numbers
-      (arg, [&] (breakpoint *b)
+      (arg, [&] (breakpoint *br)
        {
-        iterate_over_related_breakpoints (b, delete_breakpoint);
+        iterate_over_related_breakpoints (br, delete_breakpoint);
        });
 }
 
@@ -14999,7 +14781,7 @@ static void
 trace_pass_set_count (struct tracepoint *tp, int count, int from_tty)
 {
   tp->pass_count = count;
-  observer_notify_breakpoint_modified (tp);
+  gdb::observers::breakpoint_modified.notify (tp);
   if (from_tty)
     printf_filtered (_("Setting tracepoint %d's passcount to %d\n"),
                     tp->number, count);
@@ -15225,16 +15007,15 @@ save_breakpoints (const char *filename, int from_tty,
        fp.puts ("  commands\n");
        
        current_uiout->redirect (&fp);
-       TRY
+       try
          {
            print_command_lines (current_uiout, tp->commands.get (), 2);
          }
-       CATCH (ex, RETURN_MASK_ALL)
+       catch (const gdb_exception &ex)
          {
          current_uiout->redirect (NULL);
-           throw_exception (ex);
+           throw;
          }
-       END_CATCH
 
        current_uiout->redirect (NULL);
        fp.puts ("  end\n");
@@ -15282,15 +15063,15 @@ save_tracepoints_command (const char *args, int from_tty)
 
 /* Create a vector of all tracepoints.  */
 
-VEC(breakpoint_p) *
+std::vector<breakpoint *>
 all_tracepoints (void)
 {
-  VEC(breakpoint_p) *tp_vec = 0;
+  std::vector<breakpoint *> tp_vec;
   struct breakpoint *tp;
 
   ALL_TRACEPOINTS (tp)
   {
-    VEC_safe_push (breakpoint_p, tp_vec, tp);
+    tp_vec.push_back (tp);
   }
 
   return tp_vec;
@@ -15315,7 +15096,14 @@ Explicit locations are similar to linespecs but use an option/argument\n\
 syntax to specify location parameters.\n\
 Example: To specify the start of the label named \"the_top\" in the\n\
 function \"fact\" in the file \"factorial.c\", use \"-source factorial.c\n\
--function fact -label the_top\".\n"
+-function fact -label the_top\".\n\
+\n\
+By default, a specified function is matched against the program's\n\
+functions in all scopes.  For C++, this means in all namespaces and\n\
+classes.  For Ada, this means in all packages.  E.g., in C++,\n\
+\"func()\" matches \"A::func()\", \"A::B::func()\", etc.  The\n\
+\"-qualified\" flag overrides this behavior, making GDB interpret the\n\
+specified name as a complete fully-qualified name instead."
 
 /* This help string is used for the break, hbreak, tbreak and thbreak
    commands.  It is defined as a macro to prevent duplication.
@@ -15336,7 +15124,7 @@ stack frame.  This is useful for breaking on return to a stack frame.\n\
 \n\
 THREADNUM is the number from \"info threads\".\n\
 CONDITION is a boolean expression.\n\
-\n" LOCATION_HELP_STRING "\n\
+\n" LOCATION_HELP_STRING "\n\n\
 Multiple breakpoints at one place are permitted, and useful if their\n\
 conditions are different.\n\
 \n\
@@ -15350,7 +15138,7 @@ static struct cmd_list_element *tcatch_cmdlist;
 
 void
 add_catch_command (const char *name, const char *docstring,
-                  cmd_sfunc_ftype *sfunc,
+                  cmd_const_sfunc_ftype *sfunc,
                   completer_ftype *completer,
                   void *user_data_catch,
                   void *user_data_tcatch)
@@ -15625,6 +15413,10 @@ initialize_breakpoint_ops (void)
 
 static struct cmd_list_element *enablebreaklist = NULL;
 
+/* See breakpoint.h.  */
+
+cmd_list_element *commands_cmd_element = nullptr;
+
 void
 _initialize_breakpoint (void)
 {
@@ -15632,12 +15424,9 @@ _initialize_breakpoint (void)
 
   initialize_breakpoint_ops ();
 
-  observer_attach_solib_unloaded (disable_breakpoints_in_unloaded_shlib);
-  observer_attach_free_objfile (disable_breakpoints_in_freed_objfile);
-  observer_attach_memory_changed (invalidate_bp_value_on_memory_change);
-
-  breakpoint_objfile_key
-    = register_objfile_data_with_cleanup (NULL, free_breakpoint_objfile_data);
+  gdb::observers::solib_unloaded.attach (disable_breakpoints_in_unloaded_shlib);
+  gdb::observers::free_objfile.attach (disable_breakpoints_in_freed_objfile);
+  gdb::observers::memory_changed.attach (invalidate_bp_value_on_memory_change);
 
   breakpoint_chain = 0;
   /* Don't bother to call set_breakpoint_count.  $bpnum isn't useful
@@ -15650,7 +15439,8 @@ _initialize_breakpoint (void)
 Set ignore-count of breakpoint number N to COUNT.\n\
 Usage is `ignore N COUNT'."));
 
-  add_com ("commands", class_breakpoint, commands_command, _("\
+  commands_cmd_element = add_com ("commands", class_breakpoint,
+                                 commands_command, _("\
 Set commands to be executed when the given breakpoints are hit.\n\
 Give a space-separated breakpoint list as argument after \"commands\".\n\
 A list element can be a breakpoint number (e.g. `5') or a range of numbers\n\
@@ -15706,7 +15496,7 @@ With a subcommand you can enable temporarily."),
 Enable some breakpoints.\n\
 Give breakpoint numbers (separated by spaces) as arguments.\n\
 This is used to cancel the effect of the \"disable\" command.\n\
-May be abbreviated to simply \"enable\".\n"),
+May be abbreviated to simply \"enable\"."),
                   &enablebreaklist, "enable breakpoints ", 1, &enablelist);
 
   add_cmd ("once", no_class, enable_once_command, _("\
@@ -15782,7 +15572,7 @@ Argument may be a linespec, explicit, or address location as described below.\n\
 \n\
 With no argument, clears all breakpoints in the line that the selected frame\n\
 is executing in.\n"
-"\n" LOCATION_HELP_STRING "\n\
+"\n" LOCATION_HELP_STRING "\n\n\
 See also the \"delete\" command which clears breakpoints by number."));
   add_com_alias ("cl", "clear", class_breakpoint, 1);
 
@@ -15982,7 +15772,7 @@ tracing library.  You can inspect it when analyzing the trace buffer,\n\
 by printing the $_sdata variable like any other convenience variable.\n\
 \n\
 CONDITION is a boolean expression.\n\
-\n" LOCATION_HELP_STRING "\n\
+\n" LOCATION_HELP_STRING "\n\n\
 Multiple tracepoints at one place are permitted, and useful if their\n\
 conditions are different.\n\
 \n\
@@ -16185,6 +15975,6 @@ agent-printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
 
   automatic_hardware_breakpoints = 1;
 
-  observer_attach_about_to_proceed (breakpoint_about_to_proceed);
-  observer_attach_thread_exit (remove_threaded_breakpoints);
+  gdb::observers::about_to_proceed.attach (breakpoint_about_to_proceed);
+  gdb::observers::thread_exit.attach (remove_threaded_breakpoints);
 }
This page took 0.083753 seconds and 4 git commands to generate.