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