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_
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"
28 class ProcessFreeBSD :
29 public lldb_private::Process
33 //------------------------------------------------------------------
35 //------------------------------------------------------------------
36 static lldb::ProcessSP
37 CreateInstance(lldb::TargetSP target_sp,
38 lldb_private::Listener &listener,
39 const lldb_private::FileSpec *crash_file_path);
47 static lldb_private::ConstString
48 GetPluginNameStatic();
51 GetPluginDescriptionStatic();
53 //------------------------------------------------------------------
54 // Constructors and destructors
55 //------------------------------------------------------------------
56 ProcessFreeBSD(lldb::TargetSP target_sp,
57 lldb_private::Listener &listener,
58 lldb::UnixSignalsSP &unix_signals_sp);
62 virtual lldb_private::Error
63 WillResume() override;
65 //------------------------------------------------------------------
66 // PluginInterface protocol
67 //------------------------------------------------------------------
68 virtual lldb_private::ConstString
69 GetPluginName() override;
72 GetPluginVersion() override;
75 //------------------------------------------------------------------
77 //------------------------------------------------------------------
82 CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
85 WillLaunch(lldb_private::Module *module) override;
88 DoAttachToProcessWithID (lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info) override;
91 DoLaunch (lldb_private::Module *exe_module,
92 lldb_private::ProcessLaunchInfo &launch_info) override;
101 DoHalt(bool &caused_stop) override;
104 DoDetach(bool keep_stopped) override;
107 DoSignal(int signal) override;
110 DoDestroy() override;
113 DoDidExec() override;
116 RefreshStateAfterStop() override;
122 DoReadMemory(lldb::addr_t vm_addr,
125 lldb_private::Error &error) override;
128 DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
129 lldb_private::Error &error) override;
132 DoAllocateMemory(size_t size, uint32_t permissions,
133 lldb_private::Error &error) override;
136 DoDeallocateMemory(lldb::addr_t ptr) override;
139 GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site);
142 EnableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
145 DisableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
148 EnableWatchpoint(lldb_private::Watchpoint *wp, bool notify = true) override;
151 DisableWatchpoint(lldb_private::Watchpoint *wp, bool notify = true) override;
154 GetWatchpointSupportInfo(uint32_t &num) override;
157 GetWatchpointSupportInfo(uint32_t &num, bool &after) override;
160 UpdateThreadListIfNeeded();
163 UpdateThreadList(lldb_private::ThreadList &old_thread_list,
164 lldb_private::ThreadList &new_thread_list) override;
166 virtual lldb::ByteOrder
167 GetByteOrder() const;
170 GetImageInfoAddress() override;
173 PutSTDIN(const char *buf, size_t len, lldb_private::Error &error) override;
175 const lldb::DataBufferSP
176 GetAuxvData () override;
178 //--------------------------------------------------------------------------
179 // ProcessFreeBSD internal API.
181 /// Registers the given message with this process.
183 SendMessage(const ProcessMessage &message);
186 GetMonitor() { assert(m_monitor); return *m_monitor; }
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);
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.
196 AddThreadForInitialStopIfNeeded(lldb::tid_t stop_tid);
199 WaitingForInitialStop(lldb::tid_t stop_tid);
201 virtual FreeBSDThread *
202 CreateNewFreeBSDThread(lldb_private::Process &process, lldb::tid_t tid);
205 /// Target byte order.
206 lldb::ByteOrder m_byte_order;
209 ProcessMonitor *m_monitor;
211 /// The module we are executing.
212 lldb_private::Module *m_module;
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;
218 /// Drive any exit events to completion.
221 /// Returns true if the process has exited.
224 /// Returns true if the process is stopped.
227 /// Returns true if at least one running is currently running
228 bool IsAThreadRunning();
230 typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
231 MMapMap m_addr_to_mmap_size;
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;
238 friend class FreeBSDThread;
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;
249 #endif // liblldb_ProcessFreeBSD_H_