Skip to content

Commit b19eb1c

Browse files
fixup! Address review comments
1 parent 0c9d9ed commit b19eb1c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lldb/include/lldb/Target/Thread.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,19 @@ class Thread : public std::enable_shared_from_this<Thread>,
470470

471471
virtual void ClearStackFrames();
472472

473-
/// Derived classes implementing SetBackingThread should use this to provide
474-
/// bidirectional access to the Backing-Backed relationship.
473+
/// Sets the thread that is backed by this thread.
474+
/// If backed_thread.GetBackedThread() is null, this method also calls
475+
/// backed_thread.SetBackedThread(this).
476+
/// If backed_thread.GetBackedThread() is non-null, asserts that it is equal
477+
/// to `this`.
475478
void SetBackedThread(Thread &backed_thread) {
476-
assert(backed_thread.GetBackingThread().get() == this);
477479
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());
478486
}
479487

480488
void ClearBackedThread() { m_backed_thread.reset(); }

0 commit comments

Comments
 (0)