Mention virtual tables in Python dynamic_type documentation
[deliverable/binutils-gdb.git] / gdb / record-btrace.c
index 35c8421525ff7f0f75a3e13a7b719d7ef0d60b01..eafecd967d904d55c0e39c6642a530023b989e6f 100644 (file)
@@ -39,6 +39,7 @@
 #include "event-loop.h"
 #include "inf-loop.h"
 #include "vec.h"
+#include "inferior.h"
 #include <algorithm>
 
 static const target_info record_btrace_target_info = {
@@ -244,14 +245,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 ());
@@ -423,7 +423,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);
@@ -462,7 +462,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.  */
@@ -1401,7 +1401,7 @@ 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))
+    if (tp->ptid.matches (ptid) && btrace_is_replaying (tp))
       return true;
 
   return false;
@@ -1463,8 +1463,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.  */
@@ -1484,7 +1484,7 @@ record_btrace_target::insert_breakpoint (struct gdbarch *gdbarch,
   ret = 0;
   TRY
     {
-      ret = this->beneath->insert_breakpoint (gdbarch, bp_tgt);
+      ret = this->beneath ()->insert_breakpoint (gdbarch, bp_tgt);
     }
   CATCH (except, RETURN_MASK_ALL)
     {
@@ -1515,7 +1515,7 @@ record_btrace_target::remove_breakpoint (struct gdbarch *gdbarch,
   ret = 0;
   TRY
     {
-      ret = this->beneath->remove_breakpoint (gdbarch, bp_tgt, reason);
+      ret = this->beneath ()->remove_breakpoint (gdbarch, bp_tgt, reason);
     }
   CATCH (except, RETURN_MASK_ALL)
     {
@@ -1558,10 +1558,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 +1569,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->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.  */
@@ -1589,7 +1587,7 @@ record_btrace_target::prepare_to_store (struct regcache *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 +1776,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 +1842,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;
 
@@ -1977,9 +1974,11 @@ get_thread_current_frame (struct thread_info *tp)
   ptid_t old_inferior_ptid;
   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,8 +1987,8 @@ 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
@@ -2001,9 +2000,6 @@ get_thread_current_frame (struct thread_info *tp)
       /* 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
@@ -2011,9 +2007,6 @@ get_thread_current_frame (struct thread_info *tp)
   /* Restore the previous execution state.  */
   set_executing (inferior_ptid, executing);
 
-  /* Restore the previous inferior_ptid.  */
-  inferior_ptid = old_inferior_ptid;
-
   return frame;
 }
 
@@ -2073,7 +2066,7 @@ 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);
@@ -2090,7 +2083,7 @@ record_btrace_start_replaying (struct thread_info *tp)
       xfree (btinfo->replay);
       btinfo->replay = NULL;
 
-      registers_changed_ptid (tp->ptid);
+      registers_changed_thread (tp);
 
       throw_exception (except);
     }
@@ -2112,7 +2105,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.  */
@@ -2161,7 +2154,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,12 +2176,12 @@ 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 (tp->ptid.matches (ptid))
          {
-           if (ptid_match (tp->ptid, inferior_ptid))
+           if (tp->ptid.matches (inferior_ptid))
              record_btrace_resume_thread (tp, flag);
            else
              record_btrace_resume_thread (tp, cflag);
@@ -2197,7 +2190,7 @@ record_btrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
   else
     {
       ALL_NON_EXITED_THREADS (tp)
-       if (ptid_match (tp->ptid, ptid))
+       if (tp->ptid.matches (ptid))
          record_btrace_resume_thread (tp, flag);
     }
 
@@ -2216,7 +2209,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.  */
@@ -2334,7 +2327,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 +2338,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);
 }
 
@@ -2556,7 +2544,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
   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.  */
@@ -2565,7 +2553,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
 
     ALL_NON_EXITED_THREADS (tp)
       {
-       if (ptid_match (tp->ptid, ptid)
+       if (tp->ptid.matches (ptid)
            && ((tp->btrace.flags & (BTHR_MOVE | BTHR_STOP)) != 0))
          moving.push_back (tp);
       }
@@ -2664,7 +2652,7 @@ 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),
@@ -2685,14 +2673,14 @@ record_btrace_target::stop (ptid_t ptid)
   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))
+       if (tp->ptid.matches (ptid))
          {
            tp->btrace.flags &= ~BTHR_MOVE;
            tp->btrace.flags |= BTHR_STOP;
@@ -2720,7 +2708,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
@@ -2732,7 +2720,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.  */
@@ -2747,7 +2735,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
@@ -2759,7 +2747,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.  */
@@ -2772,7 +2760,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.  */
@@ -2782,10 +2770,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
@@ -2809,13 +2797,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);
 }
 
@@ -3094,8 +3083,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);
 
This page took 0.030934 seconds and 4 git commands to generate.