This is an archive of the discontinued LLVM Phabricator instance.

Don't assume the backing thread shares a Protocol ID
ClosedPublic

Authored by JDevlieghere on Apr 10 2018, 11:32 AM.

Details

Summary

When we're dealing with virtual (memory) threads created by the OS
plugins, there's no guarantee that the real thread and the backing
thread share a protocol ID. Instead, we should iterate over the memory
threads to find the virtual thread that is backed by the current real
thread.

rdar://36485830

Diff Detail

Repository
rL LLVM

Event Timeline

JDevlieghere created this revision.Apr 10 2018, 11:32 AM

(I'll update the diff once I've figured out how to test this)

clayborg requested changes to this revision.Apr 10 2018, 11:42 AM
clayborg added inline comments.
source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
1826–1827 ↗(On Diff #141884)

I would add a new function to ThreadList:

ThreadSP ThreadList::GetBackingThread(const ThreadSP &real_thread);

Since there is a mutex inside the thread list, we don't want another thread to be able to mutate the thread list while doing this iteration. So this code would become:

ThreadSP memory_thread_sp = m_thread_list.GetBackingThread(thread_sp);
if (memory_thread_sp)
  thread_sp = memory_thread_sp;
This revision now requires changes to proceed.Apr 10 2018, 11:42 AM
  • Address Greg's comment and factor out the method.
  • Add a test case.
JDevlieghere marked an inline comment as done.Apr 11 2018, 5:40 AM
JDevlieghere added a subscriber: labath.
clayborg accepted this revision.Apr 11 2018, 10:39 PM
This revision is now accepted and ready to land.Apr 11 2018, 10:39 PM
This revision was automatically updated to reflect the committed changes.