1 //===-- FreeBSDThread.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 #ifndef liblldb_FreeBSDThread_H_
10 #define liblldb_FreeBSDThread_H_
15 #include "RegisterContextPOSIX.h"
16 #include "lldb/Target/Thread.h"
20 class POSIXBreakpointProtocol;
22 // @class FreeBSDThread
23 // Abstraction of a FreeBSD thread.
24 class FreeBSDThread : public lldb_private::Thread {
26 // Constructors and destructors
27 FreeBSDThread(lldb_private::Process &process, lldb::tid_t tid);
29 virtual ~FreeBSDThread();
32 void RefreshStateAfterStop() override;
34 // This notifies the thread when a private stop occurs.
35 void DidStop() override;
37 const char *GetInfo() override;
39 void SetName(const char *name) override;
41 const char *GetName() override;
43 lldb::RegisterContextSP GetRegisterContext() override;
45 lldb::RegisterContextSP
46 CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
48 lldb::addr_t GetThreadPointer() override;
50 // These functions provide a mapping from the register offset
51 // back to the register index or name for use in debugging or log
54 unsigned GetRegisterIndexFromOffset(unsigned offset);
56 const char *GetRegisterName(unsigned reg);
58 const char *GetRegisterNameFromOffset(unsigned offset);
60 // These methods form a specialized interface to POSIX threads.
64 void Notify(const ProcessMessage &message);
66 // These methods provide an interface to watchpoints
68 bool EnableHardwareWatchpoint(lldb_private::Watchpoint *wp);
70 bool DisableHardwareWatchpoint(lldb_private::Watchpoint *wp);
72 uint32_t NumSupportedHardwareWatchpoints();
74 uint32_t FindVacantWatchpointIndex();
77 POSIXBreakpointProtocol *GetPOSIXBreakpointProtocol() {
78 if (!m_reg_context_sp)
79 m_reg_context_sp = GetRegisterContext();
80 return m_posix_thread;
83 std::unique_ptr<lldb_private::StackFrame> m_frame_up;
85 lldb::BreakpointSiteSP m_breakpoint;
87 bool m_thread_name_valid;
88 std::string m_thread_name;
89 POSIXBreakpointProtocol *m_posix_thread;
91 ProcessMonitor &GetMonitor();
93 bool CalculateStopInfo() override;
95 void BreakNotify(const ProcessMessage &message);
96 void WatchNotify(const ProcessMessage &message);
97 virtual void TraceNotify(const ProcessMessage &message);
98 void LimboNotify(const ProcessMessage &message);
99 void SignalNotify(const ProcessMessage &message);
100 void SignalDeliveredNotify(const ProcessMessage &message);
101 void CrashNotify(const ProcessMessage &message);
102 void ExitNotify(const ProcessMessage &message);
103 void ExecNotify(const ProcessMessage &message);
105 lldb_private::Unwind *GetUnwinder() override;
107 // FreeBSDThread internal API.
109 // POSIXThread override
110 virtual void WillResume(lldb::StateType resume_state) override;
113 #endif // #ifndef liblldb_FreeBSDThread_H_