@@ -470,6 +470,26 @@ class Thread : public std::enable_shared_from_this<Thread>,
470470
471471 virtual void ClearStackFrames ();
472472
473+ // / Sets the thread that is backed by this thread.
474+ // / If backed_thread.GetBackedThread() is null, this method also calls
475+ // / backed_thread.SetBackingThread(this).
476+ // / If backed_thread.GetBackedThread() is non-null, asserts that it is equal
477+ // / to `this`.
478+ void SetBackedThread (Thread &backed_thread) {
479+ m_backed_thread = backed_thread.shared_from_this ();
480+
481+ // Ensure the bidrectional relationship is preserved.
482+ Thread *backing_thread = backed_thread.GetBackingThread ().get ();
483+ assert (backing_thread == nullptr || backing_thread == this );
484+ if (backing_thread == nullptr )
485+ backed_thread.SetBackingThread (shared_from_this ());
486+ }
487+
488+ void ClearBackedThread () { m_backed_thread.reset (); }
489+
490+ // / Returns the thread that is backed by this thread, if any.
491+ lldb::ThreadSP GetBackedThread () const { return m_backed_thread.lock (); }
492+
473493 virtual bool SetBackingThread (const lldb::ThreadSP &thread_sp) {
474494 return false ;
475495 }
@@ -1349,6 +1369,9 @@ class Thread : public std::enable_shared_from_this<Thread>,
13491369 LazyBool m_override_should_notify;
13501370 mutable std::unique_ptr<ThreadPlanStack> m_null_plan_stack_up;
13511371
1372+ // / The Thread backed by this thread, if any.
1373+ lldb::ThreadWP m_backed_thread;
1374+
13521375private:
13531376 bool m_extended_info_fetched; // Have we tried to retrieve the m_extended_info
13541377 // for this thread?
0 commit comments