Change inferior thread list to be a thread map
[deliverable/binutils-gdb.git] / gdb / thread-iter.c
index a6bbc50185a8f4ab45ced0fed307260821462f28..b7cf4d0e1c94a6e518517856b54b6d3f81da0f47 100644 (file)
@@ -27,8 +27,13 @@ all_threads_iterator::all_threads_iterator (begin_t)
 {
   /* Advance M_INF/M_THR to the first thread's position.  */
   for (m_inf = inferior_list; m_inf != NULL; m_inf = m_inf->next)
-    if ((m_thr = m_inf->thread_list) != NULL)
-      return;
+    {
+      if (!m_inf->thread_map.empty())
+       {
+         this->m_thr_iter = m_inf->thread_map.cbegin ();
+         return;
+       }
+    }
 }
 
 /* See thread-iter.h.  */
@@ -43,16 +48,24 @@ all_threads_iterator::advance ()
 
   for (; m_inf != NULL; m_inf = m_inf->next)
     {
-      m_thr = m_inf->thread_list;
-      while (m_thr != NULL)
+      m_thr_iter = m_inf->thread_map.cbegin ();
+      while (m_thr_iter != m_inf->thread_map.cend ())
        {
          return;
        start:
-         m_thr = m_thr->next;
+         ++m_thr_iter;
        }
     }
 }
 
+thread_info *all_threads_iterator::operator* () const
+{
+  gdb_assert (m_inf != NULL);
+  gdb_assert (m_thr_iter != m_inf->thread_map.cend ());
+
+  return m_thr_iter->second;
+}
+
 /* See thread-iter.h.  */
 
 bool
@@ -74,12 +87,19 @@ all_matching_threads_iterator::all_matching_threads_iterator
   gdb_assert ((filter_target == nullptr && filter_ptid == minus_one_ptid)
              || filter_target->stratum () == process_stratum);
 
-  m_thr = nullptr;
   for (m_inf = inferior_list; m_inf != NULL; m_inf = m_inf->next)
-    if (m_inf_matches ())
-      for (m_thr = m_inf->thread_list; m_thr != NULL; m_thr = m_thr->next)
-       if (m_thr->ptid.matches (m_filter_ptid))
-         return;
+    {
+      if (!m_inf->thread_map.empty () && m_inf_matches ())
+       {
+         for (m_thr_iter = m_inf->thread_map.cbegin ();
+              m_thr_iter != m_inf->thread_map.cend ();
+              m_thr_iter++)
+           {
+             if (m_thr_iter->second->ptid.matches (m_filter_ptid))
+               return;
+           }
+       }
+    }
 }
 
 /* See thread-iter.h.  */
@@ -95,13 +115,20 @@ all_matching_threads_iterator::advance ()
   for (; m_inf != NULL; m_inf = m_inf->next)
     if (m_inf_matches ())
       {
-       m_thr = m_inf->thread_list;
-       while (m_thr != NULL)
+       m_thr_iter = m_inf->thread_map.cbegin ();
+       while (m_thr_iter != m_inf->thread_map.cend ())
          {
-           if (m_thr->ptid.matches (m_filter_ptid))
+           if (m_thr_iter->second->ptid.matches (m_filter_ptid))
              return;
          start:
-           m_thr = m_thr->next;
+           ++m_thr_iter;
          }
       }
 }
+
+thread_info *all_matching_threads_iterator::operator* () const
+{
+  gdb_assert (m_inf != nullptr);
+
+  return m_thr_iter->second;
+}
This page took 0.041356 seconds and 4 git commands to generate.