Multi-target support
[deliverable/binutils-gdb.git] / gdb / record-btrace.c
index c923b365c48d1a178256ba793c5430c0ac508b66..7e5b7860df6ee5d8c7de9c00a45660b823827f1b 100644 (file)
@@ -1,6 +1,6 @@
 /* Branch trace support for GDB, the GNU debugger.
 
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
+   Copyright (C) 2013-2020 Free Software Foundation, Inc.
 
    Contributed by Intel Corp. <markus.t.metzger@intel.com>
 
@@ -38,7 +38,6 @@
 #include "infrun.h"
 #include "event-loop.h"
 #include "inf-loop.h"
-#include "gdbsupport/vec.h"
 #include "inferior.h"
 #include <algorithm>
 #include "gdbarch.h"
@@ -557,10 +556,11 @@ record_btrace_target::info_record ()
 
   DEBUG ("info");
 
-  tp = find_thread_ptid (inferior_ptid);
-  if (tp == NULL)
+  if (inferior_ptid == null_ptid)
     error (_("No thread."));
 
+  tp = inferior_thread ();
+
   validate_registers_access ();
 
   btinfo = &tp->btrace;
@@ -1116,9 +1116,9 @@ btrace_get_bfun_name (const struct btrace_function *bfun)
   sym = bfun->sym;
 
   if (sym != NULL)
-    return SYMBOL_PRINT_NAME (sym);
+    return sym->print_name ();
   else if (msym != NULL)
-    return MSYMBOL_PRINT_NAME (msym);
+    return msym->print_name ();
   else
     return "??";
 }
@@ -1176,10 +1176,10 @@ btrace_call_history (struct ui_out *uiout,
        }
 
       if (sym != NULL)
-       uiout->field_string ("function", SYMBOL_PRINT_NAME (sym),
+       uiout->field_string ("function", sym->print_name (),
                             function_name_style.style ());
       else if (msym != NULL)
-       uiout->field_string ("function", MSYMBOL_PRINT_NAME (msym),
+       uiout->field_string ("function", msym->print_name (),
                             function_name_style.style ());
       else if (!uiout->is_mi_like_p ())
        uiout->field_string ("function", "??",
@@ -1374,7 +1374,8 @@ record_btrace_target::call_history_from (ULONGEST from, int size,
 enum record_method
 record_btrace_target::record_method (ptid_t ptid)
 {
-  struct thread_info * const tp = find_thread_ptid (ptid);
+  process_stratum_target *proc_target = current_inferior ()->process_target ();
+  thread_info *const tp = find_thread_ptid (proc_target, ptid);
 
   if (tp == NULL)
     error (_("No thread."));
@@ -1390,7 +1391,8 @@ record_btrace_target::record_method (ptid_t ptid)
 bool
 record_btrace_target::record_is_replaying (ptid_t ptid)
 {
-  for (thread_info *tp : all_non_exited_threads (ptid))
+  process_stratum_target *proc_target = current_inferior ()->process_target ();
+  for (thread_info *tp : all_non_exited_threads (proc_target, ptid))
     if (btrace_is_replaying (tp))
       return true;
 
@@ -1520,13 +1522,10 @@ record_btrace_target::remove_breakpoint (struct gdbarch *gdbarch,
 void
 record_btrace_target::fetch_registers (struct regcache *regcache, int regno)
 {
-  struct btrace_insn_iterator *replay;
-  struct thread_info *tp;
-
-  tp = find_thread_ptid (regcache->ptid ());
+  thread_info *tp = find_thread_ptid (regcache->target (), regcache->ptid ());
   gdb_assert (tp != NULL);
 
-  replay = tp->btrace.replay;
+  btrace_insn_iterator *replay = tp->btrace.replay;
   if (replay != NULL && !record_btrace_generating_corefile)
     {
       const struct btrace_insn *insn;
@@ -1862,7 +1861,7 @@ record_btrace_frame_dealloc_cache (struct frame_info *self, void *this_cache)
 }
 
 /* btrace recording does not store previous memory content, neither the stack
-   frames content.  Any unwinding would return errorneous results as the stack
+   frames content.  Any unwinding would return erroneous results as the stack
    contents no longer matches the changed PC value restored from history.
    Therefore this unwinder reports any possibly unwound registers as
    <unavailable>.  */
@@ -1967,15 +1966,17 @@ get_thread_current_frame_id (struct thread_info *tp)
 
   switch_to_thread (tp);
 
+  process_stratum_target *proc_target = tp->inf->process_target ();
+
   /* Clear the executing flag to allow changes to the current frame.
      We are not actually running, yet.  We just started a reverse execution
      command or a record goto command.
      For the latter, EXECUTING is false and this has no effect.
      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.  */
+     set EXECUTING to false.  */
   executing = tp->executing;
-  set_executing (inferior_ptid, false);
+  set_executing (proc_target, inferior_ptid, false);
 
   id = null_frame_id;
   try
@@ -1985,13 +1986,13 @@ get_thread_current_frame_id (struct thread_info *tp)
   catch (const gdb_exception &except)
     {
       /* Restore the previous execution state.  */
-      set_executing (inferior_ptid, executing);
+      set_executing (proc_target, inferior_ptid, executing);
 
       throw;
     }
 
   /* Restore the previous execution state.  */
-  set_executing (inferior_ptid, executing);
+  set_executing (proc_target, inferior_ptid, executing);
 
   return id;
 }
@@ -2155,11 +2156,14 @@ record_btrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
      record_btrace_wait below.
 
      For all-stop targets, we only step INFERIOR_PTID and continue others.  */
+
+  process_stratum_target *proc_target = current_inferior ()->process_target ();
+
   if (!target_is_non_stop_p ())
     {
       gdb_assert (inferior_ptid.matches (ptid));
 
-      for (thread_info *tp : all_non_exited_threads (ptid))
+      for (thread_info *tp : all_non_exited_threads (proc_target, ptid))
        {
          if (tp->ptid.matches (inferior_ptid))
            record_btrace_resume_thread (tp, flag);
@@ -2169,7 +2173,7 @@ record_btrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
     }
   else
     {
-      for (thread_info *tp : all_non_exited_threads (ptid))
+      for (thread_info *tp : all_non_exited_threads (proc_target, ptid))
        record_btrace_resume_thread (tp, flag);
     }
 
@@ -2527,7 +2531,8 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status,
     }
 
   /* Keep a work list of moving threads.  */
-  for (thread_info *tp : all_non_exited_threads (ptid))
+  process_stratum_target *proc_target = current_inferior ()->process_target ();
+  for (thread_info *tp : all_non_exited_threads (proc_target, ptid))
     if ((tp->btrace.flags & (BTHR_MOVE | BTHR_STOP)) != 0)
       moving.push_back (tp);
 
@@ -2647,7 +2652,10 @@ record_btrace_target::stop (ptid_t ptid)
     }
   else
     {
-      for (thread_info *tp : all_non_exited_threads (ptid))
+      process_stratum_target *proc_target
+       = current_inferior ()->process_target ();
+
+      for (thread_info *tp : all_non_exited_threads (proc_target, ptid))
        {
          tp->btrace.flags &= ~BTHR_MOVE;
          tp->btrace.flags |= BTHR_STOP;
This page took 0.028599 seconds and 4 git commands to generate.