1af245d11STodd Fiala //===-- NativeProcessLinux.h ---------------------------------- -*- C++ -*-===// 2af245d11STodd Fiala // 3af245d11STodd Fiala // The LLVM Compiler Infrastructure 4af245d11STodd Fiala // 5af245d11STodd Fiala // This file is distributed under the University of Illinois Open Source 6af245d11STodd Fiala // License. See LICENSE.TXT for details. 7af245d11STodd Fiala // 8af245d11STodd Fiala //===----------------------------------------------------------------------===// 9af245d11STodd Fiala 10af245d11STodd Fiala #ifndef liblldb_NativeProcessLinux_H_ 11af245d11STodd Fiala #define liblldb_NativeProcessLinux_H_ 12af245d11STodd Fiala 13af245d11STodd Fiala // C Includes 14af245d11STodd Fiala #include <semaphore.h> 15af245d11STodd Fiala #include <signal.h> 16af245d11STodd Fiala 17af245d11STodd Fiala // C++ Includes 18c076559aSPavel Labath #include <mutex> 19c076559aSPavel Labath #include <unordered_map> 20af245d11STodd Fiala #include <unordered_set> 21af245d11STodd Fiala 22af245d11STodd Fiala // Other libraries and framework includes 23af245d11STodd Fiala #include "lldb/Core/ArchSpec.h" 24af245d11STodd Fiala #include "lldb/lldb-types.h" 25af245d11STodd Fiala #include "lldb/Host/Debug.h" 2639de3110SZachary Turner #include "lldb/Host/HostThread.h" 27af245d11STodd Fiala #include "lldb/Host/Mutex.h" 28af245d11STodd Fiala #include "lldb/Target/MemoryRegionInfo.h" 29af245d11STodd Fiala 302fe1d0abSChaoren Lin #include "lldb/Host/common/NativeProcessProtocol.h" 31*8c8ff7afSPavel Labath #include "NativeThreadLinux.h" 32af245d11STodd Fiala 33db264a6dSTamas Berghammer namespace lldb_private { 34af245d11STodd Fiala class Error; 35af245d11STodd Fiala class Module; 36af245d11STodd Fiala class Scalar; 37af245d11STodd Fiala 38db264a6dSTamas Berghammer namespace process_linux { 39af245d11STodd Fiala /// @class NativeProcessLinux 40af245d11STodd Fiala /// @brief Manages communication with the inferior (debugee) process. 41af245d11STodd Fiala /// 42af245d11STodd Fiala /// Upon construction, this class prepares and launches an inferior process for 43af245d11STodd Fiala /// debugging. 44af245d11STodd Fiala /// 45af245d11STodd Fiala /// Changes in the inferior process state are broadcasted. 46af245d11STodd Fiala class NativeProcessLinux: public NativeProcessProtocol 47af245d11STodd Fiala { 48af245d11STodd Fiala public: 49af245d11STodd Fiala 50db264a6dSTamas Berghammer static Error 51af245d11STodd Fiala LaunchProcess ( 52af245d11STodd Fiala Module *exe_module, 53af245d11STodd Fiala ProcessLaunchInfo &launch_info, 54db264a6dSTamas Berghammer NativeProcessProtocol::NativeDelegate &native_delegate, 55af245d11STodd Fiala NativeProcessProtocolSP &native_process_sp); 56af245d11STodd Fiala 57db264a6dSTamas Berghammer static Error 58af245d11STodd Fiala AttachToProcess ( 59af245d11STodd Fiala lldb::pid_t pid, 60db264a6dSTamas Berghammer NativeProcessProtocol::NativeDelegate &native_delegate, 61af245d11STodd Fiala NativeProcessProtocolSP &native_process_sp); 62af245d11STodd Fiala 63af245d11STodd Fiala // --------------------------------------------------------------------- 64af245d11STodd Fiala // NativeProcessProtocol Interface 65af245d11STodd Fiala // --------------------------------------------------------------------- 66af245d11STodd Fiala Error 67af245d11STodd Fiala Resume (const ResumeActionList &resume_actions) override; 68af245d11STodd Fiala 69af245d11STodd Fiala Error 70af245d11STodd Fiala Halt () override; 71af245d11STodd Fiala 72af245d11STodd Fiala Error 73af245d11STodd Fiala Detach () override; 74af245d11STodd Fiala 75af245d11STodd Fiala Error 76af245d11STodd Fiala Signal (int signo) override; 77af245d11STodd Fiala 78af245d11STodd Fiala Error 79e9547b80SChaoren Lin Interrupt () override; 80e9547b80SChaoren Lin 81e9547b80SChaoren Lin Error 82af245d11STodd Fiala Kill () override; 83af245d11STodd Fiala 84af245d11STodd Fiala Error 85af245d11STodd Fiala GetMemoryRegionInfo (lldb::addr_t load_addr, MemoryRegionInfo &range_info) override; 86af245d11STodd Fiala 87af245d11STodd Fiala Error 883eb4b458SChaoren Lin ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override; 89af245d11STodd Fiala 90af245d11STodd Fiala Error 913eb4b458SChaoren Lin ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override; 92af245d11STodd Fiala 93af245d11STodd Fiala Error 943eb4b458SChaoren Lin WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) override; 953eb4b458SChaoren Lin 963eb4b458SChaoren Lin Error 973eb4b458SChaoren Lin AllocateMemory(size_t size, uint32_t permissions, lldb::addr_t &addr) override; 98af245d11STodd Fiala 99af245d11STodd Fiala Error 100af245d11STodd Fiala DeallocateMemory (lldb::addr_t addr) override; 101af245d11STodd Fiala 102af245d11STodd Fiala lldb::addr_t 103af245d11STodd Fiala GetSharedLibraryInfoAddress () override; 104af245d11STodd Fiala 105af245d11STodd Fiala size_t 106af245d11STodd Fiala UpdateThreads () override; 107af245d11STodd Fiala 108af245d11STodd Fiala bool 109af245d11STodd Fiala GetArchitecture (ArchSpec &arch) const override; 110af245d11STodd Fiala 111af245d11STodd Fiala Error 112af245d11STodd Fiala SetBreakpoint (lldb::addr_t addr, uint32_t size, bool hardware) override; 113af245d11STodd Fiala 11445f5cb31SPavel Labath Error 11545f5cb31SPavel Labath SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override; 11645f5cb31SPavel Labath 11745f5cb31SPavel Labath Error 11845f5cb31SPavel Labath RemoveWatchpoint (lldb::addr_t addr) override; 11945f5cb31SPavel Labath 120af245d11STodd Fiala void 121af245d11STodd Fiala DoStopIDBumped (uint32_t newBumpId) override; 122af245d11STodd Fiala 1238bc34f4dSOleksiy Vyalov void 1248bc34f4dSOleksiy Vyalov Terminate () override; 1258bc34f4dSOleksiy Vyalov 126af245d11STodd Fiala // --------------------------------------------------------------------- 127af245d11STodd Fiala // Interface used by NativeRegisterContext-derived classes. 128af245d11STodd Fiala // --------------------------------------------------------------------- 129af245d11STodd Fiala 130af245d11STodd Fiala /// Reads the contents from the register identified by the given (architecture 131af245d11STodd Fiala /// dependent) offset. 132af245d11STodd Fiala /// 133af245d11STodd Fiala /// This method is provided for use by RegisterContextLinux derivatives. 13497ccc294SChaoren Lin Error 135af245d11STodd Fiala ReadRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name, 136db264a6dSTamas Berghammer unsigned size, RegisterValue &value); 137af245d11STodd Fiala 138af245d11STodd Fiala /// Writes the given value to the register identified by the given 139af245d11STodd Fiala /// (architecture dependent) offset. 140af245d11STodd Fiala /// 141af245d11STodd Fiala /// This method is provided for use by RegisterContextLinux derivatives. 14297ccc294SChaoren Lin Error 143af245d11STodd Fiala WriteRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name, 144db264a6dSTamas Berghammer const RegisterValue &value); 145af245d11STodd Fiala 146af245d11STodd Fiala /// Reads all general purpose registers into the specified buffer. 14797ccc294SChaoren Lin Error 148af245d11STodd Fiala ReadGPR(lldb::tid_t tid, void *buf, size_t buf_size); 149af245d11STodd Fiala 150af245d11STodd Fiala /// Reads generic floating point registers into the specified buffer. 15197ccc294SChaoren Lin Error 152af245d11STodd Fiala ReadFPR(lldb::tid_t tid, void *buf, size_t buf_size); 153af245d11STodd Fiala 154af245d11STodd Fiala /// Reads the specified register set into the specified buffer. 155af245d11STodd Fiala /// For instance, the extended floating-point register set. 15697ccc294SChaoren Lin Error 157af245d11STodd Fiala ReadRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset); 158af245d11STodd Fiala 159af245d11STodd Fiala /// Writes all general purpose registers into the specified buffer. 16097ccc294SChaoren Lin Error 161af245d11STodd Fiala WriteGPR(lldb::tid_t tid, void *buf, size_t buf_size); 162af245d11STodd Fiala 163af245d11STodd Fiala /// Writes generic floating point registers into the specified buffer. 16497ccc294SChaoren Lin Error 165af245d11STodd Fiala WriteFPR(lldb::tid_t tid, void *buf, size_t buf_size); 166af245d11STodd Fiala 167af245d11STodd Fiala /// Writes the specified register set into the specified buffer. 168af245d11STodd Fiala /// For instance, the extended floating-point register set. 16997ccc294SChaoren Lin Error 170af245d11STodd Fiala WriteRegisterSet(lldb::tid_t tid, void *buf, size_t buf_size, unsigned int regset); 171af245d11STodd Fiala 1727cb18bf5STamas Berghammer Error 1737cb18bf5STamas Berghammer GetLoadedModuleFileSpec(const char* module_path, FileSpec& file_spec) override; 1747cb18bf5STamas Berghammer 175af245d11STodd Fiala protected: 176af245d11STodd Fiala // --------------------------------------------------------------------- 177af245d11STodd Fiala // NativeProcessProtocol protected interface 178af245d11STodd Fiala // --------------------------------------------------------------------- 179af245d11STodd Fiala Error 180af245d11STodd Fiala GetSoftwareBreakpointTrapOpcode (size_t trap_opcode_size_hint, size_t &actual_opcode_size, const uint8_t *&trap_opcode_bytes) override; 181af245d11STodd Fiala 182af245d11STodd Fiala private: 183af245d11STodd Fiala 1841107b5a5SPavel Labath class Monitor; 1851107b5a5SPavel Labath 186db264a6dSTamas Berghammer ArchSpec m_arch; 187af245d11STodd Fiala 1881107b5a5SPavel Labath std::unique_ptr<Monitor> m_monitor_up; 189af245d11STodd Fiala 190db264a6dSTamas Berghammer LazyBool m_supports_mem_region; 191af245d11STodd Fiala std::vector<MemoryRegionInfo> m_mem_region_cache; 192db264a6dSTamas Berghammer Mutex m_mem_region_cache_mutex; 193af245d11STodd Fiala 194d8c338d4STamas Berghammer // List of thread ids stepping with a breakpoint with the address of 195d8c338d4STamas Berghammer // the relevan breakpoint 196d8c338d4STamas Berghammer std::map<lldb::tid_t, lldb::addr_t> m_threads_stepping_with_breakpoint; 197d8c338d4STamas Berghammer 198af245d11STodd Fiala /// @class LauchArgs 199af245d11STodd Fiala /// 200af245d11STodd Fiala /// @brief Simple structure to pass data to the thread responsible for 201af245d11STodd Fiala /// launching a child process. 202bd7cbc5aSPavel Labath struct LaunchArgs 203af245d11STodd Fiala { 204bd7cbc5aSPavel Labath LaunchArgs(Module *module, 205af245d11STodd Fiala char const **argv, 206af245d11STodd Fiala char const **envp, 20775f47c3aSTodd Fiala const std::string &stdin_path, 20875f47c3aSTodd Fiala const std::string &stdout_path, 20975f47c3aSTodd Fiala const std::string &stderr_path, 2100bce1b67STodd Fiala const char *working_dir, 211db264a6dSTamas Berghammer const ProcessLaunchInfo &launch_info); 212af245d11STodd Fiala 213af245d11STodd Fiala ~LaunchArgs(); 214af245d11STodd Fiala 215db264a6dSTamas Berghammer Module *m_module; // The executable image to launch. 216af245d11STodd Fiala char const **m_argv; // Process arguments. 217af245d11STodd Fiala char const **m_envp; // Process environment. 21875f47c3aSTodd Fiala const std::string &m_stdin_path; // Redirect stdin if not empty. 21975f47c3aSTodd Fiala const std::string &m_stdout_path; // Redirect stdout if not empty. 22075f47c3aSTodd Fiala const std::string &m_stderr_path; // Redirect stderr if not empty. 221af245d11STodd Fiala const char *m_working_dir; // Working directory or NULL. 222db264a6dSTamas Berghammer const ProcessLaunchInfo &m_launch_info; 223af245d11STodd Fiala }; 224af245d11STodd Fiala 225bd7cbc5aSPavel Labath typedef std::function<::pid_t(Error &)> InitialOperation; 226af245d11STodd Fiala 227af245d11STodd Fiala // --------------------------------------------------------------------- 228af245d11STodd Fiala // Private Instance Methods 229af245d11STodd Fiala // --------------------------------------------------------------------- 230af245d11STodd Fiala NativeProcessLinux (); 231af245d11STodd Fiala 232af245d11STodd Fiala /// Launches an inferior process ready for debugging. Forms the 233af245d11STodd Fiala /// implementation of Process::DoLaunch. 234af245d11STodd Fiala void 235af245d11STodd Fiala LaunchInferior ( 236af245d11STodd Fiala Module *module, 237af245d11STodd Fiala char const *argv[], 238af245d11STodd Fiala char const *envp[], 23975f47c3aSTodd Fiala const std::string &stdin_path, 24075f47c3aSTodd Fiala const std::string &stdout_path, 24175f47c3aSTodd Fiala const std::string &stderr_path, 242af245d11STodd Fiala const char *working_dir, 243db264a6dSTamas Berghammer const ProcessLaunchInfo &launch_info, 244af245d11STodd Fiala Error &error); 245af245d11STodd Fiala 246af245d11STodd Fiala /// Attaches to an existing process. Forms the 2470cbf0b13STamas Berghammer /// implementation of Process::DoAttach 248af245d11STodd Fiala void 249af245d11STodd Fiala AttachToInferior (lldb::pid_t pid, Error &error); 250af245d11STodd Fiala 251af245d11STodd Fiala void 252bd7cbc5aSPavel Labath StartMonitorThread(const InitialOperation &operation, Error &error); 2531107b5a5SPavel Labath 254bd7cbc5aSPavel Labath ::pid_t 255bd7cbc5aSPavel Labath Launch(LaunchArgs *args, Error &error); 256af245d11STodd Fiala 257bd7cbc5aSPavel Labath ::pid_t 258bd7cbc5aSPavel Labath Attach(lldb::pid_t pid, Error &error); 259af245d11STodd Fiala 26097ccc294SChaoren Lin static Error 261af245d11STodd Fiala SetDefaultPtraceOpts(const lldb::pid_t); 262af245d11STodd Fiala 263af245d11STodd Fiala static bool 264af245d11STodd Fiala DupDescriptor(const char *path, int fd, int flags); 265af245d11STodd Fiala 2661107b5a5SPavel Labath static void * 2671107b5a5SPavel Labath MonitorThread(void *baton); 2681107b5a5SPavel Labath 2691107b5a5SPavel Labath void 2701107b5a5SPavel Labath MonitorCallback(lldb::pid_t pid, bool exited, int signal, int status); 271af245d11STodd Fiala 272af245d11STodd Fiala void 273426bdf88SPavel Labath WaitForNewThread(::pid_t tid); 274426bdf88SPavel Labath 275426bdf88SPavel Labath void 276af245d11STodd Fiala MonitorSIGTRAP(const siginfo_t *info, lldb::pid_t pid); 277af245d11STodd Fiala 278af245d11STodd Fiala void 279c16f5dcaSChaoren Lin MonitorTrace(lldb::pid_t pid, NativeThreadProtocolSP thread_sp); 280c16f5dcaSChaoren Lin 281c16f5dcaSChaoren Lin void 282c16f5dcaSChaoren Lin MonitorBreakpoint(lldb::pid_t pid, NativeThreadProtocolSP thread_sp); 283c16f5dcaSChaoren Lin 284c16f5dcaSChaoren Lin void 285c16f5dcaSChaoren Lin MonitorWatchpoint(lldb::pid_t pid, NativeThreadProtocolSP thread_sp, uint32_t wp_index); 286c16f5dcaSChaoren Lin 287c16f5dcaSChaoren Lin void 288af245d11STodd Fiala MonitorSignal(const siginfo_t *info, lldb::pid_t pid, bool exited); 289af245d11STodd Fiala 290e7708688STamas Berghammer bool 291e7708688STamas Berghammer SupportHardwareSingleStepping() const; 292e7708688STamas Berghammer 293e7708688STamas Berghammer Error 294e7708688STamas Berghammer SetupSoftwareSingleStepping(NativeThreadProtocolSP thread_sp); 295e7708688STamas Berghammer 296af245d11STodd Fiala #if 0 297af245d11STodd Fiala static ::ProcessMessage::CrashReason 298af245d11STodd Fiala GetCrashReasonForSIGSEGV(const siginfo_t *info); 299af245d11STodd Fiala 300af245d11STodd Fiala static ::ProcessMessage::CrashReason 301af245d11STodd Fiala GetCrashReasonForSIGILL(const siginfo_t *info); 302af245d11STodd Fiala 303af245d11STodd Fiala static ::ProcessMessage::CrashReason 304af245d11STodd Fiala GetCrashReasonForSIGFPE(const siginfo_t *info); 305af245d11STodd Fiala 306af245d11STodd Fiala static ::ProcessMessage::CrashReason 307af245d11STodd Fiala GetCrashReasonForSIGBUS(const siginfo_t *info); 308af245d11STodd Fiala #endif 309af245d11STodd Fiala 310af245d11STodd Fiala bool 311af245d11STodd Fiala HasThreadNoLock (lldb::tid_t thread_id); 312af245d11STodd Fiala 313af245d11STodd Fiala NativeThreadProtocolSP 314af245d11STodd Fiala MaybeGetThreadNoLock (lldb::tid_t thread_id); 315af245d11STodd Fiala 316af245d11STodd Fiala bool 317af245d11STodd Fiala StopTrackingThread (lldb::tid_t thread_id); 318af245d11STodd Fiala 319af245d11STodd Fiala NativeThreadProtocolSP 320af245d11STodd Fiala AddThread (lldb::tid_t thread_id); 321af245d11STodd Fiala 322af245d11STodd Fiala Error 32363c8be95STamas Berghammer GetSoftwareBreakpointPCOffset (NativeRegisterContextSP context_sp, uint32_t &actual_opcode_size); 324af245d11STodd Fiala 325af245d11STodd Fiala Error 326af245d11STodd Fiala FixupBreakpointPCAsNeeded (NativeThreadProtocolSP &thread_sp); 327af245d11STodd Fiala 328af245d11STodd Fiala /// Writes a siginfo_t structure corresponding to the given thread ID to the 329af245d11STodd Fiala /// memory region pointed to by @p siginfo. 33097ccc294SChaoren Lin Error 33197ccc294SChaoren Lin GetSignalInfo(lldb::tid_t tid, void *siginfo); 332af245d11STodd Fiala 333af245d11STodd Fiala /// Writes the raw event message code (vis-a-vis PTRACE_GETEVENTMSG) 334af245d11STodd Fiala /// corresponding to the given thread ID to the memory pointed to by @p 335af245d11STodd Fiala /// message. 33697ccc294SChaoren Lin Error 337af245d11STodd Fiala GetEventMessage(lldb::tid_t tid, unsigned long *message); 338af245d11STodd Fiala 339af245d11STodd Fiala /// Resumes the given thread. If @p signo is anything but 340af245d11STodd Fiala /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread. 34197ccc294SChaoren Lin Error 342af245d11STodd Fiala Resume(lldb::tid_t tid, uint32_t signo); 343af245d11STodd Fiala 344af245d11STodd Fiala /// Single steps the given thread. If @p signo is anything but 345af245d11STodd Fiala /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread. 34697ccc294SChaoren Lin Error 347af245d11STodd Fiala SingleStep(lldb::tid_t tid, uint32_t signo); 348af245d11STodd Fiala 349511e5cdcSTodd Fiala void 350fa03ad2eSChaoren Lin NotifyThreadDeath (lldb::tid_t tid); 351fa03ad2eSChaoren Lin 352db264a6dSTamas Berghammer Error 353af245d11STodd Fiala Detach(lldb::tid_t tid); 35486fd8e45SChaoren Lin 355c076559aSPavel Labath 356c076559aSPavel Labath // Typedefs. 357c076559aSPavel Labath typedef std::unordered_set<lldb::tid_t> ThreadIDSet; 358c076559aSPavel Labath 359*8c8ff7afSPavel Labath // Notify that a thread is created and/or starting to be tracked. 360c076559aSPavel Labath void 361*8c8ff7afSPavel Labath NotifyThreadCreate(lldb::tid_t tid); 362c076559aSPavel Labath 363c076559aSPavel Labath 364ed89c7feSPavel Labath // Notify the delegate after a given set of threads stops. The triggering_tid will be set 365ed89c7feSPavel Labath // as the current thread. The error_function will be fired if either the triggering tid 366ed89c7feSPavel Labath // or any of the wait_for_stop_tids are unknown. 367c076559aSPavel Labath void 368337f3eb9SPavel Labath StopThreads(lldb::tid_t triggering_tid, const ThreadIDSet &wait_for_stop_tids); 369c076559aSPavel Labath 370ed89c7feSPavel Labath // Notify the delegate after all non-stopped threads stop. The triggering_tid will be set 371ed89c7feSPavel Labath // as the current thread. The error_function will be fired if the triggering tid 372ed89c7feSPavel Labath // is unknown. 373c076559aSPavel Labath void 374337f3eb9SPavel Labath StopRunningThreads(lldb::tid_t triggering_tid); 375c076559aSPavel Labath 376ed89c7feSPavel Labath // Notify the delegate after all non-stopped threads stop. The triggering_tid will be set 377ed89c7feSPavel Labath // as the current thread. The error_function will be fired if either the triggering tid 378ed89c7feSPavel Labath // or any of the wait_for_stop_tids are unknown. This variant will send stop requests to 379337f3eb9SPavel Labath // all non-stopped threads except skip_stop_request_tid. 380c076559aSPavel Labath void 381337f3eb9SPavel Labath StopRunningThreadsWithSkipTID(lldb::tid_t triggering_tid, lldb::tid_t skip_stop_request_tid); 382c076559aSPavel Labath 383c076559aSPavel Labath // Notify the thread stopped. Will trigger error at time of execution if we 384c076559aSPavel Labath // already think it is stopped. 3855eb721edSPavel Labath Error 3865eb721edSPavel Labath NotifyThreadStop(lldb::tid_t tid, bool initiated_by_llgs); 387c076559aSPavel Labath 388c076559aSPavel Labath // Request that the given thread id should have the request_thread_resume_function 3895eb721edSPavel Labath // called. This call signals an error if the thread resume is for 390c076559aSPavel Labath // a thread that is already in a running state. 3915eb721edSPavel Labath Error 392c076559aSPavel Labath RequestThreadResume (lldb::tid_t tid, 393*8c8ff7afSPavel Labath const NativeThreadLinux::ResumeThreadFunction &request_thread_resume_function); 394c076559aSPavel Labath 395c076559aSPavel Labath // Request that the given thread id should have the request_thread_resume_function 3965eb721edSPavel Labath // called. This call ignores threads that are already running and 397c076559aSPavel Labath // does not trigger an error in that case. 3985eb721edSPavel Labath Error 399c076559aSPavel Labath RequestThreadResumeAsNeeded (lldb::tid_t tid, 400*8c8ff7afSPavel Labath const NativeThreadLinux::ResumeThreadFunction &request_thread_resume_function); 401c076559aSPavel Labath 402c076559aSPavel Labath // Indicate the calling process did an exec and that the thread state 403c076559aSPavel Labath // should be 100% cleared. 404c076559aSPavel Labath void 405c076559aSPavel Labath ResetForExec (); 406c076559aSPavel Labath 407c076559aSPavel Labath private: 408c076559aSPavel Labath struct PendingNotification 409c076559aSPavel Labath { 410c076559aSPavel Labath PendingNotification (lldb::tid_t triggering_tid, 411c076559aSPavel Labath const ThreadIDSet &wait_for_stop_tids, 412337f3eb9SPavel Labath const ThreadIDSet &skip_stop_request_tids): 413c076559aSPavel Labath triggering_tid (triggering_tid), 414c076559aSPavel Labath wait_for_stop_tids (wait_for_stop_tids), 415c076559aSPavel Labath original_wait_for_stop_tids (wait_for_stop_tids), 416c076559aSPavel Labath request_stop_on_all_unstopped_threads (false), 417c076559aSPavel Labath skip_stop_request_tids (skip_stop_request_tids) 418c076559aSPavel Labath { 419c076559aSPavel Labath } 420c076559aSPavel Labath 421337f3eb9SPavel Labath PendingNotification (lldb::tid_t triggering_tid): 422337f3eb9SPavel Labath triggering_tid (triggering_tid), 423337f3eb9SPavel Labath wait_for_stop_tids (), 424337f3eb9SPavel Labath original_wait_for_stop_tids (), 425337f3eb9SPavel Labath request_stop_on_all_unstopped_threads (true), 426337f3eb9SPavel Labath skip_stop_request_tids () 427337f3eb9SPavel Labath { 428337f3eb9SPavel Labath } 429337f3eb9SPavel Labath 430c076559aSPavel Labath const lldb::tid_t triggering_tid; 431c076559aSPavel Labath ThreadIDSet wait_for_stop_tids; 432c076559aSPavel Labath const ThreadIDSet original_wait_for_stop_tids; 433c076559aSPavel Labath const bool request_stop_on_all_unstopped_threads; 434c076559aSPavel Labath ThreadIDSet skip_stop_request_tids; 435c076559aSPavel Labath }; 436c076559aSPavel Labath typedef std::unique_ptr<PendingNotification> PendingNotificationUP; 437c076559aSPavel Labath 438c076559aSPavel Labath // Fire pending notification if no pending thread stops remain. 439c076559aSPavel Labath void SignalIfRequirementsSatisfied(); 440c076559aSPavel Labath 441c076559aSPavel Labath bool 442c076559aSPavel Labath RequestStopOnAllSpecifiedThreads(); 443c076559aSPavel Labath 444c076559aSPavel Labath void 445c076559aSPavel Labath RequestStopOnAllRunningThreads(); 446c076559aSPavel Labath 447c076559aSPavel Labath std::mutex m_event_mutex; // Serializes execution of ProcessEvent. XXX 448c076559aSPavel Labath 4495eb721edSPavel Labath Error 4505eb721edSPavel Labath ThreadDidStop(lldb::tid_t tid, bool initiated_by_llgs); 451c076559aSPavel Labath 4525eb721edSPavel Labath Error 453*8c8ff7afSPavel Labath DoResume(lldb::tid_t tid, NativeThreadLinux::ResumeThreadFunction request_thread_resume_function, 4545eb721edSPavel Labath bool error_when_already_running); 455c076559aSPavel Labath 456c076559aSPavel Labath void 457ed89c7feSPavel Labath DoStopThreads(PendingNotificationUP &¬ification_up); 458c076559aSPavel Labath 459c076559aSPavel Labath void 460*8c8ff7afSPavel Labath ThreadWasCreated (lldb::tid_t tid); 461c076559aSPavel Labath 462c076559aSPavel Labath void 4635eb721edSPavel Labath ThreadDidDie (lldb::tid_t tid); 464c076559aSPavel Labath 465c076559aSPavel Labath // Member variables. 466c076559aSPavel Labath PendingNotificationUP m_pending_notification_up; 467af245d11STodd Fiala }; 468db264a6dSTamas Berghammer 469db264a6dSTamas Berghammer } // namespace process_linux 470db264a6dSTamas Berghammer } // namespace lldb_private 471af245d11STodd Fiala 472af245d11STodd Fiala #endif // #ifndef liblldb_NativeProcessLinux_H_ 473