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, |
Greg Clayton | de915be | 2011-01-23 05:56:20 +0000 | [diff] [blame] | 75 | const char *stderr_path, |
| 76 | const char *working_directory); |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 77 | |
Stephen Wilson | 92241ef | 2011-01-16 19:45:39 +0000 | [diff] [blame] | 78 | virtual void |
| 79 | DidLaunch(); |
| 80 | |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 81 | virtual lldb_private::Error |
| 82 | DoResume(); |
| 83 | |
| 84 | virtual lldb_private::Error |
Stephen Wilson | 3a80431 | 2011-01-04 21:41:31 +0000 | [diff] [blame] | 85 | DoHalt(bool &caused_stop); |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 86 | |
| 87 | virtual lldb_private::Error |
| 88 | DoDetach(); |
| 89 | |
| 90 | virtual lldb_private::Error |
| 91 | DoSignal(int signal); |
| 92 | |
| 93 | virtual lldb_private::Error |
| 94 | DoDestroy(); |
| 95 | |
| 96 | virtual void |
| 97 | RefreshStateAfterStop(); |
| 98 | |
| 99 | virtual bool |
| 100 | IsAlive(); |
| 101 | |
| 102 | virtual size_t |
| 103 | DoReadMemory(lldb::addr_t vm_addr, |
| 104 | void *buf, |
| 105 | size_t size, |
| 106 | lldb_private::Error &error); |
| 107 | |
| 108 | virtual size_t |
| 109 | DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, |
| 110 | lldb_private::Error &error); |
| 111 | |
| 112 | virtual lldb::addr_t |
| 113 | DoAllocateMemory(size_t size, uint32_t permissions, |
| 114 | lldb_private::Error &error); |
| 115 | |
| 116 | lldb::addr_t |
| 117 | AllocateMemory(size_t size, uint32_t permissions, |
| 118 | lldb_private::Error &error); |
| 119 | |
| 120 | virtual lldb_private::Error |
| 121 | DoDeallocateMemory(lldb::addr_t ptr); |
| 122 | |
| 123 | virtual size_t |
| 124 | GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site); |
| 125 | |
| 126 | virtual lldb_private::Error |
| 127 | EnableBreakpoint(lldb_private::BreakpointSite *bp_site); |
| 128 | |
| 129 | virtual lldb_private::Error |
| 130 | DisableBreakpoint(lldb_private::BreakpointSite *bp_site); |
| 131 | |
| 132 | virtual uint32_t |
| 133 | UpdateThreadListIfNeeded(); |
| 134 | |
| 135 | virtual lldb::ByteOrder |
| 136 | GetByteOrder() const; |
| 137 | |
Stephen Wilson | 0131642 | 2011-01-15 00:10:37 +0000 | [diff] [blame] | 138 | virtual lldb::addr_t |
| 139 | GetImageInfoAddress(); |
| 140 | |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 141 | //------------------------------------------------------------------ |
| 142 | // PluginInterface protocol |
| 143 | //------------------------------------------------------------------ |
| 144 | virtual const char * |
| 145 | GetPluginName(); |
| 146 | |
| 147 | virtual const char * |
| 148 | GetShortPluginName(); |
| 149 | |
| 150 | virtual uint32_t |
| 151 | GetPluginVersion(); |
| 152 | |
| 153 | virtual void |
| 154 | GetPluginCommandHelp(const char *command, lldb_private::Stream *strm); |
| 155 | |
| 156 | virtual lldb_private::Error |
| 157 | ExecutePluginCommand(lldb_private::Args &command, |
| 158 | lldb_private::Stream *strm); |
| 159 | |
| 160 | virtual lldb_private::Log * |
| 161 | EnablePluginLogging(lldb_private::Stream *strm, |
| 162 | lldb_private::Args &command); |
| 163 | |
| 164 | //-------------------------------------------------------------------------- |
| 165 | // ProcessLinux internal API. |
| 166 | |
| 167 | /// Registers the given message with this process. |
| 168 | void SendMessage(const ProcessMessage &message); |
| 169 | |
| 170 | ProcessMonitor &GetMonitor() { return *m_monitor; } |
| 171 | |
| 172 | private: |
| 173 | /// Target byte order. |
| 174 | lldb::ByteOrder m_byte_order; |
| 175 | |
| 176 | /// Process monitor; |
| 177 | ProcessMonitor *m_monitor; |
| 178 | |
| 179 | /// The module we are executing. |
| 180 | lldb_private::Module *m_module; |
| 181 | |
| 182 | /// Message queue notifying this instance of inferior process state changes. |
| 183 | lldb_private::Mutex m_message_mutex; |
| 184 | std::queue<ProcessMessage> m_message_queue; |
| 185 | |
Stephen Wilson | f6f4033 | 2010-07-24 02:19:04 +0000 | [diff] [blame] | 186 | /// Updates the loaded sections provided by the executable. |
| 187 | /// |
| 188 | /// FIXME: It would probably be better to delegate this task to the |
| 189 | /// DynamicLoader plugin, when we have one. |
| 190 | void UpdateLoadedSections(); |
| 191 | |
| 192 | /// Returns true if the process has exited. |
| 193 | bool HasExited(); |
| 194 | }; |
| 195 | |
| 196 | #endif // liblldb_MacOSXProcess_H_ |