blob: 2429f873c8231f3ec4d64898a8f173db0a316c92 [file] [log] [blame]
Adrian McCarthy18a9135d2015-10-28 18:21:45 +00001//===-- ProcessWindowsLive.h ------------------------------------*- C++ -*-===//
Zachary Turner35ed1322014-07-28 16:45:18 +00002//
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
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000010#ifndef liblldb_Plugins_Process_Windows_Live_ProcessWindowsLive_H_
11#define liblldb_Plugins_Process_Windows_Live_ProcessWindowsLive_H_
Zachary Turner35ed1322014-07-28 16:45:18 +000012
13// C Includes
14
15// C++ Includes
Zachary Turner3985f892014-11-10 22:32:18 +000016#include <memory>
Zachary Turner35ed1322014-07-28 16:45:18 +000017#include <queue>
18
19// Other libraries and framework includes
Zachary Turner742346a2014-11-05 22:16:28 +000020#include "ForwardDecl.h"
21#include "IDebugDelegate.h"
Zachary Turnera32d2ce2014-11-12 19:31:56 +000022#include "lldb/lldb-forward.h"
Zachary Turner3985f892014-11-10 22:32:18 +000023#include "lldb/Core/Error.h"
Zachary Turner8f211742014-11-04 00:00:12 +000024#include "lldb/Host/HostThread.h"
Zachary Turner35ed1322014-07-28 16:45:18 +000025#include "lldb/Target/Process.h"
26
Zachary Turnerfb6c34942014-12-10 23:25:10 +000027#include "llvm/Support/Mutex.h"
28
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000029#include "plugins/Process/Windows/Common/ProcessWindows.h"
30
Zachary Turner35ed1322014-07-28 16:45:18 +000031class ProcessMonitor;
32
Zachary Turner8f211742014-11-04 00:00:12 +000033namespace lldb_private
34{
Zachary Turnerc62733b2015-05-20 18:31:17 +000035class HostProcess;
Zachary Turner3985f892014-11-10 22:32:18 +000036class ProcessWindowsData;
Zachary Turner8f211742014-11-04 00:00:12 +000037
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000038class ProcessWindowsLive : public lldb_private::ProcessWindows, public lldb_private::IDebugDelegate
Zachary Turner35ed1322014-07-28 16:45:18 +000039{
40public:
41 //------------------------------------------------------------------
42 // Static functions.
43 //------------------------------------------------------------------
44 static lldb::ProcessSP
Zachary Turner7529df92015-09-01 20:02:29 +000045 CreateInstance(lldb::TargetSP target_sp,
Zachary Turner35ed1322014-07-28 16:45:18 +000046 lldb_private::Listener &listener,
47 const lldb_private::FileSpec *);
48
49 static void
50 Initialize();
51
52 static void
53 Terminate();
54
55 static lldb_private::ConstString
56 GetPluginNameStatic();
57
58 static const char *
59 GetPluginDescriptionStatic();
60
61 //------------------------------------------------------------------
62 // Constructors and destructors
63 //------------------------------------------------------------------
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000064 ProcessWindowsLive(lldb::TargetSP target_sp,
65 lldb_private::Listener &listener);
Zachary Turner35ed1322014-07-28 16:45:18 +000066
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000067 ~ProcessWindowsLive();
Zachary Turner8f211742014-11-04 00:00:12 +000068
Zachary Turner82da55f2014-11-25 19:03:08 +000069 // lldb_private::Process overrides
70 lldb_private::ConstString GetPluginName() override;
71 uint32_t GetPluginVersion() override;
Zachary Turner35ed1322014-07-28 16:45:18 +000072
Zachary Turnere0d93f52014-12-01 23:13:52 +000073 lldb_private::Error EnableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
74 lldb_private::Error DisableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
75
Zachary Turner82da55f2014-11-25 19:03:08 +000076 lldb_private::Error DoDetach(bool keep_stopped) override;
77 lldb_private::Error DoLaunch(lldb_private::Module *exe_module, lldb_private::ProcessLaunchInfo &launch_info) override;
Zachary Turnerc62733b2015-05-20 18:31:17 +000078 lldb_private::Error DoAttachToProcessWithID(lldb::pid_t pid,
79 const lldb_private::ProcessAttachInfo &attach_info) override;
Zachary Turner82da55f2014-11-25 19:03:08 +000080 lldb_private::Error DoResume() override;
81 lldb_private::Error DoDestroy() override;
82 lldb_private::Error DoHalt(bool &caused_stop) override;
83
Zachary Turner807eb552014-11-25 19:03:19 +000084 void DidLaunch() override;
Zachary Turnerc62733b2015-05-20 18:31:17 +000085 void DidAttach(lldb_private::ArchSpec &arch_spec) override;
Zachary Turner807eb552014-11-25 19:03:19 +000086
Zachary Turner82da55f2014-11-25 19:03:08 +000087 void RefreshStateAfterStop() override;
Zachary Turner82da55f2014-11-25 19:03:08 +000088
Zachary Turner7529df92015-09-01 20:02:29 +000089 bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
Zachary Turner82da55f2014-11-25 19:03:08 +000090 bool
Zachary Turner119767d2014-11-17 17:46:43 +000091 DestroyRequiresHalt() override
92 {
93 return false;
94 }
Zachary Turner82da55f2014-11-25 19:03:08 +000095 bool UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list) override;
96 bool IsAlive() override;
Zachary Turner35ed1322014-07-28 16:45:18 +000097
Zachary Turner82da55f2014-11-25 19:03:08 +000098 size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, lldb_private::Error &error) override;
99 size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, lldb_private::Error &error) override;
Zachary Turner5a7e8d02015-01-21 23:26:40 +0000100 lldb_private::Error GetMemoryRegionInfo(lldb::addr_t vm_addr, lldb_private::MemoryRegionInfo &info) override;
Zachary Turner742346a2014-11-05 22:16:28 +0000101
102 // IDebugDelegate overrides.
Zachary Turner82da55f2014-11-25 19:03:08 +0000103 void OnExitProcess(uint32_t exit_code) override;
104 void OnDebuggerConnected(lldb::addr_t image_base) override;
105 ExceptionResult OnDebugException(bool first_chance, const lldb_private::ExceptionRecord &record) override;
106 void OnCreateThread(const lldb_private::HostThread &thread) override;
Adrian McCarthy2f8e4c32015-05-18 23:24:32 +0000107 void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override;
Zachary Turner82da55f2014-11-25 19:03:08 +0000108 void OnLoadDll(const lldb_private::ModuleSpec &module_spec, lldb::addr_t module_addr) override;
109 void OnUnloadDll(lldb::addr_t module_addr) override;
110 void OnDebugString(const std::string &string) override;
111 void OnDebuggerError(const lldb_private::Error &error, uint32_t type) override;
Zachary Turner02862bc2014-11-07 23:44:13 +0000112
113 private:
Zachary Turnerc62733b2015-05-20 18:31:17 +0000114 lldb_private::Error WaitForDebuggerConnection(lldb_private::DebuggerThreadSP debugger,
115 lldb_private::HostProcess &process);
116
Zachary Turnerfb6c34942014-12-10 23:25:10 +0000117 llvm::sys::Mutex m_mutex;
118
Zachary Turnera32d2ce2014-11-12 19:31:56 +0000119 // Data for the active debugging session.
120 std::unique_ptr<lldb_private::ProcessWindowsData> m_session_data;
Zachary Turner35ed1322014-07-28 16:45:18 +0000121};
122
Adrian McCarthy18a9135d2015-10-28 18:21:45 +0000123}
124
125#endif // liblldb_Plugins_Process_Windows_Live_ProcessWindowsLive_H_