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 | |
Zachary Turner | fb6c3494 | 2014-12-10 23:25:10 +0000 | [diff] [blame^] | 13 | #include <memory> |
| 14 | |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 15 | #include "ForwardDecl.h" |
| 16 | #include "lldb/Host/HostProcess.h" |
| 17 | #include "lldb/Host/HostThread.h" |
Zachary Turner | dcd8037 | 2014-11-11 00:00:14 +0000 | [diff] [blame] | 18 | #include "lldb/Host/Predicate.h" |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 19 | #include "lldb/Host/windows/windows.h" |
| 20 | |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 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 | fb6c3494 | 2014-12-10 23:25:10 +0000 | [diff] [blame^] | 48 | std::weak_ptr<ExceptionRecord> |
Zachary Turner | c6a6653 | 2014-12-03 22:04:18 +0000 | [diff] [blame] | 49 | GetActiveException() |
| 50 | { |
Zachary Turner | fb6c3494 | 2014-12-10 23:25:10 +0000 | [diff] [blame^] | 51 | return m_active_exception; |
Zachary Turner | c6a6653 | 2014-12-03 22:04:18 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | Error StopDebugging(bool terminate); |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 55 | |
Zachary Turner | dcd8037 | 2014-11-11 00:00:14 +0000 | [diff] [blame] | 56 | void ContinueAsyncException(ExceptionResult result); |
| 57 | |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 58 | private: |
Zachary Turner | c6a6653 | 2014-12-03 22:04:18 +0000 | [diff] [blame] | 59 | void FreeProcessHandles(); |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 60 | void DebugLoop(); |
Zachary Turner | dcd8037 | 2014-11-11 00:00:14 +0000 | [diff] [blame] | 61 | ExceptionResult HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info, DWORD thread_id); |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 62 | DWORD HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info, DWORD thread_id); |
| 63 | DWORD HandleCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO &info, DWORD thread_id); |
| 64 | DWORD HandleExitThreadEvent(const EXIT_THREAD_DEBUG_INFO &info, DWORD thread_id); |
| 65 | DWORD HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info, DWORD thread_id); |
| 66 | DWORD HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info, DWORD thread_id); |
| 67 | DWORD HandleUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO &info, DWORD thread_id); |
| 68 | DWORD HandleODSEvent(const OUTPUT_DEBUG_STRING_INFO &info, DWORD thread_id); |
| 69 | DWORD HandleRipEvent(const RIP_INFO &info, DWORD thread_id); |
| 70 | |
| 71 | DebugDelegateSP m_debug_delegate; |
| 72 | |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 73 | HostProcess m_process; // The process being debugged. |
| 74 | HostThread m_main_thread; // The main thread of the inferior. |
| 75 | HANDLE m_image_file; // The image file of the process being debugged. |
| 76 | |
Zachary Turner | fb6c3494 | 2014-12-10 23:25:10 +0000 | [diff] [blame^] | 77 | ExceptionRecordSP m_active_exception; // The current exception waiting to be handled |
Zachary Turner | c6a6653 | 2014-12-03 22:04:18 +0000 | [diff] [blame] | 78 | |
| 79 | Predicate<ExceptionResult> m_exception_pred; // A predicate which gets signalled when an exception |
| 80 | // is finished processing and the debug loop can be |
| 81 | // continued. |
Zachary Turner | dcd8037 | 2014-11-11 00:00:14 +0000 | [diff] [blame] | 82 | |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 83 | static lldb::thread_result_t DebuggerThreadRoutine(void *data); |
| 84 | lldb::thread_result_t DebuggerThreadRoutine(const ProcessLaunchInfo &launch_info); |
| 85 | }; |
| 86 | } |
| 87 | |
| 88 | #endif |