LLDB  mainline
ProcessDebugger.h
Go to the documentation of this file.
1 //===-- ProcessDebugger.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_ProcessDebugger_h_
10 #define liblldb_ProcessDebugger_h_
11 
13 
14 #include "lldb/Utility/Status.h"
15 #include "lldb/lldb-forward.h"
16 #include "lldb/lldb-types.h"
17 #include "llvm/Support/Mutex.h"
18 
19 #include "ForwardDecl.h"
20 #include <map>
21 #include <set>
22 
23 namespace lldb_private {
24 
25 class HostProcess;
26 class HostThread;
27 class ProcessLaunchInfo;
28 class ProcessAttachInfo;
29 
31 public:
32  ProcessWindowsData(bool stop_at_entry) : m_stop_at_entry(stop_at_entry) {
33  m_initial_stop_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr);
34  }
35 
37 
40  // StopInfoSP m_pending_stop_info;
41  HANDLE m_initial_stop_event = nullptr;
44  std::map<lldb::tid_t, lldb::ThreadSP> m_new_threads;
45  std::set<lldb::tid_t> m_exited_threads;
46 };
47 
49 
50 public:
51  virtual ~ProcessDebugger();
52 
53  virtual void OnExitProcess(uint32_t exit_code);
54  virtual void OnDebuggerConnected(lldb::addr_t image_base);
55  virtual ExceptionResult OnDebugException(bool first_chance,
56  const ExceptionRecord &record);
57  virtual void OnCreateThread(const HostThread &thread);
58  virtual void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code);
59  virtual void OnLoadDll(const ModuleSpec &module_spec,
60  lldb::addr_t module_addr);
61  virtual void OnUnloadDll(lldb::addr_t module_addr);
62  virtual void OnDebugString(const std::string &string);
63  virtual void OnDebuggerError(const Status &error, uint32_t type);
64 
65 protected:
67 
69  DebugDelegateSP delegate);
70 
71  Status AttachProcess(lldb::pid_t pid, const ProcessAttachInfo &attach_info,
72  DebugDelegateSP delegate);
73 
74  Status DestroyProcess(lldb::StateType process_state);
75 
76  Status HaltProcess(bool &caused_stop);
77 
79  MemoryRegionInfo &range_info);
80 
81  Status ReadMemory(lldb::addr_t addr, void *buf, size_t size,
82  size_t &bytes_read);
83 
84  Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
85  size_t &bytes_written);
86 
87  Status AllocateMemory(size_t size, uint32_t permissions, lldb::addr_t &addr);
88 
90 
92 
94  HostProcess &process);
95 
96 protected:
97  llvm::sys::Mutex m_mutex;
98  std::unique_ptr<ProcessWindowsData> m_session_data;
99 };
100 
101 } // namespace lldb_private
102 
103 #endif // #ifndef liblldb_ProcessDebugger_h_
lldb_private::HostProcess
Definition: HostProcess.h:33
lldb_private::ProcessDebugger::GetDebuggedProcessId
lldb::pid_t GetDebuggedProcessId() const
Definition: ProcessDebugger.cpp:68
lldb_private::ProcessWindowsData::m_stop_at_entry
bool m_stop_at_entry
Definition: ProcessDebugger.h:43
lldb_private::HostThread
Definition: HostThread.h:29
lldb_private::DebuggerThreadSP
std::shared_ptr< DebuggerThread > DebuggerThreadSP
Definition: ForwardDecl.h:36
lldb_private::ProcessDebugger::~ProcessDebugger
virtual ~ProcessDebugger()
Definition: ProcessDebugger.cpp:66
lldb_private::MemoryRegionInfo
Definition: MemoryRegionInfo.h:21
lldb_private::ProcessDebugger::m_mutex
llvm::sys::Mutex m_mutex
Definition: ProcessDebugger.h:97
lldb_private::ProcessDebugger::ReadMemory
Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read)
Definition: ProcessDebugger.cpp:262
lldb_private::ProcessDebugger::OnCreateThread
virtual void OnCreateThread(const HostThread &thread)
Definition: ProcessDebugger.cpp:520
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::ProcessDebugger::DestroyProcess
Status DestroyProcess(lldb::StateType process_state)
Definition: ProcessDebugger.cpp:211
lldb_private::ProcessDebugger::DetachProcess
Status DetachProcess()
Definition: ProcessDebugger.cpp:74
lldb_private::ProcessDebugger::AttachProcess
Status AttachProcess(lldb::pid_t pid, const ProcessAttachInfo &attach_info, DebugDelegateSP delegate)
Definition: ProcessDebugger.cpp:171
lldb_private::ProcessDebugger
Definition: ProcessDebugger.h:48
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::ProcessDebugger::OnUnloadDll
virtual void OnUnloadDll(lldb::addr_t module_addr)
Definition: ProcessDebugger.cpp:533
lldb_private::ProcessWindowsData::m_initial_stop_received
bool m_initial_stop_received
Definition: ProcessDebugger.h:42
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
ForwardDecl.h
lldb_private::ProcessDebugger::OnDebuggerError
virtual void OnDebuggerError(const Status &error, uint32_t type)
Definition: ProcessDebugger.cpp:539
lldb_private::ProcessWindowsData::m_exited_threads
std::set< lldb::tid_t > m_exited_threads
Definition: ProcessDebugger.h:45
ExceptionResult
ExceptionResult
Definition: ForwardDecl.h:16
lldb_private::ProcessDebugger::LaunchProcess
Status LaunchProcess(ProcessLaunchInfo &launch_info, DebugDelegateSP delegate)
Definition: ProcessDebugger.cpp:105
lldb_private::ProcessWindowsData::m_launch_error
Status m_launch_error
Definition: ProcessDebugger.h:38
lldb_private::DebugDelegateSP
std::shared_ptr< IDebugDelegate > DebugDelegateSP
Definition: ForwardDecl.h:33
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::ProcessDebugger::WaitForDebuggerConnection
Status WaitForDebuggerConnection(DebuggerThreadSP debugger, HostProcess &process)
Definition: ProcessDebugger.cpp:564
lldb_private::ProcessWindowsData::ProcessWindowsData
ProcessWindowsData(bool stop_at_entry)
Definition: ProcessDebugger.h:32
lldb_private::ProcessAttachInfo
Definition: Process.h:113
lldb-types.h
lldb_private::ProcessDebugger::OnLoadDll
virtual void OnLoadDll(const ModuleSpec &module_spec, lldb::addr_t module_addr)
Definition: ProcessDebugger.cpp:528
lldb_private::ProcessDebugger::DeallocateMemory
Status DeallocateMemory(lldb::addr_t addr)
Definition: ProcessDebugger.cpp:355
lldb_private::ModuleSpec
Definition: ModuleSpec.h:26
lldb_private::Status
Definition: Status.h:44
lldb_private::ProcessWindowsData::~ProcessWindowsData
~ProcessWindowsData()
Definition: ProcessDebugger.h:36
uint32_t
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
lldb_private::ProcessWindowsData
Definition: ProcessDebugger.h:30
windows.h
lldb_private::ProcessDebugger::OnDebuggerConnected
virtual void OnDebuggerConnected(lldb::addr_t image_base)
Definition: ProcessDebugger.cpp:482
lldb-forward.h
lldb_private::ProcessDebugger::OnDebugString
virtual void OnDebugString(const std::string &string)
Definition: ProcessDebugger.cpp:537
Status.h
lldb_private::ProcessDebugger::OnDebugException
virtual ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record)
Definition: ProcessDebugger.cpp:485
lldb_private::ProcessDebugger::HaltProcess
Status HaltProcess(bool &caused_stop)
Definition: ProcessDebugger.cpp:247
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::ProcessDebugger::OnExitThread
virtual void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code)
Definition: ProcessDebugger.cpp:524
lldb_private::ProcessDebugger::AllocateMemory
Status AllocateMemory(size_t size, uint32_t permissions, lldb::addr_t &addr)
Definition: ProcessDebugger.cpp:326
lldb_private::ProcessWindowsData::m_debugger
DebuggerThreadSP m_debugger
Definition: ProcessDebugger.h:39
lldb_private::ProcessWindowsData::m_initial_stop_event
HANDLE m_initial_stop_event
Definition: ProcessDebugger.h:41
lldb::StateType
StateType
Process and Thread States.
Definition: lldb-enumerations.h:73
lldb_private::ProcessDebugger::WriteMemory
Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written)
Definition: ProcessDebugger.cpp:296
lldb_private::ProcessDebugger::m_session_data
std::unique_ptr< ProcessWindowsData > m_session_data
Definition: ProcessDebugger.h:98
lldb_private::ProcessWindowsData::m_new_threads
std::map< lldb::tid_t, lldb::ThreadSP > m_new_threads
Definition: ProcessDebugger.h:44
lldb_private::ProcessDebugger::OnExitProcess
virtual void OnExitProcess(uint32_t exit_code)
Definition: ProcessDebugger.cpp:472
lldb_private::ProcessDebugger::GetMemoryRegionInfo
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info)
Definition: ProcessDebugger.cpp:380
lldb_private::ExceptionRecord
Definition: ExceptionRecord.h:25
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86