[Lldb-commits] [PATCH] D45497: Don't assume the backing thread shares a Protocol ID

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 10 11:32:21 PDT 2018


JDevlieghere created this revision.
JDevlieghere added reviewers: jingham, clayborg.

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


Repository:
  rL LLVM

https://reviews.llvm.org/D45497

Files:
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp


Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1820,11 +1820,13 @@
       if (!thread_sp->StopInfoIsUpToDate()) {
         thread_sp->SetStopInfo(StopInfoSP());
         // If there's a memory thread backed by this thread, we need to use it
-        // to calcualte StopInfo.
-        ThreadSP memory_thread_sp =
-            m_thread_list.FindThreadByProtocolID(thread_sp->GetProtocolID());
-        if (memory_thread_sp)
-          thread_sp = memory_thread_sp;
+        // to calculate StopInfo.
+        size_t num_threads = m_thread_list.GetSize(false);
+        for (size_t i = 0; i < num_threads; ++i) {
+          ThreadSP mem_thread = m_thread_list.GetThreadAtIndex(i, false);
+          if (mem_thread && mem_thread->GetBackingThread() == thread_sp)
+            thread_sp = mem_thread;
+        }
 
         if (exc_type != 0) {
           const size_t exc_data_size = exc_data.size();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45497.141884.patch
Type: text/x-patch
Size: 1102 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180410/7be7c837/attachment.bin>


More information about the lldb-commits mailing list