Rename gdb exception types
[deliverable/binutils-gdb.git] / gdb / record-btrace.c
index a7a565b865a71d9e8dd8c61b91fabfa0b68d9934..f5a5306fe1232962d7a61c3ae294de56c877c06b 100644 (file)
@@ -1,6 +1,6 @@
 /* Branch trace support for GDB, the GNU debugger.
 
-   Copyright (C) 2013-2018 Free Software Foundation, Inc.
+   Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
    Contributed by Intel Corp. <markus.t.metzger@intel.com>
 
@@ -38,7 +38,8 @@
 #include "infrun.h"
 #include "event-loop.h"
 #include "inf-loop.h"
-#include "vec.h"
+#include "common/vec.h"
+#include "inferior.h"
 #include <algorithm>
 
 static const target_info record_btrace_target_info = {
@@ -52,12 +53,11 @@ static const target_info record_btrace_target_info = {
 class record_btrace_target final : public target_ops
 {
 public:
-  record_btrace_target ()
-  { to_stratum = record_stratum; }
-
   const target_info &info () const override
   { return record_btrace_target_info; }
 
+  strata stratum () const override { return record_stratum; }
+
   void close () override;
   void async (int) override;
 
@@ -143,7 +143,7 @@ static record_btrace_target record_btrace_ops;
 
 /* Token associated with a new-thread observer enabling branch tracing
    for the new thread.  */
-static const gdb::observers::token record_btrace_thread_observer_token;
+static const gdb::observers::token record_btrace_thread_observer_token {};
 
 /* Memory access types used in set/show record btrace replay-memory-access.  */
 static const char replay_memory_access_read_only[] = "read-only";
@@ -244,14 +244,13 @@ record_btrace_get_cpu (void)
 static struct thread_info *
 require_btrace_thread (void)
 {
-  struct thread_info *tp;
-
   DEBUG ("require");
 
-  tp = find_thread_ptid (inferior_ptid);
-  if (tp == NULL)
+  if (inferior_ptid == null_ptid)
     error (_("No thread."));
 
+  thread_info *tp = inferior_thread ();
+
   validate_registers_access ();
 
   btrace_fetch (tp, record_btrace_get_cpu ());
@@ -283,15 +282,14 @@ require_btrace (void)
 static void
 record_btrace_enable_warn (struct thread_info *tp)
 {
-  TRY
+  try
     {
       btrace_enable (tp, &record_btrace_conf);
     }
-  CATCH (error, RETURN_MASK_ERROR)
+  catch (const gdb_exception_error &error)
     {
-      warning ("%s", error.message);
+      warning ("%s", error.what ());
     }
-  END_CATCH
 }
 
 /* Enable automatic tracing of new threads.  */
@@ -379,7 +377,6 @@ record_btrace_target_open (const char *args, int from_tty)
   /* If we fail to enable btrace for one thread, disable it for the threads for
      which it was successfully enabled.  */
   scoped_btrace_disable btrace_disable;
-  struct thread_info *tp;
 
   DEBUG ("open");
 
@@ -388,7 +385,7 @@ record_btrace_target_open (const char *args, int from_tty)
   if (!target_has_execution)
     error (_("The program is not being run."));
 
-  ALL_NON_EXITED_THREADS (tp)
+  for (thread_info *tp : all_non_exited_threads ())
     if (args == NULL || *args == 0 || number_is_in_list (args, tp->global_num))
       {
        btrace_enable (tp, &record_btrace_conf);
@@ -406,13 +403,11 @@ record_btrace_target_open (const char *args, int from_tty)
 void
 record_btrace_target::stop_recording ()
 {
-  struct thread_info *tp;
-
   DEBUG ("stop recording");
 
   record_btrace_auto_disable ();
 
-  ALL_NON_EXITED_THREADS (tp)
+  for (thread_info *tp : all_non_exited_threads ())
     if (tp->btrace.target != NULL)
       btrace_disable (tp);
 }
@@ -423,7 +418,7 @@ void
 record_btrace_target::disconnect (const char *args,
                                  int from_tty)
 {
-  struct target_ops *beneath = this->beneath;
+  struct target_ops *beneath = this->beneath ();
 
   /* Do not stop recording, just clean up GDB side.  */
   unpush_target (this);
@@ -437,8 +432,6 @@ record_btrace_target::disconnect (const char *args,
 void
 record_btrace_target::close ()
 {
-  struct thread_info *tp;
-
   if (record_btrace_async_inferior_event_handler != NULL)
     delete_async_event_handler (&record_btrace_async_inferior_event_handler);
 
@@ -448,7 +441,7 @@ record_btrace_target::close ()
 
   /* We should have already stopped recording.
      Tear down btrace in case we have not.  */
-  ALL_NON_EXITED_THREADS (tp)
+  for (thread_info *tp : all_non_exited_threads ())
     btrace_teardown (tp);
 }
 
@@ -462,7 +455,7 @@ record_btrace_target::async (int enable)
   else
     clear_async_event_handler (record_btrace_async_inferior_event_handler);
 
-  this->beneath->async (enable);
+  this->beneath ()->async (enable);
 }
 
 /* Adjusts the size and returns a human readable size suffix.  */
@@ -602,7 +595,8 @@ record_btrace_target::info_record ()
 
   printf_unfiltered (_("Recorded %u instructions in %u functions (%u gaps) "
                       "for thread %s (%s).\n"), insns, calls, gaps,
-                    print_thread_id (tp), target_pid_to_str (tp->ptid));
+                    print_thread_id (tp),
+                    target_pid_to_str (tp->ptid).c_str ());
 
   if (btrace_is_replaying (tp))
     printf_unfiltered (_("Replay in progress.  At instruction %u.\n"),
@@ -1096,7 +1090,8 @@ btrace_call_history_src_line (struct ui_out *uiout,
     return;
 
   uiout->field_string ("file",
-                      symtab_to_filename_for_display (symbol_symtab (sym)));
+                      symtab_to_filename_for_display (symbol_symtab (sym)),
+                      ui_out_style_kind::FILE);
 
   btrace_compute_src_line_range (bfun, &begin, &end);
   if (end < begin)
@@ -1187,11 +1182,14 @@ btrace_call_history (struct ui_out *uiout,
        }
 
       if (sym != NULL)
-       uiout->field_string ("function", SYMBOL_PRINT_NAME (sym));
+       uiout->field_string ("function", SYMBOL_PRINT_NAME (sym),
+                            ui_out_style_kind::FUNCTION);
       else if (msym != NULL)
-       uiout->field_string ("function", MSYMBOL_PRINT_NAME (msym));
+       uiout->field_string ("function", MSYMBOL_PRINT_NAME (msym),
+                            ui_out_style_kind::FUNCTION);
       else if (!uiout->is_mi_like_p ())
-       uiout->field_string ("function", "??");
+       uiout->field_string ("function", "??",
+                            ui_out_style_kind::FUNCTION);
 
       if ((flags & RECORD_PRINT_INSN_RANGE) != 0)
        {
@@ -1398,10 +1396,8 @@ record_btrace_target::record_method (ptid_t ptid)
 bool
 record_btrace_target::record_is_replaying (ptid_t ptid)
 {
-  struct thread_info *tp;
-
-  ALL_NON_EXITED_THREADS (tp)
-    if (ptid_match (tp->ptid, ptid) && btrace_is_replaying (tp))
+  for (thread_info *tp : all_non_exited_threads (ptid))
+    if (btrace_is_replaying (tp))
       return true;
 
   return false;
@@ -1463,8 +1459,8 @@ record_btrace_target::xfer_partial (enum target_object object,
     }
 
   /* Forward the request.  */
-  return this->beneath->xfer_partial (object, annex, readbuf, writebuf,
-                                     offset, len, xfered_len);
+  return this->beneath ()->xfer_partial (object, annex, readbuf, writebuf,
+                                        offset, len, xfered_len);
 }
 
 /* The insert_breakpoint method of target record-btrace.  */
@@ -1482,16 +1478,15 @@ record_btrace_target::insert_breakpoint (struct gdbarch *gdbarch,
   replay_memory_access = replay_memory_access_read_write;
 
   ret = 0;
-  TRY
+  try
     {
-      ret = this->beneath->insert_breakpoint (gdbarch, bp_tgt);
+      ret = this->beneath ()->insert_breakpoint (gdbarch, bp_tgt);
     }
-  CATCH (except, RETURN_MASK_ALL)
+  catch (const gdb_exception &except)
     {
       replay_memory_access = old;
       throw_exception (except);
     }
-  END_CATCH
   replay_memory_access = old;
 
   return ret;
@@ -1513,16 +1508,15 @@ record_btrace_target::remove_breakpoint (struct gdbarch *gdbarch,
   replay_memory_access = replay_memory_access_read_write;
 
   ret = 0;
-  TRY
+  try
     {
-      ret = this->beneath->remove_breakpoint (gdbarch, bp_tgt, reason);
+      ret = this->beneath ()->remove_breakpoint (gdbarch, bp_tgt, reason);
     }
-  CATCH (except, RETURN_MASK_ALL)
+  catch (const gdb_exception &except)
     {
       replay_memory_access = old;
       throw_exception (except);
     }
-  END_CATCH
   replay_memory_access = old;
 
   return ret;
@@ -1536,7 +1530,7 @@ record_btrace_target::fetch_registers (struct regcache *regcache, int regno)
   struct btrace_insn_iterator *replay;
   struct thread_info *tp;
 
-  tp = find_thread_ptid (regcache_get_ptid (regcache));
+  tp = find_thread_ptid (regcache->ptid ());
   gdb_assert (tp != NULL);
 
   replay = tp->btrace.replay;
@@ -1558,10 +1552,10 @@ record_btrace_target::fetch_registers (struct regcache *regcache, int regno)
       insn = btrace_insn_get (replay);
       gdb_assert (insn != NULL);
 
-      regcache_raw_supply (regcache, regno, &insn->pc);
+      regcache->raw_supply (regno, &insn->pc);
     }
   else
-    this->beneath->fetch_registers (regcache, regno);
+    this->beneath ()->fetch_registers (regcache, regno);
 }
 
 /* The store_registers method of target record-btrace.  */
@@ -1569,15 +1563,13 @@ record_btrace_target::fetch_registers (struct regcache *regcache, int regno)
 void
 record_btrace_target::store_registers (struct regcache *regcache, int regno)
 {
-  struct target_ops *t;
-
   if (!record_btrace_generating_corefile
-      && record_is_replaying (regcache_get_ptid (regcache)))
+      && record_is_replaying (regcache->ptid ()))
     error (_("Cannot write registers while replaying."));
 
   gdb_assert (may_write_registers != 0);
 
-  this->beneath->store_registers (regcache, regno);
+  this->beneath ()->store_registers (regcache, regno);
 }
 
 /* The prepare_to_store method of target record-btrace.  */
@@ -1586,10 +1578,10 @@ void
 record_btrace_target::prepare_to_store (struct regcache *regcache)
 {
   if (!record_btrace_generating_corefile
-      && record_is_replaying (regcache_get_ptid (regcache)))
+      && record_is_replaying (regcache->ptid ()))
     return;
 
-  this->beneath->prepare_to_store (regcache);
+  this->beneath ()->prepare_to_store (regcache);
 }
 
 /* The branch trace frame cache.  */
@@ -1778,8 +1770,7 @@ record_btrace_frame_sniffer (const struct frame_unwind *self,
   struct frame_info *next;
 
   /* THIS_FRAME does not contain a reference to its thread.  */
-  tp = find_thread_ptid (inferior_ptid);
-  gdb_assert (tp != NULL);
+  tp = inferior_thread ();
 
   bfun = NULL;
   next = get_next_frame (this_frame);
@@ -1845,7 +1836,7 @@ record_btrace_tailcall_frame_sniffer (const struct frame_unwind *self,
   if ((callee->flags & BFUN_UP_LINKS_TO_TAILCALL) == 0)
     return 0;
 
-  tinfo = find_thread_ptid (inferior_ptid);
+  tinfo = inferior_thread ();
   if (btrace_find_call_by_number (&it, &tinfo->btrace, callee->up) == 0)
     return 0;
 
@@ -1956,7 +1947,8 @@ record_btrace_resume_thread (struct thread_info *tp,
   struct btrace_thread_info *btinfo;
 
   DEBUG ("resuming thread %s (%s): %x (%s)", print_thread_id (tp),
-        target_pid_to_str (tp->ptid), flag, btrace_thread_flag_to_str (flag));
+        target_pid_to_str (tp->ptid).c_str (), flag,
+        btrace_thread_flag_to_str (flag));
 
   btinfo = &tp->btrace;
 
@@ -1970,16 +1962,17 @@ record_btrace_resume_thread (struct thread_info *tp,
 
 /* Get the current frame for TP.  */
 
-static struct frame_info *
-get_thread_current_frame (struct thread_info *tp)
+static struct frame_id
+get_thread_current_frame_id (struct thread_info *tp)
 {
-  struct frame_info *frame;
-  ptid_t old_inferior_ptid;
+  struct frame_id id;
   int executing;
 
-  /* Set INFERIOR_PTID, which is implicitly used by get_current_frame.  */
-  old_inferior_ptid = inferior_ptid;
-  inferior_ptid = tp->ptid;
+  /* Set current thread, which is implicitly used by
+     get_current_frame.  */
+  scoped_restore_current_thread restore_thread;
+
+  switch_to_thread (tp);
 
   /* Clear the executing flag to allow changes to the current frame.
      We are not actually running, yet.  We just started a reverse execution
@@ -1988,33 +1981,26 @@ get_thread_current_frame (struct thread_info *tp)
      For the former, EXECUTING is true and we're in wait, about to
      move the thread.  Since we need to recompute the stack, we temporarily
      set EXECUTING to flase.  */
-  executing = is_executing (inferior_ptid);
-  set_executing (inferior_ptid, 0);
+  executing = tp->executing;
+  set_executing (inferior_ptid, false);
 
-  frame = NULL;
-  TRY
+  id = null_frame_id;
+  try
     {
-      frame = get_current_frame ();
+      id = get_frame_id (get_current_frame ());
     }
-  CATCH (except, RETURN_MASK_ALL)
+  catch (const gdb_exception &except)
     {
       /* Restore the previous execution state.  */
       set_executing (inferior_ptid, executing);
 
-      /* Restore the previous inferior_ptid.  */
-      inferior_ptid = old_inferior_ptid;
-
       throw_exception (except);
     }
-  END_CATCH
 
   /* Restore the previous execution state.  */
   set_executing (inferior_ptid, executing);
 
-  /* Restore the previous inferior_ptid.  */
-  inferior_ptid = old_inferior_ptid;
-
-  return frame;
+  return id;
 }
 
 /* Start replaying a thread.  */
@@ -2037,15 +2023,13 @@ record_btrace_start_replaying (struct thread_info *tp)
      Since frames are computed differently when we're replaying, we need to
      recompute those stored frames and fix them up so we can still detect
      subroutines after we started replaying.  */
-  TRY
+  try
     {
-      struct frame_info *frame;
       struct frame_id frame_id;
       int upd_step_frame_id, upd_step_stack_frame_id;
 
       /* The current frame without replaying - computed via normal unwind.  */
-      frame = get_thread_current_frame (tp);
-      frame_id = get_frame_id (frame);
+      frame_id = get_thread_current_frame_id (tp);
 
       /* Check if we need to update any stepping-related frame id's.  */
       upd_step_frame_id = frame_id_eq (frame_id,
@@ -2073,11 +2057,10 @@ record_btrace_start_replaying (struct thread_info *tp)
       btinfo->replay = replay;
 
       /* Make sure we're not using any stale registers.  */
-      registers_changed_ptid (tp->ptid);
+      registers_changed_thread (tp);
 
       /* The current frame with replaying - computed via btrace unwind.  */
-      frame = get_thread_current_frame (tp);
-      frame_id = get_frame_id (frame);
+      frame_id = get_thread_current_frame_id (tp);
 
       /* Replace stepping related frames where necessary.  */
       if (upd_step_frame_id)
@@ -2085,16 +2068,15 @@ record_btrace_start_replaying (struct thread_info *tp)
       if (upd_step_stack_frame_id)
        tp->control.step_stack_frame_id = frame_id;
     }
-  CATCH (except, RETURN_MASK_ALL)
+  catch (const gdb_exception &except)
     {
       xfree (btinfo->replay);
       btinfo->replay = NULL;
 
-      registers_changed_ptid (tp->ptid);
+      registers_changed_thread (tp);
 
       throw_exception (except);
     }
-  END_CATCH
 
   return replay;
 }
@@ -2112,7 +2094,7 @@ record_btrace_stop_replaying (struct thread_info *tp)
   btinfo->replay = NULL;
 
   /* Make sure we're not leaving any stale registers.  */
-  registers_changed_ptid (tp->ptid);
+  registers_changed_thread (tp);
 }
 
 /* Stop replaying TP if it is at the end of its execution history.  */
@@ -2140,10 +2122,9 @@ record_btrace_stop_replaying_at_end (struct thread_info *tp)
 void
 record_btrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
 {
-  struct thread_info *tp;
   enum btrace_thread_flag flag, cflag;
 
-  DEBUG ("resume %s: %s%s", target_pid_to_str (ptid),
+  DEBUG ("resume %s: %s%s", target_pid_to_str (ptid).c_str (),
         ::execution_direction == EXEC_REVERSE ? "reverse-" : "",
         step ? "step" : "cont");
 
@@ -2161,7 +2142,7 @@ record_btrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
   if ((::execution_direction != EXEC_REVERSE)
       && !record_is_replaying (minus_one_ptid))
     {
-      this->beneath->resume (ptid, step, signal);
+      this->beneath ()->resume (ptid, step, signal);
       return;
     }
 
@@ -2183,22 +2164,20 @@ record_btrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
      For all-stop targets, we only step INFERIOR_PTID and continue others.  */
   if (!target_is_non_stop_p ())
     {
-      gdb_assert (ptid_match (inferior_ptid, ptid));
+      gdb_assert (inferior_ptid.matches (ptid));
 
-      ALL_NON_EXITED_THREADS (tp)
-       if (ptid_match (tp->ptid, ptid))
-         {
-           if (ptid_match (tp->ptid, inferior_ptid))
-             record_btrace_resume_thread (tp, flag);
-           else
-             record_btrace_resume_thread (tp, cflag);
-         }
+      for (thread_info *tp : all_non_exited_threads (ptid))
+       {
+         if (tp->ptid.matches (inferior_ptid))
+           record_btrace_resume_thread (tp, flag);
+         else
+           record_btrace_resume_thread (tp, cflag);
+       }
     }
   else
     {
-      ALL_NON_EXITED_THREADS (tp)
-       if (ptid_match (tp->ptid, ptid))
-         record_btrace_resume_thread (tp, flag);
+      for (thread_info *tp : all_non_exited_threads (ptid))
+       record_btrace_resume_thread (tp, flag);
     }
 
   /* Async support.  */
@@ -2216,7 +2195,7 @@ record_btrace_target::commit_resume ()
 {
   if ((::execution_direction != EXEC_REVERSE)
       && !record_is_replaying (minus_one_ptid))
-    beneath->commit_resume ();
+    beneath ()->commit_resume ();
 }
 
 /* Cancel resuming TP.  */
@@ -2232,7 +2211,7 @@ record_btrace_cancel_resume (struct thread_info *tp)
 
   DEBUG ("cancel resume thread %s (%s): %x (%s)",
         print_thread_id (tp),
-        target_pid_to_str (tp->ptid), flags,
+        target_pid_to_str (tp->ptid).c_str (), flags,
         btrace_thread_flag_to_str (flags));
 
   tp->btrace.flags &= ~(BTHR_MOVE | BTHR_STOP);
@@ -2334,7 +2313,6 @@ record_btrace_replay_at_breakpoint (struct thread_info *tp)
   struct btrace_insn_iterator *replay;
   struct btrace_thread_info *btinfo;
   const struct btrace_insn *insn;
-  struct inferior *inf;
 
   btinfo = &tp->btrace;
   replay = btinfo->replay;
@@ -2346,11 +2324,7 @@ record_btrace_replay_at_breakpoint (struct thread_info *tp)
   if (insn == NULL)
     return 0;
 
-  inf = find_inferior_ptid (tp->ptid);
-  if (inf == NULL)
-    return 0;
-
-  return record_check_stopped_by_breakpoint (inf->aspace, insn->pc,
+  return record_check_stopped_by_breakpoint (tp->inf->aspace, insn->pc,
                                             &btinfo->stop_reason);
 }
 
@@ -2465,7 +2439,7 @@ record_btrace_step_thread (struct thread_info *tp)
   btinfo->flags &= ~(BTHR_MOVE | BTHR_STOP);
 
   DEBUG ("stepping thread %s (%s): %x (%s)", print_thread_id (tp),
-        target_pid_to_str (tp->ptid), flags,
+        target_pid_to_str (tp->ptid).c_str (), flags,
         btrace_thread_flag_to_str (flags));
 
   /* We can't step without an execution history.  */
@@ -2519,11 +2493,6 @@ record_btrace_step_thread (struct thread_info *tp)
   return status;
 }
 
-/* A vector of threads.  */
-
-typedef struct thread_info * tp_t;
-DEF_VEC_P (tp_t);
-
 /* Announce further events if necessary.  */
 
 static void
@@ -2555,32 +2524,25 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
   std::vector<thread_info *> moving;
   std::vector<thread_info *> no_history;
 
-  DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid), options);
+  DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid).c_str (), options);
 
   /* As long as we're not replaying, just forward the request.  */
   if ((::execution_direction != EXEC_REVERSE)
       && !record_is_replaying (minus_one_ptid))
     {
-      return this->beneath->wait (ptid, status, options);
+      return this->beneath ()->wait (ptid, status, options);
     }
 
   /* Keep a work list of moving threads.  */
-  {
-    thread_info *tp;
-
-    ALL_NON_EXITED_THREADS (tp)
-      {
-       if (ptid_match (tp->ptid, ptid)
-           && ((tp->btrace.flags & (BTHR_MOVE | BTHR_STOP)) != 0))
-         moving.push_back (tp);
-      }
-  }
+  for (thread_info *tp : all_non_exited_threads (ptid))
+    if ((tp->btrace.flags & (BTHR_MOVE | BTHR_STOP)) != 0)
+      moving.push_back (tp);
 
   if (moving.empty ())
     {
       *status = btrace_step_no_resumed ();
 
-      DEBUG ("wait ended by %s: %s", target_pid_to_str (null_ptid),
+      DEBUG ("wait ended by %s: %s", target_pid_to_str (null_ptid).c_str (),
             target_waitstatus_to_string (status).c_str ());
 
       return null_ptid;
@@ -2655,9 +2617,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
   /* Stop all other threads. */
   if (!target_is_non_stop_p ())
     {
-      thread_info *tp;
-
-      ALL_NON_EXITED_THREADS (tp)
+      for (thread_info *tp : all_non_exited_threads ())
        record_btrace_cancel_resume (tp);
     }
 
@@ -2669,11 +2629,11 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
   record_btrace_clear_histories (&eventing->btrace);
 
   /* We moved the replay position but did not update registers.  */
-  registers_changed_ptid (eventing->ptid);
+  registers_changed_thread (eventing);
 
   DEBUG ("wait ended by thread %s (%s): %s",
         print_thread_id (eventing),
-        target_pid_to_str (eventing->ptid),
+        target_pid_to_str (eventing->ptid).c_str (),
         target_waitstatus_to_string (status).c_str ());
 
   return eventing->ptid;
@@ -2684,24 +2644,21 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
 void
 record_btrace_target::stop (ptid_t ptid)
 {
-  DEBUG ("stop %s", target_pid_to_str (ptid));
+  DEBUG ("stop %s", target_pid_to_str (ptid).c_str ());
 
   /* As long as we're not replaying, just forward the request.  */
   if ((::execution_direction != EXEC_REVERSE)
       && !record_is_replaying (minus_one_ptid))
     {
-      this->beneath->stop (ptid);
+      this->beneath ()->stop (ptid);
     }
   else
     {
-      struct thread_info *tp;
-
-      ALL_NON_EXITED_THREADS (tp)
-       if (ptid_match (tp->ptid, ptid))
-         {
-           tp->btrace.flags &= ~BTHR_MOVE;
-           tp->btrace.flags |= BTHR_STOP;
-         }
+      for (thread_info *tp : all_non_exited_threads (ptid))
+       {
+         tp->btrace.flags &= ~BTHR_MOVE;
+         tp->btrace.flags |= BTHR_STOP;
+       }
     }
  }
 
@@ -2725,7 +2682,7 @@ record_btrace_target::stopped_by_sw_breakpoint ()
       return tp->btrace.stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT;
     }
 
-  return this->beneath->stopped_by_sw_breakpoint ();
+  return this->beneath ()->stopped_by_sw_breakpoint ();
 }
 
 /* The supports_stopped_by_sw_breakpoint method of target
@@ -2737,7 +2694,7 @@ record_btrace_target::supports_stopped_by_sw_breakpoint ()
   if (record_is_replaying (minus_one_ptid))
     return true;
 
-  return this->beneath->supports_stopped_by_sw_breakpoint ();
+  return this->beneath ()->supports_stopped_by_sw_breakpoint ();
 }
 
 /* The stopped_by_sw_breakpoint method of target record-btrace.  */
@@ -2752,7 +2709,7 @@ record_btrace_target::stopped_by_hw_breakpoint ()
       return tp->btrace.stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT;
     }
 
-  return this->beneath->stopped_by_hw_breakpoint ();
+  return this->beneath ()->stopped_by_hw_breakpoint ();
 }
 
 /* The supports_stopped_by_hw_breakpoint method of target
@@ -2764,7 +2721,7 @@ record_btrace_target::supports_stopped_by_hw_breakpoint ()
   if (record_is_replaying (minus_one_ptid))
     return true;
 
-  return this->beneath->supports_stopped_by_hw_breakpoint ();
+  return this->beneath ()->supports_stopped_by_hw_breakpoint ();
 }
 
 /* The update_thread_list method of target record-btrace.  */
@@ -2777,7 +2734,7 @@ record_btrace_target::update_thread_list ()
     return;
 
   /* Forward the request.  */
-  this->beneath->update_thread_list ();
+  this->beneath ()->update_thread_list ();
 }
 
 /* The thread_alive method of target record-btrace.  */
@@ -2787,10 +2744,10 @@ record_btrace_target::thread_alive (ptid_t ptid)
 {
   /* We don't add or remove threads during replay.  */
   if (record_is_replaying (minus_one_ptid))
-    return find_thread_ptid (ptid) != NULL;
+    return true;
 
   /* Forward the request.  */
-  return this->beneath->thread_alive (ptid);
+  return this->beneath ()->thread_alive (ptid);
 }
 
 /* Set the replay branch trace instruction iterator.  If IT is NULL, replay
@@ -2814,13 +2771,14 @@ record_btrace_set_replay (struct thread_info *tp,
        return;
 
       *btinfo->replay = *it;
-      registers_changed_ptid (tp->ptid);
+      registers_changed_thread (tp);
     }
 
   /* Start anew from the new replay position.  */
   record_btrace_clear_histories (btinfo);
 
-  stop_pc = regcache_read_pc (get_current_regcache ());
+  inferior_thread ()->suspend.stop_pc
+    = regcache_read_pc (get_current_regcache ());
   print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
 }
 
@@ -2893,9 +2851,7 @@ record_btrace_target::goto_record (ULONGEST insn)
 void
 record_btrace_target::record_stop_replaying ()
 {
-  struct thread_info *tp;
-
-  ALL_NON_EXITED_THREADS (tp)
+  for (thread_info *tp : all_non_exited_threads ())
     record_btrace_stop_replaying (tp);
 }
 
@@ -2933,16 +2889,15 @@ cmd_record_btrace_bts_start (const char *args, int from_tty)
 
   record_btrace_conf.format = BTRACE_FORMAT_BTS;
 
-  TRY
+  try
     {
       execute_command ("target record-btrace", from_tty);
     }
-  CATCH (exception, RETURN_MASK_ALL)
+  catch (const gdb_exception &exception)
     {
       record_btrace_conf.format = BTRACE_FORMAT_NONE;
       throw_exception (exception);
     }
-  END_CATCH
 }
 
 /* Start recording in Intel Processor Trace format.  */
@@ -2955,16 +2910,15 @@ cmd_record_btrace_pt_start (const char *args, int from_tty)
 
   record_btrace_conf.format = BTRACE_FORMAT_PT;
 
-  TRY
+  try
     {
       execute_command ("target record-btrace", from_tty);
     }
-  CATCH (exception, RETURN_MASK_ALL)
+  catch (const gdb_exception &exception)
     {
       record_btrace_conf.format = BTRACE_FORMAT_NONE;
       throw_exception (exception);
     }
-  END_CATCH
 }
 
 /* Alias for "target record".  */
@@ -2977,26 +2931,24 @@ cmd_record_btrace_start (const char *args, int from_tty)
 
   record_btrace_conf.format = BTRACE_FORMAT_PT;
 
-  TRY
+  try
     {
       execute_command ("target record-btrace", from_tty);
     }
-  CATCH (exception, RETURN_MASK_ALL)
+  catch (const gdb_exception &exception)
     {
       record_btrace_conf.format = BTRACE_FORMAT_BTS;
 
-      TRY
+      try
        {
          execute_command ("target record-btrace", from_tty);
        }
-      CATCH (exception, RETURN_MASK_ALL)
+      catch (const gdb_exception &ex)
        {
          record_btrace_conf.format = BTRACE_FORMAT_NONE;
-         throw_exception (exception);
+         throw_exception (ex);
        }
-      END_CATCH
     }
-  END_CATCH
 }
 
 /* The "set record btrace" command.  */
@@ -3099,8 +3051,6 @@ cmd_set_record_btrace_cpu (const char *args, int from_tty)
 static void
 cmd_show_record_btrace_cpu (const char *args, int from_tty)
 {
-  const char *cpu;
-
   if (args != nullptr && *args != 0)
     error (_("Trailing junk: '%s'."), args);
 
@@ -3245,8 +3195,8 @@ replay."),
   add_prefix_cmd ("cpu", class_support, cmd_set_record_btrace_cpu,
                  _("\
 Set the cpu to be used for trace decode.\n\n\
-The format is \"<vendor>:<identifier>\" or \"none\" or \"auto\" (default).\n\
-For vendor \"intel\" the format is \"<family>/<model>[/<stepping>]\".\n\n\
+The format is \"VENDOR:IDENTIFIER\" or \"none\" or \"auto\" (default).\n\
+For vendor \"intel\" the format is \"FAMILY/MODEL[/STEPPING]\".\n\n\
 When decoding branch trace, enable errata workarounds for the specified cpu.\n\
 The default is \"auto\", which uses the cpu on which the trace was recorded.\n\
 When GDB does not support that cpu, this option can be used to enable\n\
This page took 0.03773 seconds and 4 git commands to generate.