Don't write to inferior_ptid in btrace_fetch
authorPedro Alves <palves@redhat.com>
Thu, 18 Jun 2020 20:28:31 +0000 (21:28 +0100)
committerPedro Alves <palves@redhat.com>
Thu, 18 Jun 2020 22:14:15 +0000 (23:14 +0100)
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

* btrace.c (btrace_fetch): Use switch_to_thread instead of writing
to inferior_ptid.

gdb/ChangeLog
gdb/btrace.c

index c465a4d36d53462c8ff00d7e8f3024b7269b9cff..2f3c1e5887488866dee543dacc5b808e24f02d0c 100644 (file)
@@ -1,3 +1,8 @@
+2020-06-18  Pedro Alves  <palves@redhat.com>
+
+       * btrace.c (btrace_fetch): Use switch_to_thread instead of writing
+       to inferior_ptid.
+
 2020-06-18  Pedro Alves  <palves@redhat.com>
 
        * bsd-kvm.c (bsd_kvm_target::close): Use switch_to_no_thread
index d41e3c4f8f91ac102a76207437a80b1545590f1b..2a0c61de766a53ecb370149f9b6c340a7e86d2d3 100644 (file)
@@ -1910,11 +1910,12 @@ btrace_fetch (struct thread_info *tp, const struct btrace_cpu *cpu)
   if (btinfo->replay != NULL)
     return;
 
-  /* With CLI usage, TP->PTID always equals INFERIOR_PTID here.  Now that we
-     can store a gdb.Record object in Python referring to a different thread
-     than the current one, temporarily set INFERIOR_PTID.  */
-  scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
-  inferior_ptid = tp->ptid;
+  /* With CLI usage, TP is always the current thread when we get here.
+     However, since we can also store a gdb.Record object in Python
+     referring to a different thread than the current one, we need to
+     temporarily set the current thread.  */
+  scoped_restore_current_thread restore_thread;
+  switch_to_thread (tp);
 
   /* We should not be called on running or exited threads.  */
   gdb_assert (can_access_registers_thread (tp));