Zachary Turner | 742346a | 2014-11-05 22:16:28 +0000 | [diff] [blame] | 1 | //===-- 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 "IDebugDelegate.h" |
| 14 | #include "lldb/lldb-forward.h" |
| 15 | |
| 16 | class ProcessWindows; |
| 17 | |
| 18 | namespace lldb_private |
| 19 | { |
| 20 | //---------------------------------------------------------------------- |
| 21 | // LocalDebugDelegate |
| 22 | // |
| 23 | // LocalDebugDelegate creates a connection between a ProcessWindows and the |
| 24 | // debug driver. This serves to decouple ProcessWindows from the debug driver. |
| 25 | // It would be possible to get a similar decoupling by just having |
| 26 | // ProcessWindows implement this interface directly. There are two reasons why |
| 27 | // we don't do this: |
| 28 | // |
| 29 | // 1) In the future when we add support for local debugging through LLGS, and we |
| 30 | // go through the Native*Protocol interface, it is likely we will need the |
| 31 | // additional flexibility provided by this sort of adapter pattern. |
| 32 | // 2) LLDB holds a shared_ptr to the ProcessWindows, and our driver thread also |
| 33 | // also needs access to it as well. To avoid a race condition, we want to |
| 34 | // make sure that we're also holding onto a shared_ptr. |
| 35 | // lldb_private::Process supports enable_shared_from_this, but that gives us |
| 36 | // a ProcessSP (which is exactly what we are trying to decouple from the |
| 37 | // driver), so this adapter serves as a way to transparently hold the |
| 38 | // ProcessSP while still keeping it decoupled from the driver. |
| 39 | //---------------------------------------------------------------------- |
| 40 | class LocalDebugDelegate : public IDebugDelegate |
| 41 | { |
| 42 | public: |
Zachary Turner | 48b475c | 2015-04-02 20:57:38 +0000 | [diff] [blame] | 43 | explicit LocalDebugDelegate(lldb::ProcessSP process); |
Zachary Turner | 742346a | 2014-11-05 22:16:28 +0000 | [diff] [blame] | 44 | |
David Blaikie | bcd891f | 2015-04-08 17:22:09 +0000 | [diff] [blame] | 45 | void OnExitProcess(uint32_t exit_code) override; |
| 46 | void OnDebuggerConnected(lldb::addr_t image_base) override; |
| 47 | ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record) override; |
| 48 | void OnCreateThread(const HostThread &thread) override; |
Adrian McCarthy | 2f8e4c3 | 2015-05-18 23:24:32 +0000 | [diff] [blame] | 49 | void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override; |
David Blaikie | bcd891f | 2015-04-08 17:22:09 +0000 | [diff] [blame] | 50 | void OnLoadDll(const lldb_private::ModuleSpec &module_spec, lldb::addr_t module_addr) override; |
| 51 | void OnUnloadDll(lldb::addr_t module_addr) override; |
| 52 | void OnDebugString(const std::string &message) override; |
| 53 | void OnDebuggerError(const Error &error, uint32_t type) override; |
Zachary Turner | 742346a | 2014-11-05 22:16:28 +0000 | [diff] [blame] | 54 | |
| 55 | private: |
| 56 | lldb::ProcessSP m_process; |
| 57 | }; |
| 58 | } |
| 59 | |
| 60 | #endif |