blob: 8402aad3496b2214de67f3ff5577d6b2e26424d9 [file] [log] [blame]
Johnny Chen9ed5b492012-01-05 21:48:15 +00001//===-- ProcessPOSIX.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_ProcessPOSIX_H_
11#define liblldb_ProcessPOSIX_H_
12
13// C Includes
14
15// C++ Includes
16#include <queue>
17
18// Other libraries and framework includes
19#include "lldb/Target/Process.h"
20#include "lldb/Target/UnixSignals.h"
21#include "ProcessMessage.h"
22
23class ProcessMonitor;
24
25class ProcessPOSIX :
26 public lldb_private::Process
27{
28public:
29
30 //------------------------------------------------------------------
31 // Constructors and destructors
32 //------------------------------------------------------------------
33 ProcessPOSIX(lldb_private::Target& target,
34 lldb_private::Listener &listener);
35
36 virtual
37 ~ProcessPOSIX();
38
39 //------------------------------------------------------------------
40 // Process protocol.
41 //------------------------------------------------------------------
42 virtual bool
43 CanDebug(lldb_private::Target &target, bool plugin_specified_by_name);
44
45 virtual lldb_private::Error
46 WillLaunch(lldb_private::Module *module);
47
48 virtual lldb_private::Error
49 DoAttachToProcessWithID(lldb::pid_t pid);
50
51 virtual lldb_private::Error
Greg Claytone2186ed2012-09-07 17:51:47 +000052 DoAttachToProcessWithID (lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info);
53
54 virtual lldb_private::Error
Johnny Chen9ed5b492012-01-05 21:48:15 +000055 DoLaunch (lldb_private::Module *exe_module,
56 const lldb_private::ProcessLaunchInfo &launch_info);
57
58 virtual void
59 DidLaunch();
60
61 virtual lldb_private::Error
62 DoResume();
63
64 virtual lldb_private::Error
65 DoHalt(bool &caused_stop);
66
67 virtual lldb_private::Error
Jim Inghamacff8952013-05-02 00:27:30 +000068 DoDetach(bool keep_stopped);
Johnny Chen9ed5b492012-01-05 21:48:15 +000069
70 virtual lldb_private::Error
71 DoSignal(int signal);
72
73 virtual lldb_private::Error
74 DoDestroy();
75
76 virtual void
77 RefreshStateAfterStop();
78
79 virtual bool
80 IsAlive();
81
82 virtual size_t
83 DoReadMemory(lldb::addr_t vm_addr,
84 void *buf,
85 size_t size,
86 lldb_private::Error &error);
87
88 virtual size_t
89 DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
90 lldb_private::Error &error);
91
92 virtual lldb::addr_t
93 DoAllocateMemory(size_t size, uint32_t permissions,
94 lldb_private::Error &error);
95
96 virtual lldb_private::Error
97 DoDeallocateMemory(lldb::addr_t ptr);
98
Matt Kopec00049b82013-02-27 20:13:38 +000099 virtual lldb::addr_t
100 ResolveIndirectFunction(const lldb_private::Address *address, lldb_private::Error &error);
101
Johnny Chen9ed5b492012-01-05 21:48:15 +0000102 virtual size_t
103 GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site);
104
105 virtual lldb_private::Error
Daniel Maleab7eec012013-02-15 20:23:25 +0000106 EnableBreakpointSite(lldb_private::BreakpointSite *bp_site);
Johnny Chen9ed5b492012-01-05 21:48:15 +0000107
108 virtual lldb_private::Error
Daniel Maleab7eec012013-02-15 20:23:25 +0000109 DisableBreakpointSite(lldb_private::BreakpointSite *bp_site);
Johnny Chen9ed5b492012-01-05 21:48:15 +0000110
Matt Kopece9ea0da2013-05-07 19:29:28 +0000111 virtual lldb_private::Error
112 EnableWatchpoint(lldb_private::Watchpoint *wp, bool notify = true);
113
114 virtual lldb_private::Error
115 DisableWatchpoint(lldb_private::Watchpoint *wp, bool notify = true);
116
117 virtual lldb_private::Error
118 GetWatchpointSupportInfo(uint32_t &num);
119
120 virtual lldb_private::Error
121 GetWatchpointSupportInfo(uint32_t &num, bool &after);
122
Johnny Chen9ed5b492012-01-05 21:48:15 +0000123 virtual uint32_t
124 UpdateThreadListIfNeeded();
125
Greg Claytonc3c0b0e2012-04-12 19:04:34 +0000126 virtual bool
Johnny Chen9ed5b492012-01-05 21:48:15 +0000127 UpdateThreadList(lldb_private::ThreadList &old_thread_list,
128 lldb_private::ThreadList &new_thread_list) = 0;
129
130 virtual lldb::ByteOrder
131 GetByteOrder() const;
132
133 virtual lldb::addr_t
134 GetImageInfoAddress();
135
136 virtual size_t
137 PutSTDIN(const char *buf, size_t len, lldb_private::Error &error);
138
Johnny Chen9ed5b492012-01-05 21:48:15 +0000139 //--------------------------------------------------------------------------
140 // ProcessPOSIX internal API.
141
142 /// Registers the given message with this process.
143 void SendMessage(const ProcessMessage &message);
144
145 ProcessMonitor &
146 GetMonitor() { assert(m_monitor); return *m_monitor; }
147
148 lldb_private::UnixSignals &
149 GetUnixSignals();
150
151 const char *
152 GetFilePath(const lldb_private::ProcessLaunchInfo::FileAction *file_action,
153 const char *default_path);
154
Andrew Kaylor93132f52013-05-28 23:04:25 +0000155 /// Stops all threads in the process.
156 /// The \p stop_tid parameter indicates the thread which initiated the stop.
157 virtual void
158 StopAllThreads(lldb::tid_t stop_tid);
159
Johnny Chen9ed5b492012-01-05 21:48:15 +0000160protected:
161 /// Target byte order.
162 lldb::ByteOrder m_byte_order;
163
164 /// Process monitor;
165 ProcessMonitor *m_monitor;
166
167 /// The module we are executing.
168 lldb_private::Module *m_module;
169
170 /// Message queue notifying this instance of inferior process state changes.
171 lldb_private::Mutex m_message_mutex;
172 std::queue<ProcessMessage> m_message_queue;
173
Johnny Chen9ed5b492012-01-05 21:48:15 +0000174 /// Drive any exit events to completion.
175 bool m_exit_now;
176
177 /// OS-specific signal set.
178 lldb_private::UnixSignals m_signals;
179
180 /// Returns true if the process has exited.
181 bool HasExited();
182
183 /// Returns true if the process is stopped.
184 bool IsStopped();
185
186 typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
187 MMapMap m_addr_to_mmap_size;
188};
189
190#endif // liblldb_MacOSXProcess_H_