]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/Darwin/NativeThreadListDarwin.h
Merge llvm trunk r351319, resolve conflicts, and update FREEBSD-Xlist.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / Process / Darwin / NativeThreadListDarwin.h
1 //===-- NativeThreadListDarwin.h --------------------------------------*- C++
2 //-*-===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10 //
11 //  Created by Greg Clayton on 6/19/07.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef __NativeThreadListDarwin_h__
16 #define __NativeThreadListDarwin_h__
17
18 #include <memory>
19 #include <mutex>
20 #include <vector>
21
22 #include "lldb/lldb-private-forward.h"
23 #include "lldb/lldb-types.h"
24
25 #include "MachException.h"
26
27 // #include "ThreadInfo.h"
28
29 namespace lldb_private {
30 namespace process_darwin {
31
32 class NativeBreakpointDarwin;
33 class NativeProcessDarwin;
34
35 class NativeThreadDarwin;
36 using NativeThreadDarwinSP = std::shared_ptr<NativeThreadDarwin>;
37
38 class NativeThreadListDarwin {
39 public:
40   NativeThreadListDarwin();
41   ~NativeThreadListDarwin();
42
43   void Clear();
44
45   void Dump(Stream &stream) const;
46
47 // These methods will be accessed directly from NativeThreadDarwin
48 #if 0
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);
55 #endif
56
57   const char *GetThreadInfo(lldb::tid_t tid) const;
58
59   void ProcessWillResume(NativeProcessDarwin &process,
60                          const ResumeActionList &thread_actions);
61
62   uint32_t ProcessDidStop(NativeProcessDarwin &process);
63
64   bool NotifyException(MachException::Data &exc);
65
66   bool ShouldStop(bool &step_more);
67
68 // These methods will be accessed directly from NativeThreadDarwin
69 #if 0
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);
73 #endif
74
75 // TODO: figure out if we need to add this to NativeThreadDarwin yet.
76 #if 0
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);
81 #endif
82
83 // These methods will be accessed directly from NativeThreadDarwin
84 #if 0
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);
88 #endif
89
90   size_t GetNumberOfThreads() const;
91
92   lldb::tid_t ThreadIDAtIndex(size_t idx) const;
93
94   lldb::tid_t GetCurrentThreadID();
95
96   NativeThreadDarwinSP GetCurrentThread();
97
98   void NotifyBreakpointChanged(const NativeBreakpointDarwin *bp);
99
100   uint32_t EnableHardwareBreakpoint(const NativeBreakpointDarwin *bp) const;
101
102   bool DisableHardwareBreakpoint(const NativeBreakpointDarwin *bp) const;
103
104   uint32_t EnableHardwareWatchpoint(const NativeBreakpointDarwin *wp) const;
105
106   bool DisableHardwareWatchpoint(const NativeBreakpointDarwin *wp) const;
107
108   uint32_t GetNumberOfSupportedHardwareWatchpoints() const;
109
110   size_t GetThreadIndexForThreadStoppedWithSignal(const int signo) const;
111
112   NativeThreadDarwinSP GetThreadByID(lldb::tid_t tid) const;
113
114   NativeThreadDarwinSP
115   GetThreadByMachPortNumber(::thread_t mach_port_number) const;
116
117   lldb::tid_t GetThreadIDByMachPortNumber(::thread_t mach_port_number) const;
118
119   thread_t GetMachPortNumberByThreadID(lldb::tid_t globally_unique_id) const;
120
121 protected:
122   typedef std::vector<NativeThreadDarwinSP> collection;
123   typedef collection::iterator iterator;
124   typedef collection::const_iterator const_iterator;
125
126   // Consider having this return an lldb_private::Status.
127   uint32_t UpdateThreadList(NativeProcessDarwin &process, bool update,
128                             collection *num_threads = nullptr);
129
130   collection m_threads;
131   mutable std::recursive_mutex m_threads_mutex;
132   NativeThreadDarwinSP m_current_thread;
133   bool m_is_64_bit;
134 };
135
136 } // namespace process_darwin
137 } // namespace lldb_private
138
139 #endif // #ifndef __NativeThreadListDarwin_h__