blob: 17e760c44533e4b630c1af7ff271839ea0400991 [file] [log] [blame]
Adrian McCarthy18a9135d2015-10-28 18:21:45 +00001//===-- LocalDebugDelegate.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_LocalDebugDelegate_H_
11#define liblldb_Plugins_Process_Windows_LocalDebugDelegate_H_
12
13#include <memory>
14
15#include "IDebugDelegate.h"
16
17#include "lldb/lldb-forward.h"
18
Kate Stoneb9c1b512016-09-06 20:57:50 +000019namespace lldb_private {
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000020
21class ProcessWindowsLive;
22typedef std::shared_ptr<ProcessWindowsLive> ProcessWindowsLiveSP;
23
24//----------------------------------------------------------------------
25// LocalDebugDelegate
26//
27// LocalDebugDelegate creates a connection between a ProcessWindowsLive and the
Kate Stoneb9c1b512016-09-06 20:57:50 +000028// debug driver. This serves to decouple ProcessWindowsLive from the debug
29// driver.
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000030// It would be possible to get a similar decoupling by just having
Kate Stoneb9c1b512016-09-06 20:57:50 +000031// ProcessWindowsLive implement this interface directly. There are two reasons
32// why
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000033// we don't do this:
34//
35// 1) In the future when we add support for local debugging through LLGS, and we
36// go through the Native*Protocol interface, it is likely we will need the
37// additional flexibility provided by this sort of adapter pattern.
38// 2) LLDB holds a shared_ptr to the ProcessWindows, and our driver thread
39// needs access to it as well. To avoid a race condition, we want to make
40// sure that we're also holding onto a shared_ptr.
41// lldb_private::Process supports enable_shared_from_this, but that gives us
42// a ProcessSP (which is exactly what we are trying to decouple from the
43// driver), so this adapter serves as a way to transparently hold the
44// ProcessSP while still keeping it decoupled from the driver.
45//----------------------------------------------------------------------
Kate Stoneb9c1b512016-09-06 20:57:50 +000046class LocalDebugDelegate : public IDebugDelegate {
47public:
48 explicit LocalDebugDelegate(lldb::ProcessWP process);
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000049
Kate Stoneb9c1b512016-09-06 20:57:50 +000050 void OnExitProcess(uint32_t exit_code) override;
51 void OnDebuggerConnected(lldb::addr_t image_base) override;
52 ExceptionResult OnDebugException(bool first_chance,
53 const ExceptionRecord &record) override;
54 void OnCreateThread(const HostThread &thread) override;
55 void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override;
56 void OnLoadDll(const lldb_private::ModuleSpec &module_spec,
57 lldb::addr_t module_addr) override;
58 void OnUnloadDll(lldb::addr_t module_addr) override;
59 void OnDebugString(const std::string &message) override;
60 void OnDebuggerError(const Error &error, uint32_t type) override;
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000061
Kate Stoneb9c1b512016-09-06 20:57:50 +000062private:
63 ProcessWindowsLiveSP GetProcessPointer();
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000064
Kate Stoneb9c1b512016-09-06 20:57:50 +000065 lldb::ProcessWP m_process;
Adrian McCarthy18a9135d2015-10-28 18:21:45 +000066};
67}
68
69#endif