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"
19 // FIXME: Currently this is a thread list with lots of functionality for use only by
20 // the process for which this is the thread list. If we ever want a container class
21 // to hand out that is just a random subset of threads, with iterator functionality,
22 // then we should make that part a base class, and make a ProcessThreadList for the
24 namespace lldb_private {
32 ThreadList (Process *process);
34 ThreadList (const ThreadList &rhs);
39 operator = (const ThreadList& rhs);
42 GetSize(bool can_update = true);
45 AddThread (const lldb::ThreadSP &thread_sp);
47 // Return the selected thread if there is one. Otherwise, return the thread
48 // selected at index 0.
53 SetSelectedThreadByID (lldb::tid_t tid, bool notify = false);
56 SetSelectedThreadByIndexID (uint32_t index_id, bool notify = false);
67 // Note that "idx" is not the same as the "thread_index". It is a zero
68 // based index to accessing the current threads, whereas "thread_index"
69 // is a unique index assigned
71 GetThreadAtIndex (uint32_t idx, bool can_update = true);
74 FindThreadByID (lldb::tid_t tid, bool can_update = true);
77 FindThreadByProtocolID (lldb::tid_t tid, bool can_update = true);
80 RemoveThreadByID (lldb::tid_t tid, bool can_update = true);
83 RemoveThreadByProtocolID (lldb::tid_t tid, bool can_update = true);
86 FindThreadByIndexID (uint32_t index_id, bool can_update = true);
89 GetThreadSPForThreadPtr (Thread *thread_ptr);
92 ShouldStop (Event *event_ptr);
95 ShouldReportStop (Event *event_ptr);
98 ShouldReportRun (Event *event_ptr);
101 RefreshStateAfterStop ();
103 //------------------------------------------------------------------
104 /// The thread list asks tells all the threads it is about to resume.
105 /// If a thread can "resume" without having to resume the target, it
106 /// will return false for WillResume, and then the process will not be
110 /// \b true instructs the process to resume normally,
111 /// \b false means start & stopped events will be generated, but
112 /// the process will not actually run. The thread must then return
113 /// the correct StopInfo when asked.
115 //------------------------------------------------------------------
126 DiscardThreadPlans();
132 SetStopID (uint32_t stop_id);
138 Update (ThreadList &rhs);
143 SetShouldReportStop (Vote vote);
146 NotifySelectedThreadChanged (lldb::tid_t tid);
148 typedef std::vector<lldb::ThreadSP> collection;
149 //------------------------------------------------------------------
150 // Classes that inherit from Process can see and modify these
151 //------------------------------------------------------------------
152 Process *m_process; ///< The process that manages this thread list.
153 uint32_t m_stop_id; ///< The process stop ID that this thread list is valid for.
154 collection m_threads; ///< The threads for this process.
155 lldb::tid_t m_selected_tid; ///< For targets that need the notion of a current thread.
161 } // namespace lldb_private
163 #endif // liblldb_ThreadList_h_