1 //===-- ProcessFreeBSD.h ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ProcessFreeBSD_H_
11 #define liblldb_ProcessFreeBSD_H_
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"
29 class ProcessFreeBSD :
30 public lldb_private::Process
34 //------------------------------------------------------------------
36 //------------------------------------------------------------------
37 static lldb::ProcessSP
38 CreateInstance(lldb::TargetSP target_sp,
39 lldb::ListenerSP listener_sp,
40 const lldb_private::FileSpec *crash_file_path);
48 static lldb_private::ConstString
49 GetPluginNameStatic();
52 GetPluginDescriptionStatic();
54 //------------------------------------------------------------------
55 // Constructors and destructors
56 //------------------------------------------------------------------
57 ProcessFreeBSD(lldb::TargetSP target_sp,
58 lldb::ListenerSP listener_sp,
59 lldb::UnixSignalsSP &unix_signals_sp);
63 virtual lldb_private::Error
64 WillResume() override;
66 //------------------------------------------------------------------
67 // PluginInterface protocol
68 //------------------------------------------------------------------
69 virtual lldb_private::ConstString
70 GetPluginName() override;
73 GetPluginVersion() override;
76 //------------------------------------------------------------------
78 //------------------------------------------------------------------
83 CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
86 WillLaunch(lldb_private::Module *module) override;
89 DoAttachToProcessWithID (lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info) override;
92 DoLaunch (lldb_private::Module *exe_module,
93 lldb_private::ProcessLaunchInfo &launch_info) override;
102 DoHalt(bool &caused_stop) override;
105 DoDetach(bool keep_stopped) override;
108 DoSignal(int signal) override;
111 DoDestroy() override;
114 DoDidExec() override;
117 RefreshStateAfterStop() override;
123 DoReadMemory(lldb::addr_t vm_addr,
126 lldb_private::Error &error) override;
129 DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
130 lldb_private::Error &error) override;
133 DoAllocateMemory(size_t size, uint32_t permissions,
134 lldb_private::Error &error) override;
137 DoDeallocateMemory(lldb::addr_t ptr) override;
140 GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site);
143 EnableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
146 DisableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
149 EnableWatchpoint(lldb_private::Watchpoint *wp, bool notify = true) override;
152 DisableWatchpoint(lldb_private::Watchpoint *wp, bool notify = true) override;
155 GetWatchpointSupportInfo(uint32_t &num) override;
158 GetWatchpointSupportInfo(uint32_t &num, bool &after) override;
161 UpdateThreadListIfNeeded();
164 UpdateThreadList(lldb_private::ThreadList &old_thread_list,
165 lldb_private::ThreadList &new_thread_list) override;
167 virtual lldb::ByteOrder
168 GetByteOrder() const;
171 GetImageInfoAddress() override;
174 PutSTDIN(const char *buf, size_t len, lldb_private::Error &error) override;
176 const lldb::DataBufferSP
177 GetAuxvData () override;
179 //--------------------------------------------------------------------------
180 // ProcessFreeBSD internal API.
182 /// Registers the given message with this process.
184 SendMessage(const ProcessMessage &message);
187 GetMonitor() { assert(m_monitor); return *m_monitor; }
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);
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.
197 AddThreadForInitialStopIfNeeded(lldb::tid_t stop_tid);
200 WaitingForInitialStop(lldb::tid_t stop_tid);
202 virtual FreeBSDThread *
203 CreateNewFreeBSDThread(lldb_private::Process &process, lldb::tid_t tid);
206 /// Target byte order.
207 lldb::ByteOrder m_byte_order;
210 ProcessMonitor *m_monitor;
212 /// The module we are executing.
213 lldb_private::Module *m_module;
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;
219 /// Drive any exit events to completion.
222 /// Returns true if the process has exited.
225 /// Returns true if the process is stopped.
228 /// Returns true if at least one running is currently running
229 bool IsAThreadRunning();
231 typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
232 MMapMap m_addr_to_mmap_size;
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;
239 friend class FreeBSDThread;
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;
250 #endif // liblldb_ProcessFreeBSD_H_