blob: 90c11dbefcb0d9a6439878f90a4bea82740615f1 [file] [log] [blame]
Ed Maste7fd845c2013-12-09 15:51:17 +00001//===-- FreeBSDThread.h -----------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef liblldb_FreeBSDThread_H_
11#define liblldb_FreeBSDThread_H_
12
Ed Mastefe5a6422015-07-28 15:45:57 +000013// C++ Includes
14#include <memory>
15#include <string>
16
Ed Maste7fd845c2013-12-09 15:51:17 +000017// Other libraries and framework includes
Ed Mastefe5a6422015-07-28 15:45:57 +000018#include "lldb/Target/Thread.h"
Ed Maste1b3f13d2015-09-14 14:20:56 +000019#include "RegisterContextPOSIX.h"
Ed Mastefe5a6422015-07-28 15:45:57 +000020
21class ProcessMessage;
22class ProcessMonitor;
23class POSIXBreakpointProtocol;
Ed Maste7fd845c2013-12-09 15:51:17 +000024
25//------------------------------------------------------------------------------
26// @class FreeBSDThread
27// @brief Abstraction of a FreeBSD thread.
28class FreeBSDThread
Ed Mastefe5a6422015-07-28 15:45:57 +000029 : public lldb_private::Thread
Ed Maste7fd845c2013-12-09 15:51:17 +000030{
31public:
32
33 //------------------------------------------------------------------
34 // Constructors and destructors
35 //------------------------------------------------------------------
36 FreeBSDThread(lldb_private::Process &process, lldb::tid_t tid);
37
38 virtual ~FreeBSDThread();
39
Ed Mastefe5a6422015-07-28 15:45:57 +000040 // POSIXThread
41 void
42 RefreshStateAfterStop() override;
43
44 // This notifies the thread when a private stop occurs.
45 void
46 DidStop () override;
47
48 const char *
49 GetInfo() override;
50
51 void
52 SetName (const char *name) override;
53
54 const char *
55 GetName () override;
56
57 lldb::RegisterContextSP
58 GetRegisterContext() override;
59
60 lldb::RegisterContextSP
61 CreateRegisterContextForFrame (lldb_private::StackFrame *frame) override;
62
63 lldb::addr_t
64 GetThreadPointer () override;
65
66 //--------------------------------------------------------------------------
67 // These functions provide a mapping from the register offset
68 // back to the register index or name for use in debugging or log
69 // output.
70
71 unsigned
72 GetRegisterIndexFromOffset(unsigned offset);
73
74 const char *
75 GetRegisterName(unsigned reg);
76
77 const char *
78 GetRegisterNameFromOffset(unsigned offset);
79
80 //--------------------------------------------------------------------------
81 // These methods form a specialized interface to POSIX threads.
82 //
83 bool Resume();
84
85 void Notify(const ProcessMessage &message);
86
87 //--------------------------------------------------------------------------
88 // These methods provide an interface to watchpoints
89 //
90 bool EnableHardwareWatchpoint(lldb_private::Watchpoint *wp);
91
92 bool DisableHardwareWatchpoint(lldb_private::Watchpoint *wp);
93
94 uint32_t NumSupportedHardwareWatchpoints();
95
96 uint32_t FindVacantWatchpointIndex();
97
98protected:
99 POSIXBreakpointProtocol *
100 GetPOSIXBreakpointProtocol ()
101 {
102 if (!m_reg_context_sp)
103 m_reg_context_sp = GetRegisterContext();
104 return m_posix_thread;
105 }
106
107 std::unique_ptr<lldb_private::StackFrame> m_frame_ap;
108
109 lldb::BreakpointSiteSP m_breakpoint;
110
111 bool m_thread_name_valid;
112 std::string m_thread_name;
113 POSIXBreakpointProtocol *m_posix_thread;
114
115 ProcessMonitor &
116 GetMonitor();
117
118 bool
119 CalculateStopInfo() override;
120
121 void BreakNotify(const ProcessMessage &message);
122 void WatchNotify(const ProcessMessage &message);
123 virtual void TraceNotify(const ProcessMessage &message);
124 void LimboNotify(const ProcessMessage &message);
125 void SignalNotify(const ProcessMessage &message);
126 void SignalDeliveredNotify(const ProcessMessage &message);
127 void CrashNotify(const ProcessMessage &message);
Ed Mastefe5a6422015-07-28 15:45:57 +0000128 void ExitNotify(const ProcessMessage &message);
129 void ExecNotify(const ProcessMessage &message);
130
131 lldb_private::Unwind *
132 GetUnwinder() override;
133
Ed Maste7fd845c2013-12-09 15:51:17 +0000134 //--------------------------------------------------------------------------
135 // FreeBSDThread internal API.
136
137 // POSIXThread override
138 virtual void
Davide Italiano7769b4a2015-11-04 23:12:17 +0000139 WillResume(lldb::StateType resume_state) override;
Ed Maste7fd845c2013-12-09 15:51:17 +0000140};
141
142#endif // #ifndef liblldb_FreeBSDThread_H_