LLDB  mainline
NativeThreadListDarwin.h
Go to the documentation of this file.
1 //===-- NativeThreadListDarwin.h --------------------------------------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Created by Greg Clayton on 6/19/07.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef __NativeThreadListDarwin_h__
15 #define __NativeThreadListDarwin_h__
16 
17 #include <memory>
18 #include <mutex>
19 #include <vector>
20 
22 #include "lldb/lldb-types.h"
23 
24 #include "MachException.h"
25 
26 // #include "ThreadInfo.h"
27 
28 namespace lldb_private {
29 namespace process_darwin {
30 
31 class NativeBreakpointDarwin;
32 class NativeProcessDarwin;
33 
34 class NativeThreadDarwin;
35 using NativeThreadDarwinSP = std::shared_ptr<NativeThreadDarwin>;
36 
38 public:
41 
42  void Clear();
43 
44  void Dump(Stream &stream) const;
45 
46 // These methods will be accessed directly from NativeThreadDarwin
47 #if 0
48  bool GetRegisterValue (nub_thread_t tid, uint32_t set, uint32_t reg, DNBRegisterValue *reg_value) const;
49  bool SetRegisterValue (nub_thread_t tid, uint32_t set, uint32_t reg, const DNBRegisterValue *reg_value) const;
50  nub_size_t GetRegisterContext (nub_thread_t tid, void *buf, size_t buf_len);
51  nub_size_t SetRegisterContext (nub_thread_t tid, const void *buf, size_t buf_len);
52  uint32_t SaveRegisterState (nub_thread_t tid);
53  bool RestoreRegisterState (nub_thread_t tid, uint32_t save_id);
54 #endif
55 
56  const char *GetThreadInfo(lldb::tid_t tid) const;
57 
59  const ResumeActionList &thread_actions);
60 
62 
64 
65  bool ShouldStop(bool &step_more);
66 
67 // These methods will be accessed directly from NativeThreadDarwin
68 #if 0
69  const char * GetName (nub_thread_t tid);
70  nub_state_t GetState (nub_thread_t tid);
71  nub_thread_t SetCurrentThread (nub_thread_t tid);
72 #endif
73 
74 // TODO: figure out if we need to add this to NativeThreadDarwin yet.
75 #if 0
76  ThreadInfo::QoS GetRequestedQoS (nub_thread_t tid, nub_addr_t tsd, uint64_t dti_qos_class_index);
77  nub_addr_t GetPThreadT (nub_thread_t tid);
78  nub_addr_t GetDispatchQueueT (nub_thread_t tid);
79  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);
80 #endif
81 
82 // These methods will be accessed directly from NativeThreadDarwin
83 #if 0
84  bool GetThreadStoppedReason (nub_thread_t tid, struct DNBThreadStopInfo *stop_info) const;
85  void DumpThreadStoppedReason (nub_thread_t tid) const;
86  bool GetIdentifierInfo (nub_thread_t tid, thread_identifier_info_data_t *ident_info);
87 #endif
88 
89  size_t GetNumberOfThreads() const;
90 
91  lldb::tid_t ThreadIDAtIndex(size_t idx) const;
92 
94 
96 
97  void NotifyBreakpointChanged(const NativeBreakpointDarwin *bp);
98 
99  uint32_t EnableHardwareBreakpoint(const NativeBreakpointDarwin *bp) const;
100 
101  bool DisableHardwareBreakpoint(const NativeBreakpointDarwin *bp) const;
102 
103  uint32_t EnableHardwareWatchpoint(const NativeBreakpointDarwin *wp) const;
104 
105  bool DisableHardwareWatchpoint(const NativeBreakpointDarwin *wp) const;
106 
108 
109  size_t GetThreadIndexForThreadStoppedWithSignal(const int signo) const;
110 
112 
114  GetThreadByMachPortNumber(::thread_t mach_port_number) const;
115 
116  lldb::tid_t GetThreadIDByMachPortNumber(::thread_t mach_port_number) const;
117 
118  thread_t GetMachPortNumberByThreadID(lldb::tid_t globally_unique_id) const;
119 
120 protected:
121  typedef std::vector<NativeThreadDarwinSP> collection;
122  typedef collection::iterator iterator;
123  typedef collection::const_iterator const_iterator;
124 
125  // Consider having this return an lldb_private::Status.
126  uint32_t UpdateThreadList(NativeProcessDarwin &process, bool update,
127  collection *num_threads = nullptr);
128 
129  collection m_threads;
130  mutable std::recursive_mutex m_threads_mutex;
133 };
134 
135 } // namespace process_darwin
136 } // namespace lldb_private
137 
138 #endif // #ifndef __NativeThreadListDarwin_h__
uint32_t EnableHardwareWatchpoint(const NativeBreakpointDarwin *wp) const
const char * GetThreadInfo(lldb::tid_t tid) const
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
NativeThreadDarwinSP GetThreadByID(lldb::tid_t tid) const
Manages communication with the inferior (debugee) process.
uint32_t EnableHardwareBreakpoint(const NativeBreakpointDarwin *bp) const
void NotifyBreakpointChanged(const NativeBreakpointDarwin *bp)
uint32_t UpdateThreadList(NativeProcessDarwin &process, bool update, collection *num_threads=nullptr)
bool DisableHardwareWatchpoint(const NativeBreakpointDarwin *wp) const
void ProcessWillResume(NativeProcessDarwin &process, const ResumeActionList &thread_actions)
uint64_t tid_t
Definition: lldb-types.h:86
NativeThreadDarwinSP GetThreadByMachPortNumber(::thread_t mach_port_number) const
pthread_t thread_t
Definition: lldb-types.h:58
std::shared_ptr< NativeThreadDarwin > NativeThreadDarwinSP
bool DisableHardwareBreakpoint(const NativeBreakpointDarwin *bp) const
thread_t GetMachPortNumberByThreadID(lldb::tid_t globally_unique_id) const
size_t GetThreadIndexForThreadStoppedWithSignal(const int signo) const
lldb::tid_t GetThreadIDByMachPortNumber(::thread_t mach_port_number) const