]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / Process / FreeBSD / FreeBSDThread.h
1 //===-- 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
13 // C++ Includes
14 #include <memory>
15 #include <string>
16
17 // Other libraries and framework includes
18 #include "RegisterContextPOSIX.h"
19 #include "lldb/Target/Thread.h"
20
21 class ProcessMessage;
22 class ProcessMonitor;
23 class POSIXBreakpointProtocol;
24
25 //------------------------------------------------------------------------------
26 // @class FreeBSDThread
27 // Abstraction of a FreeBSD thread.
28 class FreeBSDThread : public lldb_private::Thread {
29 public:
30   //------------------------------------------------------------------
31   // Constructors and destructors
32   //------------------------------------------------------------------
33   FreeBSDThread(lldb_private::Process &process, lldb::tid_t tid);
34
35   virtual ~FreeBSDThread();
36
37   // POSIXThread
38   void RefreshStateAfterStop() override;
39
40   // This notifies the thread when a private stop occurs.
41   void DidStop() override;
42
43   const char *GetInfo() override;
44
45   void SetName(const char *name) override;
46
47   const char *GetName() override;
48
49   lldb::RegisterContextSP GetRegisterContext() override;
50
51   lldb::RegisterContextSP
52   CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
53
54   lldb::addr_t GetThreadPointer() override;
55
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
59   // output.
60
61   unsigned GetRegisterIndexFromOffset(unsigned offset);
62
63   const char *GetRegisterName(unsigned reg);
64
65   const char *GetRegisterNameFromOffset(unsigned offset);
66
67   //--------------------------------------------------------------------------
68   // These methods form a specialized interface to POSIX threads.
69   //
70   bool Resume();
71
72   void Notify(const ProcessMessage &message);
73
74   //--------------------------------------------------------------------------
75   // These methods provide an interface to watchpoints
76   //
77   bool EnableHardwareWatchpoint(lldb_private::Watchpoint *wp);
78
79   bool DisableHardwareWatchpoint(lldb_private::Watchpoint *wp);
80
81   uint32_t NumSupportedHardwareWatchpoints();
82
83   uint32_t FindVacantWatchpointIndex();
84
85 protected:
86   POSIXBreakpointProtocol *GetPOSIXBreakpointProtocol() {
87     if (!m_reg_context_sp)
88       m_reg_context_sp = GetRegisterContext();
89     return m_posix_thread;
90   }
91
92   std::unique_ptr<lldb_private::StackFrame> m_frame_ap;
93
94   lldb::BreakpointSiteSP m_breakpoint;
95
96   bool m_thread_name_valid;
97   std::string m_thread_name;
98   POSIXBreakpointProtocol *m_posix_thread;
99
100   ProcessMonitor &GetMonitor();
101
102   bool CalculateStopInfo() override;
103
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);
113
114   lldb_private::Unwind *GetUnwinder() override;
115
116   //--------------------------------------------------------------------------
117   // FreeBSDThread internal API.
118
119   // POSIXThread override
120   virtual void WillResume(lldb::StateType resume_state) override;
121 };
122
123 #endif // #ifndef liblldb_FreeBSDThread_H_