]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/ThreadList.h
Import to 0.6.1
[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     ~ThreadList() override;
36
37     const ThreadList&
38     operator = (const ThreadList& rhs);
39
40     uint32_t
41     GetSize(bool can_update = true);
42
43     // Return the selected thread if there is one.  Otherwise, return the thread
44     // selected at index 0.
45     lldb::ThreadSP
46     GetSelectedThread ();
47
48     bool
49     SetSelectedThreadByID (lldb::tid_t tid, bool notify = false);
50
51     bool
52     SetSelectedThreadByIndexID (uint32_t index_id, bool notify = false);
53
54     void
55     Clear();
56
57     void
58     Flush();
59
60     void
61     Destroy();
62
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
66     lldb::ThreadSP
67     GetThreadAtIndex (uint32_t idx, bool can_update = true);
68
69     lldb::ThreadSP
70     FindThreadByID (lldb::tid_t tid, bool can_update = true);
71     
72     lldb::ThreadSP
73     FindThreadByProtocolID (lldb::tid_t tid, bool can_update = true);
74
75     lldb::ThreadSP
76     RemoveThreadByID (lldb::tid_t tid, bool can_update = true);
77     
78     lldb::ThreadSP
79     RemoveThreadByProtocolID (lldb::tid_t tid, bool can_update = true);
80
81     lldb::ThreadSP
82     FindThreadByIndexID (uint32_t index_id, bool can_update = true);
83
84     lldb::ThreadSP
85     GetThreadSPForThreadPtr (Thread *thread_ptr);
86
87     bool
88     ShouldStop (Event *event_ptr);
89
90     Vote
91     ShouldReportStop (Event *event_ptr);
92
93     Vote
94     ShouldReportRun (Event *event_ptr);
95
96     void
97     RefreshStateAfterStop ();
98
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
103     /// restarted.
104     ///
105     /// @return
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.
110     ///
111     //------------------------------------------------------------------
112     bool
113     WillResume ();
114
115     void
116     DidResume ();
117
118     void
119     DidStop ();
120
121     void
122     DiscardThreadPlans();
123
124     uint32_t
125     GetStopID () const;
126
127     void
128     SetStopID (uint32_t stop_id);
129
130     Mutex &
131     GetMutex() override;
132     
133     void
134     Update (ThreadList &rhs);
135     
136 protected:
137
138     void
139     SetShouldReportStop (Vote vote);
140
141     void
142     NotifySelectedThreadChanged (lldb::tid_t tid);
143
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.
150
151 private:
152
153     ThreadList ();
154 };
155
156 } // namespace lldb_private
157
158 #endif // liblldb_ThreadList_h_