Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 1 | //===-- NativeProcessLinux.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_NativeProcessLinux_H_ |
| 11 | #define liblldb_NativeProcessLinux_H_ |
| 12 | |
| 13 | // C Includes |
| 14 | #include <semaphore.h> |
| 15 | #include <signal.h> |
| 16 | |
| 17 | // C++ Includes |
| 18 | #include <unordered_set> |
| 19 | |
| 20 | // Other libraries and framework includes |
| 21 | #include "lldb/Core/ArchSpec.h" |
| 22 | #include "lldb/lldb-types.h" |
| 23 | #include "lldb/Host/Debug.h" |
Zachary Turner | 39de311 | 2014-09-09 20:54:56 +0000 | [diff] [blame] | 24 | #include "lldb/Host/HostThread.h" |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 25 | #include "lldb/Host/Mutex.h" |
| 26 | #include "lldb/Target/MemoryRegionInfo.h" |
| 27 | |
Chaoren Lin | 2fe1d0a | 2015-02-03 01:51:38 +0000 | [diff] [blame] | 28 | #include "lldb/Host/common/NativeProcessProtocol.h" |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 29 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 30 | namespace lldb_private { |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 31 | class Error; |
| 32 | class Module; |
| 33 | class Scalar; |
| 34 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 35 | namespace process_linux { |
| 36 | class ThreadStateCoordinator; |
| 37 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 38 | /// @class NativeProcessLinux |
| 39 | /// @brief Manages communication with the inferior (debugee) process. |
| 40 | /// |
| 41 | /// Upon construction, this class prepares and launches an inferior process for |
| 42 | /// debugging. |
| 43 | /// |
| 44 | /// Changes in the inferior process state are broadcasted. |
| 45 | class NativeProcessLinux: public NativeProcessProtocol |
| 46 | { |
| 47 | public: |
| 48 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 49 | static Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 50 | LaunchProcess ( |
| 51 | Module *exe_module, |
| 52 | ProcessLaunchInfo &launch_info, |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 53 | NativeProcessProtocol::NativeDelegate &native_delegate, |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 54 | NativeProcessProtocolSP &native_process_sp); |
| 55 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 56 | static Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 57 | AttachToProcess ( |
| 58 | lldb::pid_t pid, |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 59 | NativeProcessProtocol::NativeDelegate &native_delegate, |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 60 | NativeProcessProtocolSP &native_process_sp); |
| 61 | |
| 62 | // --------------------------------------------------------------------- |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 63 | // NativeProcessProtocol Interface |
| 64 | // --------------------------------------------------------------------- |
| 65 | Error |
| 66 | Resume (const ResumeActionList &resume_actions) override; |
| 67 | |
| 68 | Error |
| 69 | Halt () override; |
| 70 | |
| 71 | Error |
| 72 | Detach () override; |
| 73 | |
| 74 | Error |
| 75 | Signal (int signo) override; |
| 76 | |
| 77 | Error |
Chaoren Lin | e9547b8 | 2015-02-03 01:51:00 +0000 | [diff] [blame] | 78 | Interrupt () override; |
| 79 | |
| 80 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 81 | Kill () override; |
| 82 | |
| 83 | Error |
| 84 | GetMemoryRegionInfo (lldb::addr_t load_addr, MemoryRegionInfo &range_info) override; |
| 85 | |
| 86 | Error |
Chaoren Lin | 3eb4b45 | 2015-04-29 17:24:48 +0000 | [diff] [blame] | 87 | ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 88 | |
| 89 | Error |
Chaoren Lin | 3eb4b45 | 2015-04-29 17:24:48 +0000 | [diff] [blame] | 90 | ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 91 | |
| 92 | Error |
Chaoren Lin | 3eb4b45 | 2015-04-29 17:24:48 +0000 | [diff] [blame] | 93 | WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) override; |
| 94 | |
| 95 | Error |
| 96 | AllocateMemory(size_t size, uint32_t permissions, lldb::addr_t &addr) override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 97 | |
| 98 | Error |
| 99 | DeallocateMemory (lldb::addr_t addr) override; |
| 100 | |
| 101 | lldb::addr_t |
| 102 | GetSharedLibraryInfoAddress () override; |
| 103 | |
| 104 | size_t |
| 105 | UpdateThreads () override; |
| 106 | |
| 107 | bool |
| 108 | GetArchitecture (ArchSpec &arch) const override; |
| 109 | |
| 110 | Error |
| 111 | SetBreakpoint (lldb::addr_t addr, uint32_t size, bool hardware) override; |
| 112 | |
Pavel Labath | 45f5cb3 | 2015-05-05 15:05:50 +0000 | [diff] [blame] | 113 | Error |
| 114 | SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override; |
| 115 | |
| 116 | Error |
| 117 | RemoveWatchpoint (lldb::addr_t addr) override; |
| 118 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 119 | void |
| 120 | DoStopIDBumped (uint32_t newBumpId) override; |
| 121 | |
Oleksiy Vyalov | 8bc34f4 | 2015-02-19 17:58:04 +0000 | [diff] [blame] | 122 | void |
| 123 | Terminate () override; |
| 124 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 125 | // --------------------------------------------------------------------- |
| 126 | // Interface used by NativeRegisterContext-derived classes. |
| 127 | // --------------------------------------------------------------------- |
| 128 | |
| 129 | /// Reads the contents from the register identified by the given (architecture |
| 130 | /// dependent) offset. |
| 131 | /// |
| 132 | /// This method is provided for use by RegisterContextLinux derivatives. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 133 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 134 | ReadRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name, |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 135 | unsigned size, RegisterValue &value); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 136 | |
| 137 | /// Writes the given value to the register identified by the given |
| 138 | /// (architecture dependent) offset. |
| 139 | /// |
| 140 | /// This method is provided for use by RegisterContextLinux derivatives. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 141 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 142 | WriteRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name, |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 143 | const RegisterValue &value); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 144 | |
| 145 | /// Reads all general purpose registers into the specified buffer. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 146 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 147 | ReadGPR(lldb::tid_t tid, void *buf, size_t buf_size); |
| 148 | |
| 149 | /// Reads generic floating point registers into the specified buffer. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 150 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 151 | ReadFPR(lldb::tid_t tid, void *buf, size_t buf_size); |
| 152 | |
| 153 | /// Reads the specified register set into the specified buffer. |
| 154 | /// For instance, the extended floating-point register set. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 155 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 156 | ReadRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset); |
| 157 | |
| 158 | /// Writes all general purpose registers into the specified buffer. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 159 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 160 | WriteGPR(lldb::tid_t tid, void *buf, size_t buf_size); |
| 161 | |
| 162 | /// Writes generic floating point registers into the specified buffer. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 163 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 164 | WriteFPR(lldb::tid_t tid, void *buf, size_t buf_size); |
| 165 | |
| 166 | /// Writes the specified register set into the specified buffer. |
| 167 | /// For instance, the extended floating-point register set. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 168 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 169 | WriteRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset); |
Tamas Berghammer | 7cb18bf | 2015-03-24 11:15:23 +0000 | [diff] [blame] | 170 | |
| 171 | Error |
| 172 | GetLoadedModuleFileSpec(const char* module_path, FileSpec& file_spec) override; |
| 173 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 174 | protected: |
| 175 | // --------------------------------------------------------------------- |
| 176 | // NativeProcessProtocol protected interface |
| 177 | // --------------------------------------------------------------------- |
| 178 | Error |
| 179 | GetSoftwareBreakpointTrapOpcode (size_t trap_opcode_size_hint, size_t &actual_opcode_size, const uint8_t *&trap_opcode_bytes) override; |
| 180 | |
| 181 | private: |
| 182 | |
Pavel Labath | 1107b5a | 2015-04-17 14:07:49 +0000 | [diff] [blame] | 183 | class Monitor; |
| 184 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 185 | ArchSpec m_arch; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 186 | |
Pavel Labath | 1107b5a | 2015-04-17 14:07:49 +0000 | [diff] [blame] | 187 | std::unique_ptr<Monitor> m_monitor_up; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 188 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 189 | LazyBool m_supports_mem_region; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 190 | std::vector<MemoryRegionInfo> m_mem_region_cache; |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 191 | Mutex m_mem_region_cache_mutex; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 192 | |
Chaoren Lin | fa03ad2 | 2015-02-03 01:50:42 +0000 | [diff] [blame] | 193 | std::unique_ptr<ThreadStateCoordinator> m_coordinator_up; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 194 | |
Tamas Berghammer | d8c338d | 2015-04-15 09:47:02 +0000 | [diff] [blame] | 195 | // List of thread ids stepping with a breakpoint with the address of |
| 196 | // the relevan breakpoint |
| 197 | std::map<lldb::tid_t, lldb::addr_t> m_threads_stepping_with_breakpoint; |
| 198 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 199 | /// @class LauchArgs |
| 200 | /// |
| 201 | /// @brief Simple structure to pass data to the thread responsible for |
| 202 | /// launching a child process. |
Pavel Labath | bd7cbc5 | 2015-04-20 13:53:49 +0000 | [diff] [blame] | 203 | struct LaunchArgs |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 204 | { |
Pavel Labath | bd7cbc5 | 2015-04-20 13:53:49 +0000 | [diff] [blame] | 205 | LaunchArgs(Module *module, |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 206 | char const **argv, |
| 207 | char const **envp, |
Todd Fiala | 75f47c3 | 2014-10-11 21:42:09 +0000 | [diff] [blame] | 208 | const std::string &stdin_path, |
| 209 | const std::string &stdout_path, |
| 210 | const std::string &stderr_path, |
Todd Fiala | 0bce1b6 | 2014-08-17 00:10:50 +0000 | [diff] [blame] | 211 | const char *working_dir, |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 212 | const ProcessLaunchInfo &launch_info); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 213 | |
| 214 | ~LaunchArgs(); |
| 215 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 216 | Module *m_module; // The executable image to launch. |
| 217 | char const **m_argv; // Process arguments. |
| 218 | char const **m_envp; // Process environment. |
Todd Fiala | 75f47c3 | 2014-10-11 21:42:09 +0000 | [diff] [blame] | 219 | const std::string &m_stdin_path; // Redirect stdin if not empty. |
| 220 | const std::string &m_stdout_path; // Redirect stdout if not empty. |
| 221 | const std::string &m_stderr_path; // Redirect stderr if not empty. |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 222 | const char *m_working_dir; // Working directory or NULL. |
| 223 | const ProcessLaunchInfo &m_launch_info; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 224 | }; |
| 225 | |
Pavel Labath | bd7cbc5 | 2015-04-20 13:53:49 +0000 | [diff] [blame] | 226 | typedef std::function<::pid_t(Error &)> InitialOperation; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 227 | |
| 228 | // --------------------------------------------------------------------- |
| 229 | // Private Instance Methods |
| 230 | // --------------------------------------------------------------------- |
| 231 | NativeProcessLinux (); |
| 232 | |
| 233 | /// Launches an inferior process ready for debugging. Forms the |
| 234 | /// implementation of Process::DoLaunch. |
| 235 | void |
| 236 | LaunchInferior ( |
| 237 | Module *module, |
| 238 | char const *argv[], |
| 239 | char const *envp[], |
Todd Fiala | 75f47c3 | 2014-10-11 21:42:09 +0000 | [diff] [blame] | 240 | const std::string &stdin_path, |
| 241 | const std::string &stdout_path, |
| 242 | const std::string &stderr_path, |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 243 | const char *working_dir, |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 244 | const ProcessLaunchInfo &launch_info, |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 245 | Error &error); |
| 246 | |
| 247 | /// Attaches to an existing process. Forms the |
Tamas Berghammer | 0cbf0b1 | 2015-03-13 11:16:03 +0000 | [diff] [blame] | 248 | /// implementation of Process::DoAttach |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 249 | void |
| 250 | AttachToInferior (lldb::pid_t pid, Error &error); |
| 251 | |
| 252 | void |
Pavel Labath | bd7cbc5 | 2015-04-20 13:53:49 +0000 | [diff] [blame] | 253 | StartMonitorThread(const InitialOperation &operation, Error &error); |
Pavel Labath | 1107b5a | 2015-04-17 14:07:49 +0000 | [diff] [blame] | 254 | |
Pavel Labath | bd7cbc5 | 2015-04-20 13:53:49 +0000 | [diff] [blame] | 255 | ::pid_t |
| 256 | Launch(LaunchArgs *args, Error &error); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 257 | |
Pavel Labath | bd7cbc5 | 2015-04-20 13:53:49 +0000 | [diff] [blame] | 258 | ::pid_t |
| 259 | Attach(lldb::pid_t pid, Error &error); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 260 | |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 261 | static Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 262 | SetDefaultPtraceOpts(const lldb::pid_t); |
| 263 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 264 | static bool |
| 265 | DupDescriptor(const char *path, int fd, int flags); |
| 266 | |
Pavel Labath | 1107b5a | 2015-04-17 14:07:49 +0000 | [diff] [blame] | 267 | static void * |
| 268 | MonitorThread(void *baton); |
| 269 | |
| 270 | void |
| 271 | MonitorCallback(lldb::pid_t pid, bool exited, int signal, int status); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 272 | |
| 273 | void |
Pavel Labath | 426bdf8 | 2015-04-28 07:51:52 +0000 | [diff] [blame] | 274 | WaitForNewThread(::pid_t tid); |
| 275 | |
| 276 | void |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 277 | MonitorSIGTRAP(const siginfo_t *info, lldb::pid_t pid); |
| 278 | |
| 279 | void |
Chaoren Lin | c16f5dc | 2015-03-19 23:28:10 +0000 | [diff] [blame] | 280 | MonitorTrace(lldb::pid_t pid, NativeThreadProtocolSP thread_sp); |
| 281 | |
| 282 | void |
| 283 | MonitorBreakpoint(lldb::pid_t pid, NativeThreadProtocolSP thread_sp); |
| 284 | |
| 285 | void |
| 286 | MonitorWatchpoint(lldb::pid_t pid, NativeThreadProtocolSP thread_sp, uint32_t wp_index); |
| 287 | |
| 288 | void |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 289 | MonitorSignal(const siginfo_t *info, lldb::pid_t pid, bool exited); |
| 290 | |
Tamas Berghammer | e770868 | 2015-04-22 10:00:23 +0000 | [diff] [blame] | 291 | bool |
| 292 | SupportHardwareSingleStepping() const; |
| 293 | |
| 294 | Error |
| 295 | SetupSoftwareSingleStepping(NativeThreadProtocolSP thread_sp); |
| 296 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 297 | #if 0 |
| 298 | static ::ProcessMessage::CrashReason |
| 299 | GetCrashReasonForSIGSEGV(const siginfo_t *info); |
| 300 | |
| 301 | static ::ProcessMessage::CrashReason |
| 302 | GetCrashReasonForSIGILL(const siginfo_t *info); |
| 303 | |
| 304 | static ::ProcessMessage::CrashReason |
| 305 | GetCrashReasonForSIGFPE(const siginfo_t *info); |
| 306 | |
| 307 | static ::ProcessMessage::CrashReason |
| 308 | GetCrashReasonForSIGBUS(const siginfo_t *info); |
| 309 | #endif |
| 310 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 311 | bool |
| 312 | HasThreadNoLock (lldb::tid_t thread_id); |
| 313 | |
| 314 | NativeThreadProtocolSP |
| 315 | MaybeGetThreadNoLock (lldb::tid_t thread_id); |
| 316 | |
| 317 | bool |
| 318 | StopTrackingThread (lldb::tid_t thread_id); |
| 319 | |
| 320 | NativeThreadProtocolSP |
| 321 | AddThread (lldb::tid_t thread_id); |
| 322 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 323 | Error |
Tamas Berghammer | 63c8be9 | 2015-04-15 09:38:48 +0000 | [diff] [blame] | 324 | GetSoftwareBreakpointPCOffset (NativeRegisterContextSP context_sp, uint32_t &actual_opcode_size); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 325 | |
| 326 | Error |
| 327 | FixupBreakpointPCAsNeeded (NativeThreadProtocolSP &thread_sp); |
| 328 | |
| 329 | /// Writes a siginfo_t structure corresponding to the given thread ID to the |
| 330 | /// memory region pointed to by @p siginfo. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 331 | Error |
| 332 | GetSignalInfo(lldb::tid_t tid, void *siginfo); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 333 | |
| 334 | /// Writes the raw event message code (vis-a-vis PTRACE_GETEVENTMSG) |
| 335 | /// corresponding to the given thread ID to the memory pointed to by @p |
| 336 | /// message. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 337 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 338 | GetEventMessage(lldb::tid_t tid, unsigned long *message); |
| 339 | |
| 340 | /// Resumes the given thread. If @p signo is anything but |
| 341 | /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 342 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 343 | Resume(lldb::tid_t tid, uint32_t signo); |
| 344 | |
| 345 | /// Single steps the given thread. If @p signo is anything but |
| 346 | /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 347 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 348 | SingleStep(lldb::tid_t tid, uint32_t signo); |
| 349 | |
Chaoren Lin | fa03ad2 | 2015-02-03 01:50:42 +0000 | [diff] [blame] | 350 | // ThreadStateCoordinator helper methods. |
Todd Fiala | 511e5cd | 2014-09-11 23:29:14 +0000 | [diff] [blame] | 351 | void |
Chaoren Lin | fa03ad2 | 2015-02-03 01:50:42 +0000 | [diff] [blame] | 352 | NotifyThreadCreateStopped (lldb::tid_t tid); |
Todd Fiala | 511e5cd | 2014-09-11 23:29:14 +0000 | [diff] [blame] | 353 | |
| 354 | void |
Chaoren Lin | fa03ad2 | 2015-02-03 01:50:42 +0000 | [diff] [blame] | 355 | NotifyThreadCreateRunning (lldb::tid_t tid); |
| 356 | |
| 357 | void |
| 358 | NotifyThreadDeath (lldb::tid_t tid); |
| 359 | |
| 360 | void |
| 361 | NotifyThreadStop (lldb::tid_t tid); |
| 362 | |
| 363 | void |
| 364 | CallAfterRunningThreadsStop (lldb::tid_t tid, |
| 365 | const std::function<void (lldb::tid_t tid)> &call_after_function); |
Todd Fiala | 511e5cd | 2014-09-11 23:29:14 +0000 | [diff] [blame] | 366 | |
Chaoren Lin | 03f12d6 | 2015-02-03 01:50:49 +0000 | [diff] [blame] | 367 | void |
| 368 | CallAfterRunningThreadsStopWithSkipTID (lldb::tid_t deferred_signal_tid, |
| 369 | lldb::tid_t skip_stop_request_tid, |
| 370 | const std::function<void (lldb::tid_t tid)> &call_after_function); |
| 371 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 372 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 373 | Detach(lldb::tid_t tid); |
Chaoren Lin | 86fd8e4 | 2015-02-03 01:51:15 +0000 | [diff] [blame] | 374 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 375 | Error |
Chaoren Lin | 86fd8e4 | 2015-02-03 01:51:15 +0000 | [diff] [blame] | 376 | RequestThreadStop (const lldb::pid_t pid, const lldb::tid_t tid); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 377 | }; |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 378 | |
| 379 | } // namespace process_linux |
| 380 | } // namespace lldb_private |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 381 | |
| 382 | #endif // #ifndef liblldb_NativeProcessLinux_H_ |