[v2,01/12] Call add_active_thread after pushing the ravenscar target

Message ID 20200805190841.2506771-2-tromey@adacore.com
State New
Headers show
Series
  • Fix Ravenscar regressions
Related show

Commit Message

Tom Tromey Aug. 5, 2020, 7:08 p.m.
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.

2019-03-26  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          |  8 ++++++++
 gdb/ravenscar-thread.c | 13 +++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

-- 
2.26.2

Patch

diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 72253188c71..7fca51da2a7 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -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 @@  struct ravenscar_thread_target final : public target_ops
      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