Call add_active_thread after pushing the ravenscar target
authorTom Tromey <tromey@adacore.com>
Fri, 7 Aug 2020 16:26:45 +0000 (10:26 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 7 Aug 2020 16:26:45 +0000 (10:26 -0600)
Currently ravenscar-thread.c calls add_active_thread before pushing
the ravenscar target.  This yields an initial thread announcement of
"[Thread 0]".  Calling add_active_thread after pushing the target
fixes this.

gdb/ChangeLog
2020-08-07  Tom Tromey  <tromey@adacore.com>

* ravenscar-thread.c (ravenscar_thread_target): Don't call
add_active_thread.
(ravenscar_thread_target::add_active_thread): Now public.
(ravenscar_inferior_created): Call add_active_thread after pushing
the target.

gdb/ChangeLog
gdb/ravenscar-thread.c

index 88583bd73d54762b121da708d01d436475215cde..81d0527c59c0ace30d148dd9126bdd7b8d1a1ae9 100644 (file)
@@ -1,3 +1,11 @@
+2020-08-07  Tom Tromey  <tromey@adacore.com>
+
+       * ravenscar-thread.c (ravenscar_thread_target): Don't call
+       add_active_thread.
+       (ravenscar_thread_target::add_active_thread): Now public.
+       (ravenscar_inferior_created): Call add_active_thread after pushing
+       the target.
+
 2020-08-07  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * regcache.c (ptid_regcache_map): New type.
index 72253188c716ec94ff6831a02507fc3e72c11682..7fca51da2a79f9271449d5462af6279351871717 100644 (file)
@@ -79,9 +79,6 @@ struct ravenscar_thread_target final : public target_ops
   ravenscar_thread_target ()
     : m_base_ptid (inferior_ptid)
   {
-    thread_info *thr = add_active_thread ();
-    if (thr != nullptr)
-      switch_to_thread (thr);
   }
 
   const target_info &info () const override
@@ -124,6 +121,8 @@ struct ravenscar_thread_target final : public target_ops
     delete this;
   }
 
+  thread_info *add_active_thread ();
+
 private:
 
   /* PTID of the last thread that received an event.
@@ -131,7 +130,6 @@ private:
      the event, to make it the current task.  */
   ptid_t m_base_ptid;
 
-  thread_info *add_active_thread ();
   ptid_t active_task (int cpu);
   bool task_is_currently_active (ptid_t ptid);
   bool runtime_initialized ();
@@ -548,8 +546,11 @@ ravenscar_inferior_created (struct target_ops *target, int from_tty)
       return;
     }
 
-  target_ops_up target_holder (new ravenscar_thread_target ());
-  push_target (std::move (target_holder));
+  ravenscar_thread_target *rtarget = new ravenscar_thread_target ();
+  push_target (target_ops_up (rtarget));
+  thread_info *thr = rtarget->add_active_thread ();
+  if (thr != nullptr)
+    switch_to_thread (thr);
 }
 
 ptid_t