• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- POSIXThread.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_POSIXThread_H_
11 #define liblldb_POSIXThread_H_
12 
13 // C Includes
14 // C++ Includes
15 #include <memory>
16 #include <string>
17 
18 // Other libraries and framework includes
19 #include "lldb/Target/Thread.h"
20 #include "RegisterContextPOSIX.h"
21 
22 class ProcessMessage;
23 class ProcessMonitor;
24 class RegisterContextPOSIX;
25 
26 //------------------------------------------------------------------------------
27 // @class POSIXThread
28 // @brief Abstraction of a POSIX thread.
29 class POSIXThread
30     : public lldb_private::Thread
31 {
32 public:
33     POSIXThread(lldb_private::Process &process, lldb::tid_t tid);
34 
35     virtual ~POSIXThread();
36 
37     void
38     RefreshStateAfterStop();
39 
40     virtual void
41     WillResume(lldb::StateType resume_state);
42 
43     // This notifies the thread when a private stop occurs.
44     virtual void
45     DidStop ();
46 
47     const char *
48     GetInfo();
49 
50     void
51     SetName (const char *name);
52 
53     const char *
54     GetName ();
55 
56     virtual lldb::RegisterContextSP
57     GetRegisterContext();
58 
59     virtual lldb::RegisterContextSP
60     CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
61 
62     //--------------------------------------------------------------------------
63     // These functions provide a mapping from the register offset
64     // back to the register index or name for use in debugging or log
65     // output.
66 
67     unsigned
68     GetRegisterIndexFromOffset(unsigned offset);
69 
70     const char *
71     GetRegisterName(unsigned reg);
72 
73     const char *
74     GetRegisterNameFromOffset(unsigned offset);
75 
76     //--------------------------------------------------------------------------
77     // These methods form a specialized interface to POSIX threads.
78     //
79     bool Resume();
80 
81     void Notify(const ProcessMessage &message);
82 
83     //--------------------------------------------------------------------------
84     // These methods provide an interface to watchpoints
85     //
86     bool EnableHardwareWatchpoint(lldb_private::Watchpoint *wp);
87 
88     bool DisableHardwareWatchpoint(lldb_private::Watchpoint *wp);
89 
90     uint32_t NumSupportedHardwareWatchpoints();
91 
92     uint32_t FindVacantWatchpointIndex();
93 
94 protected:
95     RegisterContextPOSIX *
GetRegisterContextPOSIX()96     GetRegisterContextPOSIX ()
97     {
98         if (!m_reg_context_sp)
99             m_reg_context_sp = GetRegisterContext();
100 #if 0
101         return dynamic_cast<RegisterContextPOSIX*>(m_reg_context_sp.get());
102 #endif
103         return (RegisterContextPOSIX *)m_reg_context_sp.get();
104     }
105 
106     std::unique_ptr<lldb_private::StackFrame> m_frame_ap;
107 
108     lldb::BreakpointSiteSP m_breakpoint;
109 
110     bool m_thread_name_valid;
111     std::string m_thread_name;
112 
113     ProcessMonitor &
114     GetMonitor();
115 
116     virtual bool
117     CalculateStopInfo();
118 
119     void BreakNotify(const ProcessMessage &message);
120     void WatchNotify(const ProcessMessage &message);
121     virtual void TraceNotify(const ProcessMessage &message);
122     void LimboNotify(const ProcessMessage &message);
123     void SignalNotify(const ProcessMessage &message);
124     void SignalDeliveredNotify(const ProcessMessage &message);
125     void CrashNotify(const ProcessMessage &message);
126     void ThreadNotify(const ProcessMessage &message);
127     void ExitNotify(const ProcessMessage &message);
128 
129     lldb_private::Unwind *
130     GetUnwinder();
131 };
132 
133 #endif // #ifndef liblldb_POSIXThread_H_
134