blob: 389a1d3c88cd89524ab8ca6d3e5641c2f00235d0 [file] [log] [blame]
Zachary Turner02862bc2014-11-07 23:44:13 +00001//===-- 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 Turnerdcd80372014-11-11 00:00:14 +000016#include "lldb/Host/Predicate.h"
Zachary Turner02862bc2014-11-07 23:44:13 +000017#include "lldb/Host/windows/windows.h"
18
19#include <memory>
20
21namespace lldb_private
22{
23
24//----------------------------------------------------------------------
25// DebuggerThread
26//
27// Debugs a single process, notifying listeners as appropriate when interesting
28// things occur.
29//----------------------------------------------------------------------
30class DebuggerThread : public std::enable_shared_from_this<DebuggerThread>
31{
32 public:
33 DebuggerThread(DebugDelegateSP debug_delegate);
34 virtual ~DebuggerThread();
35
Zachary Turner3985f892014-11-10 22:32:18 +000036 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 Turner02862bc2014-11-07 23:44:13 +000048
Zachary Turnerdcd80372014-11-11 00:00:14 +000049 void ContinueAsyncException(ExceptionResult result);
50
Zachary Turner02862bc2014-11-07 23:44:13 +000051 private:
52 void DebugLoop();
Zachary Turnerdcd80372014-11-11 00:00:14 +000053 ExceptionResult HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info, DWORD thread_id);
Zachary Turner02862bc2014-11-07 23:44:13 +000054 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 Turner02862bc2014-11-07 23:44:13 +000065 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 Turnerdcd80372014-11-11 00:00:14 +000069 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 Turner02862bc2014-11-07 23:44:13 +000073 static lldb::thread_result_t DebuggerThreadRoutine(void *data);
74 lldb::thread_result_t DebuggerThreadRoutine(const ProcessLaunchInfo &launch_info);
75};
76}
77
78#endif