1 //===-- FreeBSDThread.h -----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_FreeBSDThread_H_
11 #define liblldb_FreeBSDThread_H_
17 // Other libraries and framework includes
18 #include "RegisterContextPOSIX.h"
19 #include "lldb/Target/Thread.h"
23 class POSIXBreakpointProtocol;
25 //------------------------------------------------------------------------------
26 // @class FreeBSDThread
27 // Abstraction of a FreeBSD thread.
28 class FreeBSDThread : public lldb_private::Thread {
30 //------------------------------------------------------------------
31 // Constructors and destructors
32 //------------------------------------------------------------------
33 FreeBSDThread(lldb_private::Process &process, lldb::tid_t tid);
35 virtual ~FreeBSDThread();
38 void RefreshStateAfterStop() override;
40 // This notifies the thread when a private stop occurs.
41 void DidStop() override;
43 const char *GetInfo() override;
45 void SetName(const char *name) override;
47 const char *GetName() override;
49 lldb::RegisterContextSP GetRegisterContext() override;
51 lldb::RegisterContextSP
52 CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
54 lldb::addr_t GetThreadPointer() override;
56 //--------------------------------------------------------------------------
57 // These functions provide a mapping from the register offset
58 // back to the register index or name for use in debugging or log
61 unsigned GetRegisterIndexFromOffset(unsigned offset);
63 const char *GetRegisterName(unsigned reg);
65 const char *GetRegisterNameFromOffset(unsigned offset);
67 //--------------------------------------------------------------------------
68 // These methods form a specialized interface to POSIX threads.
72 void Notify(const ProcessMessage &message);
74 //--------------------------------------------------------------------------
75 // These methods provide an interface to watchpoints
77 bool EnableHardwareWatchpoint(lldb_private::Watchpoint *wp);
79 bool DisableHardwareWatchpoint(lldb_private::Watchpoint *wp);
81 uint32_t NumSupportedHardwareWatchpoints();
83 uint32_t FindVacantWatchpointIndex();
86 POSIXBreakpointProtocol *GetPOSIXBreakpointProtocol() {
87 if (!m_reg_context_sp)
88 m_reg_context_sp = GetRegisterContext();
89 return m_posix_thread;
92 std::unique_ptr<lldb_private::StackFrame> m_frame_ap;
94 lldb::BreakpointSiteSP m_breakpoint;
96 bool m_thread_name_valid;
97 std::string m_thread_name;
98 POSIXBreakpointProtocol *m_posix_thread;
100 ProcessMonitor &GetMonitor();
102 bool CalculateStopInfo() override;
104 void BreakNotify(const ProcessMessage &message);
105 void WatchNotify(const ProcessMessage &message);
106 virtual void TraceNotify(const ProcessMessage &message);
107 void LimboNotify(const ProcessMessage &message);
108 void SignalNotify(const ProcessMessage &message);
109 void SignalDeliveredNotify(const ProcessMessage &message);
110 void CrashNotify(const ProcessMessage &message);
111 void ExitNotify(const ProcessMessage &message);
112 void ExecNotify(const ProcessMessage &message);
114 lldb_private::Unwind *GetUnwinder() override;
116 //--------------------------------------------------------------------------
117 // FreeBSDThread internal API.
119 // POSIXThread override
120 virtual void WillResume(lldb::StateType resume_state) override;
123 #endif // #ifndef liblldb_FreeBSDThread_H_