+2020-12-11  Tom Tromey  <tom@tromey.com>
+
+       * infrun.c (struct stop_context) <thread>: Now a thread_info_ref.
+       (stop_context::stop_context): Update.
+       (stop_context::~stop_context): Remove.
+
 2020-12-11  Tom Tromey  <tom@tromey.com>
 
        * inferior.c (current_inferior_): Change type.
 
 struct stop_context
 {
   stop_context ();
-  ~stop_context ();
 
   DISABLE_COPY_AND_ASSIGN (stop_context);
 
 
   /* If stopp for a thread event, this is the thread that caused the
      stop.  */
-  struct thread_info *thread;
+  thread_info_ref thread;
 
   /* The inferior that caused the stop.  */
   int inf_num;
     {
       /* Take a strong reference so that the thread can't be deleted
         yet.  */
-      thread = inferior_thread ();
-      thread->incref ();
+      thread = thread_info_ref::new_reference (inferior_thread ());
     }
-  else
-    thread = NULL;
-}
-
-/* Release a stop context previously created with save_stop_context.
-   Releases the strong reference to the thread as well. */
-
-stop_context::~stop_context ()
-{
-  if (thread != NULL)
-    thread->decref ();
 }
 
 /* Return true if the current context no longer matches the saved stop