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
I would add a new function to ThreadList:
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: