]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/ThreadList.h
Update LLDB snapshot to upstream r241361
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Target / ThreadList.h
1 //===-- ThreadList.h --------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_ThreadList_h_
11 #define liblldb_ThreadList_h_
12
13 #include <vector>
14
15 #include "lldb/lldb-private.h"
16 #include "lldb/Core/UserID.h"
17 #include "lldb/Utility/Iterable.h"
18 #include "lldb/Target/ThreadCollection.h"
19
20 namespace lldb_private {
21
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
26 {
27 friend class Process;
28
29 public:
30
31     ThreadList (Process *process);
32
33     ThreadList (const ThreadList &rhs);
34
35     virtual
36     ~ThreadList ();
37
38     const ThreadList&
39     operator = (const ThreadList& rhs);
40
41     uint32_t
42     GetSize(bool can_update = true);
43
44     // Return the selected thread if there is one.  Otherwise, return the thread
45     // selected at index 0.
46     lldb::ThreadSP
47     GetSelectedThread ();
48
49     bool
50     SetSelectedThreadByID (lldb::tid_t tid, bool notify = false);
51
52     bool
53     SetSelectedThreadByIndexID (uint32_t index_id, bool notify = false);
54
55     void
56     Clear();
57
58     void
59     Flush();
60
61     void
62     Destroy();
63
64     // Note that "idx" is not the same as the "thread_index". It is a zero
65     // based index to accessing the current threads, whereas "thread_index"
66     // is a unique index assigned
67     lldb::ThreadSP
68     GetThreadAtIndex (uint32_t idx, bool can_update = true);
69
70     lldb::ThreadSP
71     FindThreadByID (lldb::tid_t tid, bool can_update = true);
72     
73     lldb::ThreadSP
74     FindThreadByProtocolID (lldb::tid_t tid, bool can_update = true);
75
76     lldb::ThreadSP
77     RemoveThreadByID (lldb::tid_t tid, bool can_update = true);
78     
79     lldb::ThreadSP
80     RemoveThreadByProtocolID (lldb::tid_t tid, bool can_update = true);
81
82     lldb::ThreadSP
83     FindThreadByIndexID (uint32_t index_id, bool can_update = true);
84
85     lldb::ThreadSP
86     GetThreadSPForThreadPtr (Thread *thread_ptr);
87
88     bool
89     ShouldStop (Event *event_ptr);
90
91     Vote
92     ShouldReportStop (Event *event_ptr);
93
94     Vote
95     ShouldReportRun (Event *event_ptr);
96
97     void
98     RefreshStateAfterStop ();
99
100     //------------------------------------------------------------------
101     /// The thread list asks tells all the threads it is about to resume.
102     /// If a thread can "resume" without having to resume the target, it
103     /// will return false for WillResume, and then the process will not be
104     /// restarted.
105     ///
106     /// @return
107     ///    \b true instructs the process to resume normally,
108     ///    \b false means start & stopped events will be generated, but
109     ///    the process will not actually run.  The thread must then return
110     ///    the correct StopInfo when asked.
111     ///
112     //------------------------------------------------------------------
113     bool
114     WillResume ();
115
116     void
117     DidResume ();
118
119     void
120     DidStop ();
121
122     void
123     DiscardThreadPlans();
124
125     uint32_t
126     GetStopID () const;
127
128     void
129     SetStopID (uint32_t stop_id);
130
131     virtual Mutex &
132     GetMutex ();
133     
134     void
135     Update (ThreadList &rhs);
136     
137 protected:
138
139     void
140     SetShouldReportStop (Vote vote);
141
142     void
143     NotifySelectedThreadChanged (lldb::tid_t tid);
144
145     //------------------------------------------------------------------
146     // Classes that inherit from Process can see and modify these
147     //------------------------------------------------------------------
148     Process *m_process; ///< The process that manages this thread list.
149     uint32_t m_stop_id; ///< The process stop ID that this thread list is valid for.
150     lldb::tid_t m_selected_tid;  ///< For targets that need the notion of a current thread.
151
152 private:
153     ThreadList ();
154 };
155
156 } // namespace lldb_private
157
158 #endif  // liblldb_ThreadList_h_