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"
18 #include "lldb/Target/ThreadCollection.h"
20 namespace lldb_private {
22 // This is a thread list with lots of functionality for use only by the process
23 // for which this is the thread list. A generic container class with iterator
24 // functionality is ThreadCollection.
25 class ThreadList : public ThreadCollection
31 ThreadList (Process *process);
33 ThreadList (const ThreadList &rhs);
35 ~ThreadList() override;
38 operator = (const ThreadList& rhs);
41 GetSize(bool can_update = true);
43 // Return the selected thread if there is one. Otherwise, return the thread
44 // selected at index 0.
49 SetSelectedThreadByID (lldb::tid_t tid, bool notify = false);
52 SetSelectedThreadByIndexID (uint32_t index_id, bool notify = false);
63 // Note that "idx" is not the same as the "thread_index". It is a zero
64 // based index to accessing the current threads, whereas "thread_index"
65 // is a unique index assigned
67 GetThreadAtIndex (uint32_t idx, bool can_update = true);
70 FindThreadByID (lldb::tid_t tid, bool can_update = true);
73 FindThreadByProtocolID (lldb::tid_t tid, bool can_update = true);
76 RemoveThreadByID (lldb::tid_t tid, bool can_update = true);
79 RemoveThreadByProtocolID (lldb::tid_t tid, bool can_update = true);
82 FindThreadByIndexID (uint32_t index_id, bool can_update = true);
85 GetThreadSPForThreadPtr (Thread *thread_ptr);
88 ShouldStop (Event *event_ptr);
91 ShouldReportStop (Event *event_ptr);
94 ShouldReportRun (Event *event_ptr);
97 RefreshStateAfterStop ();
99 //------------------------------------------------------------------
100 /// The thread list asks tells all the threads it is about to resume.
101 /// If a thread can "resume" without having to resume the target, it
102 /// will return false for WillResume, and then the process will not be
106 /// \b true instructs the process to resume normally,
107 /// \b false means start & stopped events will be generated, but
108 /// the process will not actually run. The thread must then return
109 /// the correct StopInfo when asked.
111 //------------------------------------------------------------------
122 DiscardThreadPlans();
128 SetStopID (uint32_t stop_id);
134 Update (ThreadList &rhs);
139 SetShouldReportStop (Vote vote);
142 NotifySelectedThreadChanged (lldb::tid_t tid);
144 //------------------------------------------------------------------
145 // Classes that inherit from Process can see and modify these
146 //------------------------------------------------------------------
147 Process *m_process; ///< The process that manages this thread list.
148 uint32_t m_stop_id; ///< The process stop ID that this thread list is valid for.
149 lldb::tid_t m_selected_tid; ///< For targets that need the notion of a current thread.
156 } // namespace lldb_private
158 #endif // liblldb_ThreadList_h_