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 |
| 87 | ReadMemory (lldb::addr_t addr, void *buf, lldb::addr_t size, lldb::addr_t &bytes_read) override; |
| 88 | |
| 89 | Error |
| 90 | WriteMemory (lldb::addr_t addr, const void *buf, lldb::addr_t size, lldb::addr_t &bytes_written) override; |
| 91 | |
| 92 | Error |
| 93 | AllocateMemory (lldb::addr_t size, uint32_t permissions, lldb::addr_t &addr) override; |
| 94 | |
| 95 | Error |
| 96 | DeallocateMemory (lldb::addr_t addr) override; |
| 97 | |
| 98 | lldb::addr_t |
| 99 | GetSharedLibraryInfoAddress () override; |
| 100 | |
| 101 | size_t |
| 102 | UpdateThreads () override; |
| 103 | |
| 104 | bool |
| 105 | GetArchitecture (ArchSpec &arch) const override; |
| 106 | |
| 107 | Error |
| 108 | SetBreakpoint (lldb::addr_t addr, uint32_t size, bool hardware) override; |
| 109 | |
| 110 | void |
| 111 | DoStopIDBumped (uint32_t newBumpId) override; |
| 112 | |
Oleksiy Vyalov | 8bc34f4 | 2015-02-19 17:58:04 +0000 | [diff] [blame] | 113 | void |
| 114 | Terminate () override; |
| 115 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 116 | // --------------------------------------------------------------------- |
| 117 | // Interface used by NativeRegisterContext-derived classes. |
| 118 | // --------------------------------------------------------------------- |
| 119 | |
| 120 | /// Reads the contents from the register identified by the given (architecture |
| 121 | /// dependent) offset. |
| 122 | /// |
| 123 | /// This method is provided for use by RegisterContextLinux derivatives. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 124 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 125 | ReadRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name, |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 126 | unsigned size, RegisterValue &value); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 127 | |
| 128 | /// Writes the given value to the register identified by the given |
| 129 | /// (architecture dependent) offset. |
| 130 | /// |
| 131 | /// This method is provided for use by RegisterContextLinux derivatives. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 132 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 133 | WriteRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name, |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 134 | const RegisterValue &value); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 135 | |
| 136 | /// Reads all general purpose registers into the specified buffer. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 137 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 138 | ReadGPR(lldb::tid_t tid, void *buf, size_t buf_size); |
| 139 | |
| 140 | /// Reads generic floating point registers into the specified buffer. |
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 | ReadFPR(lldb::tid_t tid, void *buf, size_t buf_size); |
| 143 | |
| 144 | /// Reads the specified register set into the specified buffer. |
| 145 | /// For instance, the extended floating-point register set. |
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 | ReadRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset); |
| 148 | |
| 149 | /// Writes all general purpose 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 | WriteGPR(lldb::tid_t tid, void *buf, size_t buf_size); |
| 152 | |
| 153 | /// Writes generic floating point registers into the specified buffer. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 154 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 155 | WriteFPR(lldb::tid_t tid, void *buf, size_t buf_size); |
| 156 | |
| 157 | /// Writes the specified register set into the specified buffer. |
| 158 | /// For instance, the extended floating-point register set. |
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 | 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] | 161 | |
| 162 | Error |
| 163 | GetLoadedModuleFileSpec(const char* module_path, FileSpec& file_spec) override; |
| 164 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 165 | protected: |
| 166 | // --------------------------------------------------------------------- |
| 167 | // NativeProcessProtocol protected interface |
| 168 | // --------------------------------------------------------------------- |
| 169 | Error |
| 170 | GetSoftwareBreakpointTrapOpcode (size_t trap_opcode_size_hint, size_t &actual_opcode_size, const uint8_t *&trap_opcode_bytes) override; |
| 171 | |
| 172 | private: |
| 173 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 174 | ArchSpec m_arch; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 175 | |
Zachary Turner | 39de311 | 2014-09-09 20:54:56 +0000 | [diff] [blame] | 176 | HostThread m_operation_thread; |
| 177 | HostThread m_monitor_thread; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 178 | |
| 179 | // current operation which must be executed on the priviliged thread |
| 180 | void *m_operation; |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 181 | Mutex m_operation_mutex; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 182 | |
| 183 | // semaphores notified when Operation is ready to be processed and when |
| 184 | // the operation is complete. |
| 185 | sem_t m_operation_pending; |
| 186 | sem_t m_operation_done; |
| 187 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 188 | LazyBool m_supports_mem_region; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 189 | std::vector<MemoryRegionInfo> m_mem_region_cache; |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 190 | Mutex m_mem_region_cache_mutex; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 191 | |
Chaoren Lin | fa03ad2 | 2015-02-03 01:50:42 +0000 | [diff] [blame] | 192 | std::unique_ptr<ThreadStateCoordinator> m_coordinator_up; |
| 193 | HostThread m_coordinator_thread; |
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 | struct OperationArgs |
| 200 | { |
| 201 | OperationArgs(NativeProcessLinux *monitor); |
| 202 | |
| 203 | ~OperationArgs(); |
| 204 | |
| 205 | NativeProcessLinux *m_monitor; // The monitor performing the attach. |
| 206 | sem_t m_semaphore; // Posted to once operation complete. |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 207 | Error m_error; // Set if process operation failed. |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 208 | }; |
| 209 | |
| 210 | /// @class LauchArgs |
| 211 | /// |
| 212 | /// @brief Simple structure to pass data to the thread responsible for |
| 213 | /// launching a child process. |
| 214 | struct LaunchArgs : OperationArgs |
| 215 | { |
| 216 | LaunchArgs(NativeProcessLinux *monitor, |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 217 | Module *module, |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 218 | char const **argv, |
| 219 | char const **envp, |
Todd Fiala | 75f47c3 | 2014-10-11 21:42:09 +0000 | [diff] [blame] | 220 | const std::string &stdin_path, |
| 221 | const std::string &stdout_path, |
| 222 | const std::string &stderr_path, |
Todd Fiala | 0bce1b6 | 2014-08-17 00:10:50 +0000 | [diff] [blame] | 223 | const char *working_dir, |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 224 | const ProcessLaunchInfo &launch_info); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 225 | |
| 226 | ~LaunchArgs(); |
| 227 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 228 | Module *m_module; // The executable image to launch. |
| 229 | char const **m_argv; // Process arguments. |
| 230 | char const **m_envp; // Process environment. |
Todd Fiala | 75f47c3 | 2014-10-11 21:42:09 +0000 | [diff] [blame] | 231 | const std::string &m_stdin_path; // Redirect stdin if not empty. |
| 232 | const std::string &m_stdout_path; // Redirect stdout if not empty. |
| 233 | const std::string &m_stderr_path; // Redirect stderr if not empty. |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 234 | const char *m_working_dir; // Working directory or NULL. |
| 235 | const ProcessLaunchInfo &m_launch_info; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 236 | }; |
| 237 | |
| 238 | struct AttachArgs : OperationArgs |
| 239 | { |
| 240 | AttachArgs(NativeProcessLinux *monitor, |
| 241 | lldb::pid_t pid); |
| 242 | |
| 243 | ~AttachArgs(); |
| 244 | |
| 245 | lldb::pid_t m_pid; // pid of the process to be attached. |
| 246 | }; |
| 247 | |
| 248 | // --------------------------------------------------------------------- |
| 249 | // Private Instance Methods |
| 250 | // --------------------------------------------------------------------- |
| 251 | NativeProcessLinux (); |
| 252 | |
| 253 | /// Launches an inferior process ready for debugging. Forms the |
| 254 | /// implementation of Process::DoLaunch. |
| 255 | void |
| 256 | LaunchInferior ( |
| 257 | Module *module, |
| 258 | char const *argv[], |
| 259 | char const *envp[], |
Todd Fiala | 75f47c3 | 2014-10-11 21:42:09 +0000 | [diff] [blame] | 260 | const std::string &stdin_path, |
| 261 | const std::string &stdout_path, |
| 262 | const std::string &stderr_path, |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 263 | const char *working_dir, |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 264 | const ProcessLaunchInfo &launch_info, |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 265 | Error &error); |
| 266 | |
| 267 | /// Attaches to an existing process. Forms the |
Tamas Berghammer | 0cbf0b1 | 2015-03-13 11:16:03 +0000 | [diff] [blame] | 268 | /// implementation of Process::DoAttach |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 269 | void |
| 270 | AttachToInferior (lldb::pid_t pid, Error &error); |
| 271 | |
| 272 | void |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 273 | StartLaunchOpThread(LaunchArgs *args, Error &error); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 274 | |
| 275 | static void * |
| 276 | LaunchOpThread(void *arg); |
| 277 | |
| 278 | static bool |
| 279 | Launch(LaunchArgs *args); |
| 280 | |
| 281 | void |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 282 | StartAttachOpThread(AttachArgs *args, Error &error); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 283 | |
| 284 | static void * |
| 285 | AttachOpThread(void *args); |
| 286 | |
| 287 | static bool |
| 288 | Attach(AttachArgs *args); |
| 289 | |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 290 | static Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 291 | SetDefaultPtraceOpts(const lldb::pid_t); |
| 292 | |
| 293 | static void |
| 294 | ServeOperation(OperationArgs *args); |
| 295 | |
| 296 | static bool |
| 297 | DupDescriptor(const char *path, int fd, int flags); |
| 298 | |
| 299 | static bool |
| 300 | MonitorCallback(void *callback_baton, |
| 301 | lldb::pid_t pid, bool exited, int signal, int status); |
| 302 | |
| 303 | void |
| 304 | MonitorSIGTRAP(const siginfo_t *info, lldb::pid_t pid); |
| 305 | |
| 306 | void |
Chaoren Lin | c16f5dc | 2015-03-19 23:28:10 +0000 | [diff] [blame] | 307 | MonitorTrace(lldb::pid_t pid, NativeThreadProtocolSP thread_sp); |
| 308 | |
| 309 | void |
| 310 | MonitorBreakpoint(lldb::pid_t pid, NativeThreadProtocolSP thread_sp); |
| 311 | |
| 312 | void |
| 313 | MonitorWatchpoint(lldb::pid_t pid, NativeThreadProtocolSP thread_sp, uint32_t wp_index); |
| 314 | |
| 315 | void |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 316 | MonitorSignal(const siginfo_t *info, lldb::pid_t pid, bool exited); |
| 317 | |
| 318 | #if 0 |
| 319 | static ::ProcessMessage::CrashReason |
| 320 | GetCrashReasonForSIGSEGV(const siginfo_t *info); |
| 321 | |
| 322 | static ::ProcessMessage::CrashReason |
| 323 | GetCrashReasonForSIGILL(const siginfo_t *info); |
| 324 | |
| 325 | static ::ProcessMessage::CrashReason |
| 326 | GetCrashReasonForSIGFPE(const siginfo_t *info); |
| 327 | |
| 328 | static ::ProcessMessage::CrashReason |
| 329 | GetCrashReasonForSIGBUS(const siginfo_t *info); |
| 330 | #endif |
| 331 | |
| 332 | void |
| 333 | DoOperation(void *op); |
| 334 | |
| 335 | /// Stops the child monitor thread. |
| 336 | void |
Tamas Berghammer | 0cbf0b1 | 2015-03-13 11:16:03 +0000 | [diff] [blame] | 337 | StopMonitorThread(); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 338 | |
| 339 | /// Stops the operation thread used to attach/launch a process. |
| 340 | void |
| 341 | StopOpThread(); |
| 342 | |
Chaoren Lin | fa03ad2 | 2015-02-03 01:50:42 +0000 | [diff] [blame] | 343 | Error |
| 344 | StartCoordinatorThread (); |
| 345 | |
| 346 | static void* |
| 347 | CoordinatorThread (void *arg); |
| 348 | |
| 349 | void |
| 350 | StopCoordinatorThread (); |
| 351 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 352 | /// Stops monitoring the child process thread. |
| 353 | void |
| 354 | StopMonitor(); |
| 355 | |
| 356 | bool |
| 357 | HasThreadNoLock (lldb::tid_t thread_id); |
| 358 | |
| 359 | NativeThreadProtocolSP |
| 360 | MaybeGetThreadNoLock (lldb::tid_t thread_id); |
| 361 | |
| 362 | bool |
| 363 | StopTrackingThread (lldb::tid_t thread_id); |
| 364 | |
| 365 | NativeThreadProtocolSP |
| 366 | AddThread (lldb::tid_t thread_id); |
| 367 | |
| 368 | NativeThreadProtocolSP |
| 369 | GetOrCreateThread (lldb::tid_t thread_id, bool &created); |
| 370 | |
| 371 | Error |
Tamas Berghammer | 63c8be9 | 2015-04-15 09:38:48 +0000 | [diff] [blame] | 372 | GetSoftwareBreakpointPCOffset (NativeRegisterContextSP context_sp, uint32_t &actual_opcode_size); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 373 | |
| 374 | Error |
| 375 | FixupBreakpointPCAsNeeded (NativeThreadProtocolSP &thread_sp); |
| 376 | |
| 377 | /// Writes a siginfo_t structure corresponding to the given thread ID to the |
| 378 | /// memory region pointed to by @p siginfo. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 379 | Error |
| 380 | GetSignalInfo(lldb::tid_t tid, void *siginfo); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 381 | |
| 382 | /// Writes the raw event message code (vis-a-vis PTRACE_GETEVENTMSG) |
| 383 | /// corresponding to the given thread ID to the memory pointed to by @p |
| 384 | /// message. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 385 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 386 | GetEventMessage(lldb::tid_t tid, unsigned long *message); |
| 387 | |
| 388 | /// Resumes the given thread. If @p signo is anything but |
| 389 | /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 390 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 391 | Resume(lldb::tid_t tid, uint32_t signo); |
| 392 | |
| 393 | /// Single steps the given thread. If @p signo is anything but |
| 394 | /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread. |
Chaoren Lin | 97ccc29 | 2015-02-03 01:51:12 +0000 | [diff] [blame] | 395 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 396 | SingleStep(lldb::tid_t tid, uint32_t signo); |
| 397 | |
Chaoren Lin | fa03ad2 | 2015-02-03 01:50:42 +0000 | [diff] [blame] | 398 | // ThreadStateCoordinator helper methods. |
Todd Fiala | 511e5cd | 2014-09-11 23:29:14 +0000 | [diff] [blame] | 399 | void |
Chaoren Lin | fa03ad2 | 2015-02-03 01:50:42 +0000 | [diff] [blame] | 400 | NotifyThreadCreateStopped (lldb::tid_t tid); |
Todd Fiala | 511e5cd | 2014-09-11 23:29:14 +0000 | [diff] [blame] | 401 | |
| 402 | void |
Chaoren Lin | fa03ad2 | 2015-02-03 01:50:42 +0000 | [diff] [blame] | 403 | NotifyThreadCreateRunning (lldb::tid_t tid); |
| 404 | |
| 405 | void |
| 406 | NotifyThreadDeath (lldb::tid_t tid); |
| 407 | |
| 408 | void |
| 409 | NotifyThreadStop (lldb::tid_t tid); |
| 410 | |
| 411 | void |
| 412 | CallAfterRunningThreadsStop (lldb::tid_t tid, |
| 413 | const std::function<void (lldb::tid_t tid)> &call_after_function); |
Todd Fiala | 511e5cd | 2014-09-11 23:29:14 +0000 | [diff] [blame] | 414 | |
Chaoren Lin | 03f12d6 | 2015-02-03 01:50:49 +0000 | [diff] [blame] | 415 | void |
| 416 | CallAfterRunningThreadsStopWithSkipTID (lldb::tid_t deferred_signal_tid, |
| 417 | lldb::tid_t skip_stop_request_tid, |
| 418 | const std::function<void (lldb::tid_t tid)> &call_after_function); |
| 419 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 420 | Error |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 421 | Detach(lldb::tid_t tid); |
Chaoren Lin | 86fd8e4 | 2015-02-03 01:51:15 +0000 | [diff] [blame] | 422 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 423 | Error |
Chaoren Lin | 86fd8e4 | 2015-02-03 01:51:15 +0000 | [diff] [blame] | 424 | RequestThreadStop (const lldb::pid_t pid, const lldb::tid_t tid); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 425 | }; |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 426 | |
| 427 | } // namespace process_linux |
| 428 | } // namespace lldb_private |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 429 | |
| 430 | #endif // #ifndef liblldb_NativeProcessLinux_H_ |