LLDB  mainline
ProcessWindows.h
Go to the documentation of this file.
1 //===-- ProcessWindows.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_Common_ProcessWindows_H_
10 #define liblldb_Plugins_Process_Windows_Common_ProcessWindows_H_
11 
12 #include "lldb/Target/Process.h"
13 #include "lldb/Utility/Status.h"
14 #include "lldb/lldb-forward.h"
15 
17 #include "ProcessDebugger.h"
18 
19 namespace lldb_private {
20 
21 class HostProcess;
22 
23 class ProcessWindows : public Process, public ProcessDebugger {
24 public:
25  // Static functions.
26  static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
27  lldb::ListenerSP listener_sp,
28  const FileSpec *,
29  bool can_connect);
30 
31  static void Initialize();
32 
33  static void Terminate();
34 
36 
37  static const char *GetPluginDescriptionStatic();
38 
39  // Constructors and destructors
40  ProcessWindows(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp);
41 
43 
44  size_t GetSTDOUT(char *buf, size_t buf_size, Status &error) override;
45  size_t GetSTDERR(char *buf, size_t buf_size, Status &error) override;
46  size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) override;
47 
48  // lldb_private::Process overrides
49  ConstString GetPluginName() override;
50 
51  Status EnableBreakpointSite(BreakpointSite *bp_site) override;
52  Status DisableBreakpointSite(BreakpointSite *bp_site) override;
53 
54  Status DoDetach(bool keep_stopped) override;
55  Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override;
57  lldb::pid_t pid,
58  const lldb_private::ProcessAttachInfo &attach_info) override;
59  Status DoResume() override;
60  Status DoDestroy() override;
61  Status DoHalt(bool &caused_stop) override;
62 
63  void DidLaunch() override;
64  void DidAttach(lldb_private::ArchSpec &arch_spec) override;
65 
66  void RefreshStateAfterStop() override;
67 
68  bool CanDebug(lldb::TargetSP target_sp,
69  bool plugin_specified_by_name) override;
70  bool DestroyRequiresHalt() override { return false; }
71  bool DoUpdateThreadList(ThreadList &old_thread_list,
72  ThreadList &new_thread_list) override;
73  bool IsAlive() override;
74 
75  size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
76  Status &error) override;
77  size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
78  Status &error) override;
79  lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions,
80  Status &error) override;
83  MemoryRegionInfo &info) override;
84 
86 
88 
89  // IDebugDelegate overrides.
90  void OnExitProcess(uint32_t exit_code) override;
91  void OnDebuggerConnected(lldb::addr_t image_base) override;
92  ExceptionResult OnDebugException(bool first_chance,
93  const ExceptionRecord &record) override;
94  void OnCreateThread(const HostThread &thread) override;
95  void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override;
96  void OnLoadDll(const ModuleSpec &module_spec,
97  lldb::addr_t module_addr) override;
98  void OnUnloadDll(lldb::addr_t module_addr) override;
99  void OnDebugString(const std::string &string) override;
100  void OnDebuggerError(const Status &error, uint32_t type) override;
101 
103  Status GetWatchpointSupportInfo(uint32_t &num, bool &after) override;
104  Status EnableWatchpoint(Watchpoint *wp, bool notify = true) override;
105  Status DisableWatchpoint(Watchpoint *wp, bool notify = true) override;
106 
107 private:
108  struct WatchpointInfo {
112  bool read;
113  bool write;
114  };
115  std::map<lldb::break_id_t, WatchpointInfo> m_watchpoints;
116  std::vector<lldb::break_id_t> m_watchpoint_ids;
117 };
118 } // namespace lldb_private
119 
120 #endif // liblldb_Plugins_Process_Windows_Common_ProcessWindows_H_
lldb_private::ProcessWindows::DidAttach
void DidAttach(lldb_private::ArchSpec &arch_spec) override
Called after attaching a process.
Definition: ProcessWindows.cpp:284
lldb_private::ProcessWindows::DoReadMemory
size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error) override
Actually do the reading of memory from a process.
Definition: ProcessWindows.cpp:590
lldb_private::ProcessWindows::OnDebugString
void OnDebugString(const std::string &string) override
Definition: ProcessWindows.cpp:819
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::ProcessWindows::m_watchpoint_ids
std::vector< lldb::break_id_t > m_watchpoint_ids
Definition: ProcessWindows.h:116
DynamicLoaderWindowsDYLD.h
lldb_private::ProcessWindows::GetPluginDescriptionStatic
static const char * GetPluginDescriptionStatic()
Definition: ProcessWindows.cpp:114
lldb_private::HostThread
Definition: HostThread.h:29
lldb_private::ProcessWindows::Terminate
static void Terminate()
Definition: ProcessWindows.cpp:107
lldb_private::ProcessWindows::GetPluginName
ConstString GetPluginName() override
Definition: ProcessWindows.cpp:147
lldb_private::ProcessWindows::GetSTDOUT
size_t GetSTDOUT(char *buf, size_t buf_size, Status &error) override
Get any available STDOUT.
Definition: ProcessWindows.cpp:129
lldb_private::ProcessWindows::WatchpointInfo
Definition: ProcessWindows.h:108
lldb_private::Process
Definition: Process.h:342
lldb_private::ProcessWindows::DoHalt
Status DoHalt(bool &caused_stop) override
Halts a running process.
Definition: ProcessWindows.cpp:271
lldb_private::ProcessWindows::IsAlive
bool IsAlive() override
Check if a process is still alive.
Definition: ProcessWindows.cpp:576
lldb_private::ProcessWindows::DoAttachToProcessWithID
Status DoAttachToProcessWithID(lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info) override
Attach to an existing process using a process ID.
Definition: ProcessWindows.cpp:207
lldb_private::Module
Definition: Module.h:84
lldb_private::ProcessWindows::~ProcessWindows
~ProcessWindows()
Definition: ProcessWindows.cpp:127
lldb_private::ProcessWindows::GetImageInfoAddress
lldb::addr_t GetImageInfoAddress() override
Get the image information address for the current process.
Definition: ProcessWindows.cpp:620
lldb_private::MemoryRegionInfo
Definition: MemoryRegionInfo.h:21
lldb_private::ProcessWindows::OnExitProcess
void OnExitProcess(uint32_t exit_code) override
Definition: ProcessWindows.cpp:637
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::ProcessWindows
Definition: ProcessWindows.h:23
lldb_private::ProcessWindows::OnDebuggerError
void OnDebuggerError(const Status &error, uint32_t type) override
Definition: ProcessWindows.cpp:821
lldb_private::ProcessWindows::WatchpointInfo::read
bool read
Definition: ProcessWindows.h:112
lldb_private::ProcessWindows::GetWatchpointSupportInfo
Status GetWatchpointSupportInfo(uint32_t &num) override
Definition: ProcessWindows.cpp:846
lldb_private::ProcessWindows::EnableWatchpoint
Status EnableWatchpoint(Watchpoint *wp, bool notify=true) override
Definition: ProcessWindows.cpp:857
Process.h
lldb_private::ProcessWindows::WatchpointInfo::size
uint32_t size
Definition: ProcessWindows.h:111
lldb_private::ProcessWindows::DisableWatchpoint
Status DisableWatchpoint(Watchpoint *wp, bool notify=true) override
Definition: ProcessWindows.cpp:911
lldb_private::ProcessWindows::OnExitThread
void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override
Definition: ProcessWindows.cpp:790
lldb_private::ProcessWindows::PutSTDIN
size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) override
Puts data into this process's STDIN.
Definition: ProcessWindows.cpp:139
lldb_private::ProcessWindows::DisableBreakpointSite
Status DisableBreakpointSite(BreakpointSite *bp_site) override
Definition: ProcessWindows.cpp:165
lldb_private::ProcessWindows::OnLoadDll
void OnLoadDll(const ModuleSpec &module_spec, lldb::addr_t module_addr) override
Definition: ProcessWindows.cpp:808
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::ProcessDebugger
Definition: ProcessDebugger.h:48
lldb_private::ProcessWindows::GetMemoryRegionInfo
Status GetMemoryRegionInfo(lldb::addr_t vm_addr, MemoryRegionInfo &info) override
Locate the memory region that contains load_addr.
Definition: ProcessWindows.cpp:615
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::ProcessWindows::DoUpdateThreadList
bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override
Update the thread list following process plug-in's specific logic.
Definition: ProcessWindows.cpp:532
lldb_private::ProcessWindows::DoWriteMemory
size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error) override
Actually do the writing of memory to a process.
Definition: ProcessWindows.cpp:597
lldb_private::ProcessWindows::Initialize
static void Initialize()
Definition: ProcessWindows.cpp:95
lldb_private::BreakpointSite
Definition: BreakpointSite.h:35
lldb_private::ProcessWindows::CreateInstance
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *, bool can_connect)
Definition: ProcessWindows.cpp:80
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
lldb_private::ProcessWindows::GetDynamicLoader
DynamicLoaderWindowsDYLD * GetDynamicLoader() override
Get the dynamic loader plug-in for this process.
Definition: ProcessWindows.cpp:630
lldb_private::Watchpoint
Definition: Watchpoint.h:24
ExceptionResult
ExceptionResult
Definition: ForwardDecl.h:16
lldb_private::ThreadList
Definition: ThreadList.h:26
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::ProcessWindows::DoResume
Status DoResume() override
Resumes all of a process's threads as configured using the Thread run control functions.
Definition: ProcessWindows.cpp:216
lldb_private::ProcessWindows::GetSTDERR
size_t GetSTDERR(char *buf, size_t buf_size, Status &error) override
Get any available STDERR.
Definition: ProcessWindows.cpp:134
lldb_private::ProcessWindows::OnCreateThread
void OnCreateThread(const HostThread &thread) override
Definition: ProcessWindows.cpp:770
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::ProcessWindows::RefreshStateAfterStop
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
Definition: ProcessWindows.cpp:362
lldb_private::ProcessWindows::DoDeallocateMemory
Status DoDeallocateMemory(lldb::addr_t ptr) override
Actually deallocate memory in the process.
Definition: ProcessWindows.cpp:611
lldb_private::ProcessAttachInfo
Definition: Process.h:115
lldb_private::ProcessWindows::DidLaunch
void DidLaunch() override
Called after launching a process.
Definition: ProcessWindows.cpp:279
lldb_private::ProcessWindows::DestroyRequiresHalt
bool DestroyRequiresHalt() override
Definition: ProcessWindows.h:70
lldb_private::ModuleSpec
Definition: ModuleSpec.h:26
lldb_private::ProcessWindows::OnDebuggerConnected
void OnDebuggerConnected(lldb::addr_t image_base) override
Definition: ProcessWindows.cpp:656
lldb_private::Status
Definition: Status.h:44
uint32_t
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
lldb_private::ProcessWindows::m_watchpoints
std::map< lldb::break_id_t, WatchpointInfo > m_watchpoints
Definition: ProcessWindows.h:115
lldb_private::ProcessWindows::CanDebug
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
Definition: ProcessWindows.cpp:518
lldb_private::ProcessWindows::DoDetach
Status DoDetach(bool keep_stopped) override
Detaches from a running or stopped process.
Definition: ProcessWindows.cpp:177
lldb_private::ProcessWindows::DoDestroy
Status DoDestroy() override
Definition: ProcessWindows.cpp:266
lldb-forward.h
lldb_private::ProcessWindows::DoAllocateMemory
lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, Status &error) override
Actually allocate memory in the process.
Definition: ProcessWindows.cpp:604
lldb_private::ProcessWindows::GetPluginNameStatic
static lldb_private::ConstString GetPluginNameStatic()
Definition: ProcessWindows.cpp:109
Status.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::ProcessWindows::OnDebugException
ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record) override
Definition: ProcessWindows.cpp:704
ProcessDebugger.h
lldb_private::ProcessWindows::WatchpointInfo::slot_id
uint32_t slot_id
Definition: ProcessWindows.h:109
lldb_private::DynamicLoaderWindowsDYLD
Definition: DynamicLoaderWindowsDYLD.h:19
lldb_private::ProcessWindows::ProcessWindows
ProcessWindows(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
Definition: ProcessWindows.cpp:120
lldb_private::ProcessWindows::WatchpointInfo::write
bool write
Definition: ProcessWindows.h:113
lldb_private::ExceptionRecord
Definition: ExceptionRecord.h:25
lldb_private::ProcessWindows::DoLaunch
Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override
Launch a new process.
Definition: ProcessWindows.cpp:196
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86
lldb_private::ProcessWindows::WatchpointInfo::address
lldb::addr_t address
Definition: ProcessWindows.h:110
lldb_private::ProcessWindows::EnableBreakpointSite
Status EnableBreakpointSite(BreakpointSite *bp_site) override
Definition: ProcessWindows.cpp:151
lldb_private::ProcessWindows::OnUnloadDll
void OnUnloadDll(lldb::addr_t module_addr) override
Definition: ProcessWindows.cpp:814