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_
16 #include "RegisterContextPOSIX.h"
17 #include "lldb/Target/Thread.h"
21 class POSIXBreakpointProtocol;
23 //------------------------------------------------------------------------------
24 // @class FreeBSDThread
25 // Abstraction of a FreeBSD thread.
26 class FreeBSDThread : public lldb_private::Thread {
28 //------------------------------------------------------------------
29 // Constructors and destructors
30 //------------------------------------------------------------------
31 FreeBSDThread(lldb_private::Process &process, lldb::tid_t tid);
33 virtual ~FreeBSDThread();
36 void RefreshStateAfterStop() override;
38 // This notifies the thread when a private stop occurs.
39 void DidStop() override;
41 const char *GetInfo() override;
43 void SetName(const char *name) override;
45 const char *GetName() override;
47 lldb::RegisterContextSP GetRegisterContext() override;
49 lldb::RegisterContextSP
50 CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
52 lldb::addr_t GetThreadPointer() override;
54 //--------------------------------------------------------------------------
55 // These functions provide a mapping from the register offset
56 // back to the register index or name for use in debugging or log
59 unsigned GetRegisterIndexFromOffset(unsigned offset);
61 const char *GetRegisterName(unsigned reg);
63 const char *GetRegisterNameFromOffset(unsigned offset);
65 //--------------------------------------------------------------------------
66 // These methods form a specialized interface to POSIX threads.
70 void Notify(const ProcessMessage &message);
72 //--------------------------------------------------------------------------
73 // These methods provide an interface to watchpoints
75 bool EnableHardwareWatchpoint(lldb_private::Watchpoint *wp);
77 bool DisableHardwareWatchpoint(lldb_private::Watchpoint *wp);
79 uint32_t NumSupportedHardwareWatchpoints();
81 uint32_t FindVacantWatchpointIndex();
84 POSIXBreakpointProtocol *GetPOSIXBreakpointProtocol() {
85 if (!m_reg_context_sp)
86 m_reg_context_sp = GetRegisterContext();
87 return m_posix_thread;
90 std::unique_ptr<lldb_private::StackFrame> m_frame_ap;
92 lldb::BreakpointSiteSP m_breakpoint;
94 bool m_thread_name_valid;
95 std::string m_thread_name;
96 POSIXBreakpointProtocol *m_posix_thread;
98 ProcessMonitor &GetMonitor();
100 bool CalculateStopInfo() override;
102 void BreakNotify(const ProcessMessage &message);
103 void WatchNotify(const ProcessMessage &message);
104 virtual void TraceNotify(const ProcessMessage &message);
105 void LimboNotify(const ProcessMessage &message);
106 void SignalNotify(const ProcessMessage &message);
107 void SignalDeliveredNotify(const ProcessMessage &message);
108 void CrashNotify(const ProcessMessage &message);
109 void ExitNotify(const ProcessMessage &message);
110 void ExecNotify(const ProcessMessage &message);
112 lldb_private::Unwind *GetUnwinder() override;
114 //--------------------------------------------------------------------------
115 // FreeBSDThread internal API.
117 // POSIXThread override
118 virtual void WillResume(lldb::StateType resume_state) override;
121 #endif // #ifndef liblldb_FreeBSDThread_H_