Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 1 | //===-- ProcessLinux.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_ProcessLinux_H_ |
| 11 | #define liblldb_ProcessLinux_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 "ProcessMessage.h" |
| 21 | |
| 22 | class ProcessMonitor; |
| 23 | |
| 24 | class ProcessLinux : |
| 25 | public lldb_private::Process |
| 26 | { |
| 27 | public: |
| 28 | //------------------------------------------------------------------ |
| 29 | // Static functions. |
| 30 | //------------------------------------------------------------------ |
| 31 | static Process* |
| 32 | CreateInstance(lldb_private::Target& target, |
| 33 | lldb_private::Listener &listener); |
| 34 | |
| 35 | static void |
| 36 | Initialize(); |
| 37 | |
| 38 | static void |
| 39 | Terminate(); |
| 40 | |
| 41 | static const char * |
| 42 | GetPluginNameStatic(); |
| 43 | |
| 44 | static const char * |
| 45 | GetPluginDescriptionStatic(); |
| 46 | |
| 47 | //------------------------------------------------------------------ |
| 48 | // Constructors and destructors |
| 49 | //------------------------------------------------------------------ |
| 50 | ProcessLinux(lldb_private::Target& target, |
| 51 | lldb_private::Listener &listener); |
| 52 | |
| 53 | virtual |
| 54 | ~ProcessLinux(); |
| 55 | |
| 56 | //------------------------------------------------------------------ |
| 57 | // Process protocol. |
| 58 | //------------------------------------------------------------------ |
| 59 | virtual bool |
| 60 | CanDebug(lldb_private::Target &target); |
| 61 | |
| 62 | virtual lldb_private::Error |
Stephen Wilson | 92241ef | 2011-01-16 19:45:39 +0000 | [diff] [blame] | 63 | WillLaunch(lldb_private::Module *module); |
| 64 | |
| 65 | virtual lldb_private::Error |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 66 | DoAttachToProcessWithID(lldb::pid_t pid); |
| 67 | |
| 68 | virtual lldb_private::Error |
| 69 | DoLaunch(lldb_private::Module *module, |
| 70 | char const *argv[], |
| 71 | char const *envp[], |
Stephen Wilson | 3a80431 | 2011-01-04 21:41:31 +0000 | [diff] [blame] | 72 | uint32_t launch_flags, |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 73 | const char *stdin_path, |
| 74 | const char *stdout_path, |
| 75 | const char *stderr_path); |
| 76 | |
Stephen Wilson | 92241ef | 2011-01-16 19:45:39 +0000 | [diff] [blame] | 77 | virtual void |
| 78 | DidLaunch(); |
| 79 | |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 80 | virtual lldb_private::Error |
| 81 | DoResume(); |
| 82 | |
| 83 | virtual lldb_private::Error |
Stephen Wilson | 3a80431 | 2011-01-04 21:41:31 +0000 | [diff] [blame] | 84 | DoHalt(bool &caused_stop); |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 85 | |
| 86 | virtual lldb_private::Error |
| 87 | DoDetach(); |
| 88 | |
| 89 | virtual lldb_private::Error |
| 90 | DoSignal(int signal); |
| 91 | |
| 92 | virtual lldb_private::Error |
| 93 | DoDestroy(); |
| 94 | |
| 95 | virtual void |
| 96 | RefreshStateAfterStop(); |
| 97 | |
| 98 | virtual bool |
| 99 | IsAlive(); |
| 100 | |
| 101 | virtual size_t |
| 102 | DoReadMemory(lldb::addr_t vm_addr, |
| 103 | void *buf, |
| 104 | size_t size, |
| 105 | lldb_private::Error &error); |
| 106 | |
| 107 | virtual size_t |
| 108 | DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, |
| 109 | lldb_private::Error &error); |
| 110 | |
| 111 | virtual lldb::addr_t |
| 112 | DoAllocateMemory(size_t size, uint32_t permissions, |
| 113 | lldb_private::Error &error); |
| 114 | |
| 115 | lldb::addr_t |
| 116 | AllocateMemory(size_t size, uint32_t permissions, |
| 117 | lldb_private::Error &error); |
| 118 | |
| 119 | virtual lldb_private::Error |
| 120 | DoDeallocateMemory(lldb::addr_t ptr); |
| 121 | |
| 122 | virtual size_t |
| 123 | GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site); |
| 124 | |
| 125 | virtual lldb_private::Error |
| 126 | EnableBreakpoint(lldb_private::BreakpointSite *bp_site); |
| 127 | |
| 128 | virtual lldb_private::Error |
| 129 | DisableBreakpoint(lldb_private::BreakpointSite *bp_site); |
| 130 | |
| 131 | virtual uint32_t |
| 132 | UpdateThreadListIfNeeded(); |
| 133 | |
| 134 | virtual lldb::ByteOrder |
| 135 | GetByteOrder() const; |
| 136 | |
Stephen Wilson | 0131642 | 2011-01-15 00:10:37 +0000 | [diff] [blame] | 137 | virtual lldb::addr_t |
| 138 | GetImageInfoAddress(); |
| 139 | |
Stephen Wilson | 92241ef | 2011-01-16 19:45:39 +0000 | [diff] [blame] | 140 | virtual lldb_private::DynamicLoader * |
| 141 | GetDynamicLoader(); |
| 142 | |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 143 | //------------------------------------------------------------------ |
| 144 | // PluginInterface protocol |
| 145 | //------------------------------------------------------------------ |
| 146 | virtual const char * |
| 147 | GetPluginName(); |
| 148 | |
| 149 | virtual const char * |
| 150 | GetShortPluginName(); |
| 151 | |
| 152 | virtual uint32_t |
| 153 | GetPluginVersion(); |
| 154 | |
| 155 | virtual void |
| 156 | GetPluginCommandHelp(const char *command, lldb_private::Stream *strm); |
| 157 | |
| 158 | virtual lldb_private::Error |
| 159 | ExecutePluginCommand(lldb_private::Args &command, |
| 160 | lldb_private::Stream *strm); |
| 161 | |
| 162 | virtual lldb_private::Log * |
| 163 | EnablePluginLogging(lldb_private::Stream *strm, |
| 164 | lldb_private::Args &command); |
| 165 | |
| 166 | //-------------------------------------------------------------------------- |
| 167 | // ProcessLinux internal API. |
| 168 | |
| 169 | /// Registers the given message with this process. |
| 170 | void SendMessage(const ProcessMessage &message); |
| 171 | |
| 172 | ProcessMonitor &GetMonitor() { return *m_monitor; } |
| 173 | |
| 174 | private: |
| 175 | /// Target byte order. |
| 176 | lldb::ByteOrder m_byte_order; |
| 177 | |
| 178 | /// Process monitor; |
| 179 | ProcessMonitor *m_monitor; |
| 180 | |
| 181 | /// The module we are executing. |
| 182 | lldb_private::Module *m_module; |
| 183 | |
| 184 | /// Message queue notifying this instance of inferior process state changes. |
| 185 | lldb_private::Mutex m_message_mutex; |
| 186 | std::queue<ProcessMessage> m_message_queue; |
| 187 | |
Stephen Wilson | 92241ef | 2011-01-16 19:45:39 +0000 | [diff] [blame] | 188 | /// Dynamic loader plugin associated with this process. |
| 189 | std::auto_ptr<lldb_private::DynamicLoader> m_dyld_ap; |
| 190 | |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 191 | /// Updates the loaded sections provided by the executable. |
| 192 | /// |
| 193 | /// FIXME: It would probably be better to delegate this task to the |
| 194 | /// DynamicLoader plugin, when we have one. |
| 195 | void UpdateLoadedSections(); |
| 196 | |
| 197 | /// Returns true if the process has exited. |
| 198 | bool HasExited(); |
| 199 | }; |
| 200 | |
| 201 | #endif // liblldb_MacOSXProcess_H_ |