blob: 4f82cc7ca650addf18d901b161e1adb851760b5b [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- 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/Host/Mutex.h"
17#include "lldb/Core/UserID.h"
18
19
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
24// process.
25namespace lldb_private {
26
27class ThreadList
28{
29friend class Process;
30
31public:
32
33 ThreadList (Process *process);
34
35 ThreadList (const ThreadList &rhs);
36
37 ~ThreadList ();
38
39 const ThreadList&
40 operator = (const ThreadList& rhs);
41
42 uint32_t
43 GetSize(bool can_update = true);
44
45 void
46 AddThread (lldb::ThreadSP &thread_sp);
47
48 lldb::ThreadSP
49 GetCurrentThread ();
50
51 bool
52 SetCurrentThreadByID (lldb::tid_t tid);
53
54 bool
55 SetCurrentThreadByIndexID (uint32_t index_id);
56
57 void
58 Clear();
59
60 // Note that "idx" is not the same as the "thread_index". It is a zero
61 // based index to accessing the current threads, whereas "thread_index"
62 // is a unique index assigned
63 lldb::ThreadSP
64 GetThreadAtIndex (uint32_t idx, bool can_update = true);
65
66 lldb::ThreadSP
67 FindThreadByID (lldb::tid_t tid, bool can_update = true);
68
69 lldb::ThreadSP
70 FindThreadByIndexID (lldb::tid_t index_id, bool can_update = true);
71
72 lldb::ThreadSP
73 GetThreadSPForThreadPtr (Thread *thread_ptr);
74
75 bool
76 ShouldStop (Event *event_ptr);
77
78 lldb::Vote
79 ShouldReportStop (Event *event_ptr);
80
81 lldb::Vote
82 ShouldReportRun (Event *event_ptr);
83
84 void
85 RefreshStateAfterStop ();
86
87 bool
88 WillResume ();
89
90 void
91 DidResume ();
92
93 void
94 DiscardThreadPlans();
95
96 uint32_t
97 GetStopID () const;
98
99 void
100 SetStopID (uint32_t stop_id);
101
102protected:
103
104 typedef std::vector<lldb::ThreadSP> collection;
105 //------------------------------------------------------------------
106 // Classes that inherit from Process can see and modify these
107 //------------------------------------------------------------------
108 Process *m_process; ///< The process that manages this thread list.
109 uint32_t m_stop_id; ///< The process stop ID that this thread list is valid for.
110 collection m_threads; ///< The threads for this process.
111 mutable Mutex m_threads_mutex;
112 lldb::tid_t m_current_tid; ///< For targets that need the notion of a current thread.
113
114private:
115 ThreadList ();
116};
117
118} // namespace lldb_private
119
120#endif // liblldb_ThreadList_h_