[10/28] Don't write to inferior_ptid in tracectf.c

Message ID 20200414175434.8047-11-palves@redhat.com
State New
Headers show
Series
  • Decouple inferior_ptid/inferior_thread(); dup ptids in thread list (PR/25412)
Related show

Commit Message

Simon Marchi via Gdb-patches April 14, 2020, 5:54 p.m.
gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	* tracectf.c (ctf_target_open): Switch to added thread instead of
	writing to inferior_ptid directly.
	(ctf_target::close): Use switch_to_no_thread instead of writing to
	inferior_ptid directly.
---
 gdb/tracectf.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

-- 
2.14.5

Patch

diff --git a/gdb/tracectf.c b/gdb/tracectf.c
index 1c7003c2c9..2c9a7495bf 100644
--- a/gdb/tracectf.c
+++ b/gdb/tracectf.c
@@ -1168,8 +1168,9 @@  ctf_target_open (const char *dirname, int from_tty)
   push_target (&ctf_ops);
 
   inferior_appeared (current_inferior (), CTF_PID);
-  inferior_ptid = ptid_t (CTF_PID);
-  add_thread_silent (&ctf_ops, inferior_ptid);
+
+  thread_info *thr = add_thread_silent (&ctf_ops, ptid_t (CTF_PID));
+  switch_to_thread (thr);
 
   merge_uploaded_trace_state_variables (&uploaded_tsvs);
   merge_uploaded_tracepoints (&uploaded_tps);
@@ -1187,7 +1188,7 @@  ctf_target::close ()
   xfree (trace_dirname);
   trace_dirname = NULL;
 
-  inferior_ptid = null_ptid;	/* Avoid confusion from thread stuff.  */
+  switch_to_no_thread ();	/* Avoid confusion from thread stuff.  */
   exit_inferior_silent (current_inferior ());
 
   trace_reset_local_state ();