LLDB  mainline
LocalDebugDelegate.h
Go to the documentation of this file.
1 //===-- LocalDebugDelegate.h ------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_Plugins_Process_Windows_LocalDebugDelegate_H_
10 #define liblldb_Plugins_Process_Windows_LocalDebugDelegate_H_
11 
12 #include <memory>
13 
14 #include "IDebugDelegate.h"
15 
16 #include "lldb/lldb-forward.h"
17 
18 namespace lldb_private {
19 
21 typedef std::shared_ptr<ProcessWindows> ProcessWindowsSP;
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
27 // driver. It would be possible to get a similar decoupling by just having
28 // ProcessWindows implement this interface directly. There are two reasons
29 // why 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.
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.
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.
42 public:
43  explicit LocalDebugDelegate(lldb::ProcessWP process);
44 
45  void OnExitProcess(uint32_t exit_code) override;
46  void OnDebuggerConnected(lldb::addr_t image_base) override;
47  ExceptionResult OnDebugException(bool first_chance,
48  const ExceptionRecord &record) override;
49  void OnCreateThread(const HostThread &thread) override;
50  void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override;
51  void OnLoadDll(const lldb_private::ModuleSpec &module_spec,
52  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 Status &error, uint32_t type) override;
56 
57 private:
59 
60  lldb::ProcessWP m_process;
61 };
62 }
63 
64 #endif
lldb_private::LocalDebugDelegate::OnDebuggerConnected
void OnDebuggerConnected(lldb::addr_t image_base) override
Definition: LocalDebugDelegate.cpp:23
lldb_private::LocalDebugDelegate::OnUnloadDll
void OnUnloadDll(lldb::addr_t module_addr) override
Definition: LocalDebugDelegate.cpp:54
lldb_private::HostThread
Definition: HostThread.h:29
IDebugDelegate.h
lldb_private::LocalDebugDelegate::LocalDebugDelegate
LocalDebugDelegate(lldb::ProcessWP process)
Definition: LocalDebugDelegate.cpp:15
lldb_private::LocalDebugDelegate::GetProcessPointer
ProcessWindowsSP GetProcessPointer()
Definition: LocalDebugDelegate.cpp:69
lldb_private::LocalDebugDelegate::OnDebugString
void OnDebugString(const std::string &message) override
Definition: LocalDebugDelegate.cpp:59
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::ProcessWindows
Definition: ProcessWindows.h:23
lldb_private::LocalDebugDelegate::OnLoadDll
void OnLoadDll(const lldb_private::ModuleSpec &module_spec, lldb::addr_t module_addr) override
Definition: LocalDebugDelegate.cpp:48
lldb_private::IDebugDelegate
Definition: IDebugDelegate.h:25
lldb_private::LocalDebugDelegate::OnDebuggerError
void OnDebuggerError(const Status &error, uint32_t type) override
Definition: LocalDebugDelegate.cpp:64
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::LocalDebugDelegate::OnDebugException
ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record) override
Definition: LocalDebugDelegate.cpp:29
ExceptionResult
ExceptionResult
Definition: ForwardDecl.h:16
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:39
lldb_private::LocalDebugDelegate
Definition: LocalDebugDelegate.h:41
lldb_private::LocalDebugDelegate::OnCreateThread
void OnCreateThread(const HostThread &thread) override
Definition: LocalDebugDelegate.cpp:37
lldb_private::ModuleSpec
Definition: ModuleSpec.h:26
lldb_private::Status
Definition: Status.h:44
message
message(FATAL_ERROR "invalid libipt include path provided") endif() include_directories($
Definition: Plugins/Trace/intel-pt/CMakeLists.txt:6
uint32_t
lldb_private::ProcessWindowsSP
std::shared_ptr< ProcessWindows > ProcessWindowsSP
Definition: LocalDebugDelegate.h:20
lldb_private::LocalDebugDelegate::m_process
lldb::ProcessWP m_process
Definition: LocalDebugDelegate.h:60
lldb_private::LocalDebugDelegate::OnExitThread
void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override
Definition: LocalDebugDelegate.cpp:42
lldb_private::LocalDebugDelegate::OnExitProcess
void OnExitProcess(uint32_t exit_code) override
Definition: LocalDebugDelegate.cpp:18
lldb-forward.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::ExceptionRecord
Definition: ExceptionRecord.h:25
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86