1 //===-- ThreadList.h --------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ThreadList_h_
11 #define liblldb_ThreadList_h_
15 #include "lldb/lldb-private.h"
16 #include "lldb/Core/UserID.h"
17 #include "lldb/Utility/Iterable.h"
20 // FIXME: Currently this is a thread list with lots of functionality for use only by
21 // the process for which this is the thread list. If we ever want a container class
22 // to hand out that is just a random subset of threads, with iterator functionality,
23 // then we should make that part a base class, and make a ProcessThreadList for the
25 namespace lldb_private {
33 ThreadList (Process *process);
35 ThreadList (const ThreadList &rhs);
40 operator = (const ThreadList& rhs);
43 GetSize(bool can_update = true);
46 AddThread (const lldb::ThreadSP &thread_sp);
49 InsertThread (const lldb::ThreadSP &thread_sp, uint32_t idx);
50 // Return the selected thread if there is one. Otherwise, return the thread
51 // selected at index 0.
56 SetSelectedThreadByID (lldb::tid_t tid, bool notify = false);
59 SetSelectedThreadByIndexID (uint32_t index_id, bool notify = false);
70 // Note that "idx" is not the same as the "thread_index". It is a zero
71 // based index to accessing the current threads, whereas "thread_index"
72 // is a unique index assigned
74 GetThreadAtIndex (uint32_t idx, bool can_update = true);
76 typedef std::vector<lldb::ThreadSP> collection;
77 typedef LockingAdaptedIterable<collection, lldb::ThreadSP, vector_adapter> ThreadIterable;
82 return ThreadIterable(m_threads, GetMutex());
86 FindThreadByID (lldb::tid_t tid, bool can_update = true);
89 FindThreadByProtocolID (lldb::tid_t tid, bool can_update = true);
92 RemoveThreadByID (lldb::tid_t tid, bool can_update = true);
95 RemoveThreadByProtocolID (lldb::tid_t tid, bool can_update = true);
98 FindThreadByIndexID (uint32_t index_id, bool can_update = true);
101 GetThreadSPForThreadPtr (Thread *thread_ptr);
104 ShouldStop (Event *event_ptr);
107 ShouldReportStop (Event *event_ptr);
110 ShouldReportRun (Event *event_ptr);
113 RefreshStateAfterStop ();
115 //------------------------------------------------------------------
116 /// The thread list asks tells all the threads it is about to resume.
117 /// If a thread can "resume" without having to resume the target, it
118 /// will return false for WillResume, and then the process will not be
122 /// \b true instructs the process to resume normally,
123 /// \b false means start & stopped events will be generated, but
124 /// the process will not actually run. The thread must then return
125 /// the correct StopInfo when asked.
127 //------------------------------------------------------------------
138 DiscardThreadPlans();
144 SetStopID (uint32_t stop_id);
150 Update (ThreadList &rhs);
155 SetShouldReportStop (Vote vote);
158 NotifySelectedThreadChanged (lldb::tid_t tid);
160 //------------------------------------------------------------------
161 // Classes that inherit from Process can see and modify these
162 //------------------------------------------------------------------
163 Process *m_process; ///< The process that manages this thread list.
164 uint32_t m_stop_id; ///< The process stop ID that this thread list is valid for.
165 collection m_threads; ///< The threads for this process.
166 lldb::tid_t m_selected_tid; ///< For targets that need the notion of a current thread.
172 } // namespace lldb_private
174 #endif // liblldb_ThreadList_h_