1 //===-- NativeThreadListDarwin.h --------------------------------------*- C++
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 // Created by Greg Clayton on 6/19/07.
13 //===----------------------------------------------------------------------===//
15 #ifndef __NativeThreadListDarwin_h__
16 #define __NativeThreadListDarwin_h__
22 #include "lldb/lldb-private-forward.h"
23 #include "lldb/lldb-types.h"
25 #include "MachException.h"
27 // #include "ThreadInfo.h"
29 namespace lldb_private {
30 namespace process_darwin {
32 class NativeBreakpointDarwin;
33 class NativeProcessDarwin;
35 class NativeThreadDarwin;
36 using NativeThreadDarwinSP = std::shared_ptr<NativeThreadDarwin>;
38 class NativeThreadListDarwin {
40 NativeThreadListDarwin();
41 ~NativeThreadListDarwin();
45 void Dump(Stream &stream) const;
47 // These methods will be accessed directly from NativeThreadDarwin
49 bool GetRegisterValue (nub_thread_t tid, uint32_t set, uint32_t reg, DNBRegisterValue *reg_value) const;
50 bool SetRegisterValue (nub_thread_t tid, uint32_t set, uint32_t reg, const DNBRegisterValue *reg_value) const;
51 nub_size_t GetRegisterContext (nub_thread_t tid, void *buf, size_t buf_len);
52 nub_size_t SetRegisterContext (nub_thread_t tid, const void *buf, size_t buf_len);
53 uint32_t SaveRegisterState (nub_thread_t tid);
54 bool RestoreRegisterState (nub_thread_t tid, uint32_t save_id);
57 const char *GetThreadInfo(lldb::tid_t tid) const;
59 void ProcessWillResume(NativeProcessDarwin &process,
60 const ResumeActionList &thread_actions);
62 uint32_t ProcessDidStop(NativeProcessDarwin &process);
64 bool NotifyException(MachException::Data &exc);
66 bool ShouldStop(bool &step_more);
68 // These methods will be accessed directly from NativeThreadDarwin
70 const char * GetName (nub_thread_t tid);
71 nub_state_t GetState (nub_thread_t tid);
72 nub_thread_t SetCurrentThread (nub_thread_t tid);
75 // TODO: figure out if we need to add this to NativeThreadDarwin yet.
77 ThreadInfo::QoS GetRequestedQoS (nub_thread_t tid, nub_addr_t tsd, uint64_t dti_qos_class_index);
78 nub_addr_t GetPThreadT (nub_thread_t tid);
79 nub_addr_t GetDispatchQueueT (nub_thread_t tid);
80 nub_addr_t GetTSDAddressForThread (nub_thread_t tid, uint64_t plo_pthread_tsd_base_address_offset, uint64_t plo_pthread_tsd_base_offset, uint64_t plo_pthread_tsd_entry_size);
83 // These methods will be accessed directly from NativeThreadDarwin
85 bool GetThreadStoppedReason (nub_thread_t tid, struct DNBThreadStopInfo *stop_info) const;
86 void DumpThreadStoppedReason (nub_thread_t tid) const;
87 bool GetIdentifierInfo (nub_thread_t tid, thread_identifier_info_data_t *ident_info);
90 size_t GetNumberOfThreads() const;
92 lldb::tid_t ThreadIDAtIndex(size_t idx) const;
94 lldb::tid_t GetCurrentThreadID();
96 NativeThreadDarwinSP GetCurrentThread();
98 void NotifyBreakpointChanged(const NativeBreakpointDarwin *bp);
100 uint32_t EnableHardwareBreakpoint(const NativeBreakpointDarwin *bp) const;
102 bool DisableHardwareBreakpoint(const NativeBreakpointDarwin *bp) const;
104 uint32_t EnableHardwareWatchpoint(const NativeBreakpointDarwin *wp) const;
106 bool DisableHardwareWatchpoint(const NativeBreakpointDarwin *wp) const;
108 uint32_t GetNumberOfSupportedHardwareWatchpoints() const;
110 size_t GetThreadIndexForThreadStoppedWithSignal(const int signo) const;
112 NativeThreadDarwinSP GetThreadByID(lldb::tid_t tid) const;
115 GetThreadByMachPortNumber(::thread_t mach_port_number) const;
117 lldb::tid_t GetThreadIDByMachPortNumber(::thread_t mach_port_number) const;
119 thread_t GetMachPortNumberByThreadID(lldb::tid_t globally_unique_id) const;
122 typedef std::vector<NativeThreadDarwinSP> collection;
123 typedef collection::iterator iterator;
124 typedef collection::const_iterator const_iterator;
126 // Consider having this return an lldb_private::Status.
127 uint32_t UpdateThreadList(NativeProcessDarwin &process, bool update,
128 collection *num_threads = nullptr);
130 collection m_threads;
131 mutable std::recursive_mutex m_threads_mutex;
132 NativeThreadDarwinSP m_current_thread;
136 } // namespace process_darwin
137 } // namespace lldb_private
139 #endif // #ifndef __NativeThreadListDarwin_h__