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