1 //===-- MachThreadList.h ----------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // Created by Greg Clayton on 6/19/07.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_MACHTHREADLIST_H
14 #define LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_MACHTHREADLIST_H
16 #include "MachThread.h"
17 #include "ThreadInfo.h"
19 class DNBThreadResumeActions
;
21 class MachThreadList
{
28 bool GetRegisterValue(nub_thread_t tid
, uint32_t set
, uint32_t reg
,
29 DNBRegisterValue
*reg_value
) const;
30 bool SetRegisterValue(nub_thread_t tid
, uint32_t set
, uint32_t reg
,
31 const DNBRegisterValue
*reg_value
) const;
32 nub_size_t
GetRegisterContext(nub_thread_t tid
, void *buf
, size_t buf_len
);
33 nub_size_t
SetRegisterContext(nub_thread_t tid
, const void *buf
,
35 uint32_t SaveRegisterState(nub_thread_t tid
);
36 bool RestoreRegisterState(nub_thread_t tid
, uint32_t save_id
);
37 const char *GetThreadInfo(nub_thread_t tid
) const;
38 void ProcessWillResume(MachProcess
*process
,
39 const DNBThreadResumeActions
&thread_actions
);
40 uint32_t ProcessDidStop(MachProcess
*process
);
41 bool NotifyException(MachException::Data
&exc
);
42 bool ShouldStop(bool &step_more
);
43 const char *GetName(nub_thread_t tid
);
44 nub_state_t
GetState(nub_thread_t tid
);
45 nub_thread_t
SetCurrentThread(nub_thread_t tid
);
47 ThreadInfo::QoS
GetRequestedQoS(nub_thread_t tid
, nub_addr_t tsd
,
48 uint64_t dti_qos_class_index
);
49 nub_addr_t
GetPThreadT(nub_thread_t tid
);
50 nub_addr_t
GetDispatchQueueT(nub_thread_t tid
);
52 GetTSDAddressForThread(nub_thread_t tid
,
53 uint64_t plo_pthread_tsd_base_address_offset
,
54 uint64_t plo_pthread_tsd_base_offset
,
55 uint64_t plo_pthread_tsd_entry_size
);
57 bool GetThreadStoppedReason(nub_thread_t tid
,
58 struct DNBThreadStopInfo
*stop_info
) const;
59 void DumpThreadStoppedReason(nub_thread_t tid
) const;
60 bool GetIdentifierInfo(nub_thread_t tid
,
61 thread_identifier_info_data_t
*ident_info
);
62 nub_size_t
NumThreads() const;
63 nub_thread_t
ThreadIDAtIndex(nub_size_t idx
) const;
64 nub_thread_t
CurrentThreadID();
65 void CurrentThread(MachThreadSP
&threadSP
);
66 void NotifyBreakpointChanged(const DNBBreakpoint
*bp
);
67 uint32_t EnableHardwareBreakpoint(const DNBBreakpoint
*bp
) const;
68 bool DisableHardwareBreakpoint(const DNBBreakpoint
*bp
) const;
69 uint32_t EnableHardwareWatchpoint(const DNBBreakpoint
*wp
) const;
70 bool DisableHardwareWatchpoint(const DNBBreakpoint
*wp
) const;
71 uint32_t NumSupportedHardwareWatchpoints() const;
73 uint32_t GetThreadIndexForThreadStoppedWithSignal(const int signo
) const;
75 MachThreadSP
GetThreadByID(nub_thread_t tid
) const;
77 MachThreadSP
GetThreadByMachPortNumber(thread_t mach_port_number
) const;
78 nub_thread_t
GetThreadIDByMachPortNumber(thread_t mach_port_number
) const;
79 thread_t
GetMachPortNumberByThreadID(nub_thread_t globally_unique_id
) const;
82 typedef std::vector
<MachThreadSP
> collection
;
83 typedef collection::iterator iterator
;
84 typedef collection::const_iterator const_iterator
;
86 enum class HardwareBreakpointAction
{
93 uint32_t DoHardwareBreakpointAction(const DNBBreakpoint
*bp
,
94 HardwareBreakpointAction action
) const;
96 uint32_t UpdateThreadList(MachProcess
*process
, bool update
,
97 collection
*num_threads
= NULL
);
98 // const_iterator FindThreadByID (thread_t tid) const;
100 collection m_threads
;
101 mutable PThreadMutex m_threads_mutex
;
102 MachThreadSP m_current_thread
;
106 #endif // LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_MACHTHREADLIST_H