Use thread_info_ref in stop_context
authorTom Tromey <tom@tromey.com>
Fri, 11 Dec 2020 16:21:53 +0000 (09:21 -0700)
committerTom Tromey <tom@tromey.com>
Fri, 11 Dec 2020 16:21:54 +0000 (09:21 -0700)
This changes stop_context to use a thread_info_ref, removing some
manual reference counting.

gdb/ChangeLog
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.

gdb/ChangeLog
gdb/infrun.c

index 3d97380727ba48bd31f8447585b575c4c33876b9..98b7c137e26d763817bb647017496f2b28ecfbd3 100644 (file)
@@ -1,3 +1,9 @@
+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.
index e7b69ae5a5cf1a96b98fc249004050b3c137e3e6..793a7d2badd99eff92236ebfdc4f94ed1350a0e4 100644 (file)
@@ -8097,7 +8097,6 @@ maybe_remove_breakpoints (void)
 struct stop_context
 {
   stop_context ();
-  ~stop_context ();
 
   DISABLE_COPY_AND_ASSIGN (stop_context);
 
@@ -8112,7 +8111,7 @@ struct 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;
@@ -8131,20 +8130,8 @@ stop_context::stop_context ()
     {
       /* 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