Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 1 | //===-- DebuggerThread.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_Plugins_Process_Windows_DebuggerThread_H_ |
| 11 | #define liblldb_Plugins_Process_Windows_DebuggerThread_H_ |
| 12 | |
| 13 | #include "ForwardDecl.h" |
| 14 | #include "lldb/Host/HostProcess.h" |
| 15 | #include "lldb/Host/HostThread.h" |
Zachary Turner | dcd8037 | 2014-11-11 00:00:14 +0000 | [diff] [blame^] | 16 | #include "lldb/Host/Predicate.h" |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 17 | #include "lldb/Host/windows/windows.h" |
| 18 | |
| 19 | #include <memory> |
| 20 | |
| 21 | namespace lldb_private |
| 22 | { |
| 23 | |
| 24 | //---------------------------------------------------------------------- |
| 25 | // DebuggerThread |
| 26 | // |
| 27 | // Debugs a single process, notifying listeners as appropriate when interesting |
| 28 | // things occur. |
| 29 | //---------------------------------------------------------------------- |
| 30 | class DebuggerThread : public std::enable_shared_from_this<DebuggerThread> |
| 31 | { |
| 32 | public: |
| 33 | DebuggerThread(DebugDelegateSP debug_delegate); |
| 34 | virtual ~DebuggerThread(); |
| 35 | |
Zachary Turner | 3985f89 | 2014-11-10 22:32:18 +0000 | [diff] [blame] | 36 | Error DebugLaunch(const ProcessLaunchInfo &launch_info); |
| 37 | |
| 38 | HostProcess |
| 39 | GetProcess() const |
| 40 | { |
| 41 | return m_process; |
| 42 | } |
| 43 | HostThread |
| 44 | GetMainThread() const |
| 45 | { |
| 46 | return m_main_thread; |
| 47 | } |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 48 | |
Zachary Turner | dcd8037 | 2014-11-11 00:00:14 +0000 | [diff] [blame^] | 49 | void ContinueAsyncException(ExceptionResult result); |
| 50 | |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 51 | private: |
| 52 | void DebugLoop(); |
Zachary Turner | dcd8037 | 2014-11-11 00:00:14 +0000 | [diff] [blame^] | 53 | ExceptionResult HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info, DWORD thread_id); |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 54 | DWORD HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info, DWORD thread_id); |
| 55 | DWORD HandleCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO &info, DWORD thread_id); |
| 56 | DWORD HandleExitThreadEvent(const EXIT_THREAD_DEBUG_INFO &info, DWORD thread_id); |
| 57 | DWORD HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info, DWORD thread_id); |
| 58 | DWORD HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info, DWORD thread_id); |
| 59 | DWORD HandleUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO &info, DWORD thread_id); |
| 60 | DWORD HandleODSEvent(const OUTPUT_DEBUG_STRING_INFO &info, DWORD thread_id); |
| 61 | DWORD HandleRipEvent(const RIP_INFO &info, DWORD thread_id); |
| 62 | |
| 63 | DebugDelegateSP m_debug_delegate; |
| 64 | |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 65 | HostProcess m_process; // The process being debugged. |
| 66 | HostThread m_main_thread; // The main thread of the inferior. |
| 67 | HANDLE m_image_file; // The image file of the process being debugged. |
| 68 | |
Zachary Turner | dcd8037 | 2014-11-11 00:00:14 +0000 | [diff] [blame^] | 69 | Predicate<ExceptionResult> m_exception; // A predicate which gets signalled when an exception |
| 70 | // is finished processing and the debug loop can be |
| 71 | // continued. |
| 72 | |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 73 | static lldb::thread_result_t DebuggerThreadRoutine(void *data); |
| 74 | lldb::thread_result_t DebuggerThreadRoutine(const ProcessLaunchInfo &launch_info); |
| 75 | }; |
| 76 | } |
| 77 | |
| 78 | #endif |