[binutils-gdb] Don't write to inferior_ptid in tracefile-tfile.c

Pedro Alves palves@sourceware.org
Thu Jun 18 22:26:27 GMT 2020


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=087e161b3cd9a8626dc05ce1bdb8dfaf353a71b1

commit 087e161b3cd9a8626dc05ce1bdb8dfaf353a71b1
Author: Pedro Alves <palves@redhat.com>
Date:   Thu Jun 18 21:28:23 2020 +0100

    Don't write to inferior_ptid in tracefile-tfile.c
    
    gdb/ChangeLog:
    2020-06-18  Pedro Alves  <palves@redhat.com>
    
            * tracefile-tfile.c (tfile_target_open): Don't write to
            inferior_ptid directly, instead switch to added thread.
            (tfile_target::close): Use switch_to_no_thread instead of writing
            to inferior_ptid directly.

Diff:
---
 gdb/ChangeLog         | 7 +++++++
 gdb/tracefile-tfile.c | 7 ++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2a082f277b8..4454a58ca67 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2020-06-18  Pedro Alves  <palves@redhat.com>
+
+	* tracefile-tfile.c (tfile_target_open): Don't write to
+	inferior_ptid directly, instead switch to added thread.
+	(tfile_target::close): Use switch_to_no_thread instead of writing
+	to inferior_ptid directly.
+
 2020-06-18  Pedro Alves  <palves@redhat.com>
 
 	* procfs.c (procfs_target::attach): Don't write to inferior_ptid.
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
index ea191774751..fd7bab822a1 100644
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -556,8 +556,9 @@ tfile_target_open (const char *arg, int from_tty)
     }
 
   inferior_appeared (current_inferior (), TFILE_PID);
-  inferior_ptid = ptid_t (TFILE_PID);
-  add_thread_silent (&tfile_ops, inferior_ptid);
+
+  thread_info *thr = add_thread_silent (&tfile_ops, ptid_t (TFILE_PID));
+  switch_to_thread (thr);
 
   if (ts->traceframe_count <= 0)
     warning (_("No traceframes present in this file."));
@@ -618,7 +619,7 @@ tfile_target::close ()
 {
   gdb_assert (trace_fd != -1);
 
-  inferior_ptid = null_ptid;	/* Avoid confusion from thread stuff.  */
+  switch_to_no_thread ();	/* Avoid confusion from thread stuff.  */
   exit_inferior_silent (current_inferior ());
 
   ::close (trace_fd);


More information about the Gdb-cvs mailing list