File indexing completed on 2026-05-10 08:42:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_TARGET_THREADLIST_H
0010 #define LLDB_TARGET_THREADLIST_H
0011
0012 #include <mutex>
0013 #include <vector>
0014
0015 #include "lldb/Target/Thread.h"
0016 #include "lldb/Target/ThreadCollection.h"
0017 #include "lldb/Utility/Iterable.h"
0018 #include "lldb/Utility/UserID.h"
0019 #include "lldb/lldb-private.h"
0020
0021 namespace lldb_private {
0022
0023
0024
0025
0026 class ThreadList : public ThreadCollection {
0027 friend class Process;
0028
0029 public:
0030 ThreadList(Process &process);
0031
0032 ThreadList(const ThreadList &rhs);
0033
0034 ~ThreadList() override;
0035
0036
0037 const ThreadList &operator=(const ThreadList &rhs);
0038
0039 uint32_t GetSize(bool can_update = true);
0040
0041
0042
0043 lldb::ThreadSP GetSelectedThread();
0044
0045
0046
0047
0048 class ExpressionExecutionThreadPusher {
0049 public:
0050 ExpressionExecutionThreadPusher(ThreadList &thread_list, lldb::tid_t tid)
0051 : m_thread_list(&thread_list), m_tid(tid) {
0052 m_thread_list->PushExpressionExecutionThread(m_tid);
0053 }
0054
0055 ExpressionExecutionThreadPusher(lldb::ThreadSP thread_sp);
0056
0057 ~ExpressionExecutionThreadPusher() {
0058 if (m_thread_list && m_tid != LLDB_INVALID_THREAD_ID)
0059 m_thread_list->PopExpressionExecutionThread(m_tid);
0060 }
0061
0062 private:
0063 ThreadList *m_thread_list;
0064 lldb::tid_t m_tid;
0065 };
0066
0067 lldb::ThreadSP GetExpressionExecutionThread();
0068
0069 protected:
0070 void PushExpressionExecutionThread(lldb::tid_t tid);
0071
0072 void PopExpressionExecutionThread(lldb::tid_t tid);
0073
0074 public:
0075 bool SetSelectedThreadByID(lldb::tid_t tid, bool notify = false);
0076
0077 bool SetSelectedThreadByIndexID(uint32_t index_id, bool notify = false);
0078
0079 void Clear();
0080
0081 void Flush();
0082
0083 void Destroy();
0084
0085
0086
0087
0088 lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update = true);
0089
0090 lldb::ThreadSP FindThreadByID(lldb::tid_t tid, bool can_update = true);
0091
0092 lldb::ThreadSP FindThreadByProtocolID(lldb::tid_t tid,
0093 bool can_update = true);
0094
0095 lldb::ThreadSP RemoveThreadByID(lldb::tid_t tid, bool can_update = true);
0096
0097 lldb::ThreadSP RemoveThreadByProtocolID(lldb::tid_t tid,
0098 bool can_update = true);
0099
0100 lldb::ThreadSP FindThreadByIndexID(uint32_t index_id, bool can_update = true);
0101
0102 lldb::ThreadSP GetThreadSPForThreadPtr(Thread *thread_ptr);
0103
0104 lldb::ThreadSP GetBackingThread(const lldb::ThreadSP &real_thread);
0105
0106 bool ShouldStop(Event *event_ptr);
0107
0108 Vote ShouldReportStop(Event *event_ptr);
0109
0110 Vote ShouldReportRun(Event *event_ptr);
0111
0112 void RefreshStateAfterStop();
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125 bool WillResume();
0126
0127 void DidResume();
0128
0129 void DidStop();
0130
0131 void DiscardThreadPlans();
0132
0133 uint32_t GetStopID() const;
0134
0135 void SetStopID(uint32_t stop_id);
0136
0137 std::recursive_mutex &GetMutex() const override;
0138
0139
0140 void Update(ThreadList &rhs);
0141
0142 protected:
0143 void SetShouldReportStop(Vote vote);
0144
0145 void NotifySelectedThreadChanged(lldb::tid_t tid);
0146
0147
0148 Process &m_process;
0149 uint32_t
0150 m_stop_id;
0151 lldb::tid_t
0152 m_selected_tid;
0153 std::vector<lldb::tid_t> m_expression_tid_stack;
0154
0155 private:
0156 ThreadList() = delete;
0157 };
0158
0159 }
0160
0161 #endif