]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
Import libucl snapshot 20160604
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / Process / FreeBSD / ProcessFreeBSD.h
1 //===-- ProcessFreeBSD.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_ProcessFreeBSD_H_
11 #define liblldb_ProcessFreeBSD_H_
12
13 // C Includes
14
15 // C++ Includes
16 #include <set>
17 #include <queue>
18
19 // Other libraries and framework includes
20 #include "lldb/Target/Process.h"
21 #include "lldb/Target/ThreadList.h"
22 #include "Plugins/Process/POSIX/ProcessMessage.h"
23 #include "ProcessFreeBSD.h"
24
25 class ProcessMonitor;
26 class FreeBSDThread;
27
28 class ProcessFreeBSD :
29     public lldb_private::Process
30 {
31
32 public:
33     //------------------------------------------------------------------
34     // Static functions.
35     //------------------------------------------------------------------
36     static lldb::ProcessSP
37     CreateInstance(lldb::TargetSP target_sp,
38                    lldb_private::Listener &listener,
39                    const lldb_private::FileSpec *crash_file_path);
40
41     static void
42     Initialize();
43
44     static void
45     Terminate();
46
47     static lldb_private::ConstString
48     GetPluginNameStatic();
49
50     static const char *
51     GetPluginDescriptionStatic();
52
53     //------------------------------------------------------------------
54     // Constructors and destructors
55     //------------------------------------------------------------------
56     ProcessFreeBSD(lldb::TargetSP target_sp,
57                    lldb_private::Listener &listener,
58                    lldb::UnixSignalsSP &unix_signals_sp);
59
60     ~ProcessFreeBSD();
61
62     virtual lldb_private::Error
63     WillResume() override;
64
65     //------------------------------------------------------------------
66     // PluginInterface protocol
67     //------------------------------------------------------------------
68     virtual lldb_private::ConstString
69     GetPluginName() override;
70
71     virtual uint32_t
72     GetPluginVersion() override;
73
74 public:
75     //------------------------------------------------------------------
76     // Process protocol.
77     //------------------------------------------------------------------
78     void
79     Finalize() override;
80
81     bool
82     CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
83
84     lldb_private::Error
85     WillLaunch(lldb_private::Module *module) override;
86
87     lldb_private::Error
88     DoAttachToProcessWithID (lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info) override;
89
90     lldb_private::Error
91     DoLaunch (lldb_private::Module *exe_module,
92               lldb_private::ProcessLaunchInfo &launch_info) override;
93
94     void
95     DidLaunch() override;
96
97     lldb_private::Error
98     DoResume() override;
99
100     lldb_private::Error
101     DoHalt(bool &caused_stop) override;
102
103     lldb_private::Error
104     DoDetach(bool keep_stopped) override;
105
106     lldb_private::Error
107     DoSignal(int signal) override;
108
109     lldb_private::Error
110     DoDestroy() override;
111
112     void
113     DoDidExec() override;
114
115     void
116     RefreshStateAfterStop() override;
117
118     bool
119     IsAlive() override;
120
121     size_t
122     DoReadMemory(lldb::addr_t vm_addr,
123                  void *buf,
124                  size_t size,
125                  lldb_private::Error &error) override;
126
127     size_t
128     DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
129                   lldb_private::Error &error) override;
130
131     lldb::addr_t
132     DoAllocateMemory(size_t size, uint32_t permissions,
133                      lldb_private::Error &error) override;
134
135     lldb_private::Error
136     DoDeallocateMemory(lldb::addr_t ptr) override;
137
138     virtual size_t
139     GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site);
140
141     lldb_private::Error
142     EnableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
143
144     lldb_private::Error
145     DisableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
146
147     lldb_private::Error
148     EnableWatchpoint(lldb_private::Watchpoint *wp, bool notify = true) override;
149
150     lldb_private::Error
151     DisableWatchpoint(lldb_private::Watchpoint *wp, bool notify = true) override;
152
153     lldb_private::Error
154     GetWatchpointSupportInfo(uint32_t &num) override;
155
156     lldb_private::Error
157     GetWatchpointSupportInfo(uint32_t &num, bool &after) override;
158
159     virtual uint32_t
160     UpdateThreadListIfNeeded();
161
162     bool
163     UpdateThreadList(lldb_private::ThreadList &old_thread_list,
164                      lldb_private::ThreadList &new_thread_list) override;
165
166     virtual lldb::ByteOrder
167     GetByteOrder() const;
168
169     lldb::addr_t
170     GetImageInfoAddress() override;
171
172     size_t
173     PutSTDIN(const char *buf, size_t len, lldb_private::Error &error) override;
174
175     const lldb::DataBufferSP
176     GetAuxvData () override;
177
178     //--------------------------------------------------------------------------
179     // ProcessFreeBSD internal API.
180
181     /// Registers the given message with this process.
182     virtual void
183     SendMessage(const ProcessMessage &message);
184
185     ProcessMonitor &
186     GetMonitor() { assert(m_monitor); return *m_monitor; }
187
188     lldb_private::FileSpec
189     GetFileSpec(const lldb_private::FileAction *file_action,
190                 const lldb_private::FileSpec &default_file_spec,
191                 const lldb_private::FileSpec &dbg_pts_file_spec);
192
193     /// Adds the thread to the list of threads for which we have received the initial stopping signal.
194     /// The \p stop_tid parameter indicates the thread which the stop happened for.
195     bool
196     AddThreadForInitialStopIfNeeded(lldb::tid_t stop_tid);
197
198     bool
199     WaitingForInitialStop(lldb::tid_t stop_tid);
200
201     virtual FreeBSDThread *
202     CreateNewFreeBSDThread(lldb_private::Process &process, lldb::tid_t tid);
203
204 protected:
205     /// Target byte order.
206     lldb::ByteOrder m_byte_order;
207
208     /// Process monitor;
209     ProcessMonitor *m_monitor;
210
211     /// The module we are executing.
212     lldb_private::Module *m_module;
213
214     /// Message queue notifying this instance of inferior process state changes.
215     lldb_private::Mutex m_message_mutex;
216     std::queue<ProcessMessage> m_message_queue;
217
218     /// Drive any exit events to completion.
219     bool m_exit_now;
220
221     /// Returns true if the process has exited.
222     bool HasExited();
223
224     /// Returns true if the process is stopped.
225     bool IsStopped();
226
227     /// Returns true if at least one running is currently running
228     bool IsAThreadRunning();
229
230     typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
231     MMapMap m_addr_to_mmap_size;
232
233     typedef std::set<lldb::tid_t> ThreadStopSet;
234     /// Every thread begins with a stop signal. This keeps track
235     /// of the threads for which we have received the stop signal.
236     ThreadStopSet m_seen_initial_stop;
237
238     friend class FreeBSDThread;
239
240     typedef std::vector<lldb::tid_t> tid_collection;
241     tid_collection m_suspend_tids;
242     tid_collection m_run_tids;
243     tid_collection m_step_tids;
244
245     int m_resume_signo;
246
247 };
248
249 #endif  // liblldb_ProcessFreeBSD_H_