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 
35  static llvm::StringRef GetPluginNameStatic() { return "windows"; }
36 
37  static llvm::StringRef 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  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
49 
50  Status EnableBreakpointSite(BreakpointSite *bp_site) override;
51  Status DisableBreakpointSite(BreakpointSite *bp_site) override;
52 
53  Status DoDetach(bool keep_stopped) override;
54  Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override;
56  lldb::pid_t pid,
57  const lldb_private::ProcessAttachInfo &attach_info) override;
58  Status DoResume() override;
59  Status DoDestroy() override;
60  Status DoHalt(bool &caused_stop) override;
61 
62  void DidLaunch() override;
63  void DidAttach(lldb_private::ArchSpec &arch_spec) override;
64 
65  void RefreshStateAfterStop() override;
66 
67  bool CanDebug(lldb::TargetSP target_sp,
68  bool plugin_specified_by_name) override;
69  bool DestroyRequiresHalt() override { return false; }
70  bool DoUpdateThreadList(ThreadList &old_thread_list,
71  ThreadList &new_thread_list) override;
72  bool IsAlive() override;
73 
75 
76  size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
77  Status &error) override;
78  size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
79  Status &error) override;
80  lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions,
81  Status &error) override;
83 
85 
87 
88  // IDebugDelegate overrides.
89  void OnExitProcess(uint32_t exit_code) override;
90  void OnDebuggerConnected(lldb::addr_t image_base) override;
91  ExceptionResult OnDebugException(bool first_chance,
92  const ExceptionRecord &record) override;
93  void OnCreateThread(const HostThread &thread) override;
94  void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override;
95  void OnLoadDll(const ModuleSpec &module_spec,
96  lldb::addr_t module_addr) override;
97  void OnUnloadDll(lldb::addr_t module_addr) override;
98  void OnDebugString(const std::string &string) override;
99  void OnDebuggerError(const Status &error, uint32_t type) override;
100 
102  Status GetWatchpointSupportInfo(uint32_t &num, bool &after) override;
103  Status EnableWatchpoint(Watchpoint *wp, bool notify = true) override;
104  Status DisableWatchpoint(Watchpoint *wp, bool notify = true) override;
105 
106 protected:
108  MemoryRegionInfo &info) override;
109 
110 private:
111  struct WatchpointInfo {
115  bool read;
116  bool write;
117  };
118  std::map<lldb::break_id_t, WatchpointInfo> m_watchpoints;
119  std::vector<lldb::break_id_t> m_watchpoint_ids;
120 };
121 } // namespace lldb_private
122 
123 #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:274
lldb_private::ProcessWindows::GetPluginDescriptionStatic
static llvm::StringRef GetPluginDescriptionStatic()
Definition: ProcessWindows.cpp:110
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:584
lldb_private::ProcessWindows::OnDebugString
void OnDebugString(const std::string &string) override
Definition: ProcessWindows.cpp:813
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:119
DynamicLoaderWindowsDYLD.h
lldb_private::HostThread
Definition: HostThread.h:29
lldb_private::ProcessWindows::Terminate
static void Terminate()
Definition: ProcessWindows.cpp:108
lldb_private::ProcessWindows::GetSTDOUT
size_t GetSTDOUT(char *buf, size_t buf_size, Status &error) override
Get any available STDOUT.
Definition: ProcessWindows.cpp:125
lldb_private::ProcessWindows::WatchpointInfo
Definition: ProcessWindows.h:111
lldb_private::Process
Definition: Process.h:338
lldb_private::ProcessWindows::DoHalt
Status DoHalt(bool &caused_stop) override
Halts a running process.
Definition: ProcessWindows.cpp:261
lldb_private::ProcessWindows::IsAlive
bool IsAlive() override
Check if a process is still alive.
Definition: ProcessWindows.cpp:566
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:197
lldb_private::Module
Definition: Module.h:85
lldb_private::ProcessWindows::~ProcessWindows
~ProcessWindows()
Definition: ProcessWindows.cpp:123
lldb_private::ProcessWindows::GetImageInfoAddress
lldb::addr_t GetImageInfoAddress() override
Get the image information address for the current process.
Definition: ProcessWindows.cpp:614
lldb_private::MemoryRegionInfo
Definition: MemoryRegionInfo.h:21
lldb_private::ProcessWindows::OnExitProcess
void OnExitProcess(uint32_t exit_code) override
Definition: ProcessWindows.cpp:631
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:815
lldb_private::ProcessWindows::WatchpointInfo::read
bool read
Definition: ProcessWindows.h:115
lldb_private::ProcessWindows::GetWatchpointSupportInfo
Status GetWatchpointSupportInfo(uint32_t &num) override
Definition: ProcessWindows.cpp:840
lldb_private::ProcessWindows::EnableWatchpoint
Status EnableWatchpoint(Watchpoint *wp, bool notify=true) override
Definition: ProcessWindows.cpp:851
Process.h
lldb_private::ProcessWindows::WatchpointInfo::size
uint32_t size
Definition: ProcessWindows.h:114
lldb_private::ProcessWindows::DisableWatchpoint
Status DisableWatchpoint(Watchpoint *wp, bool notify=true) override
Definition: ProcessWindows.cpp:905
lldb_private::ProcessWindows::OnExitThread
void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override
Definition: ProcessWindows.cpp:784
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:135
lldb_private::ProcessWindows::DisableBreakpointSite
Status DisableBreakpointSite(BreakpointSite *bp_site) override
Definition: ProcessWindows.cpp:155
lldb_private::ProcessWindows::OnLoadDll
void OnLoadDll(const ModuleSpec &module_spec, lldb::addr_t module_addr) override
Definition: ProcessWindows.cpp:802
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::ProcessDebugger
Definition: ProcessDebugger.h:48
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:522
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:591
lldb_private::ProcessWindows::Initialize
static void Initialize()
Definition: ProcessWindows.cpp:96
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:81
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:624
lldb_private::Watchpoint
Definition: Watchpoint.h:24
ExceptionResult
ExceptionResult
Definition: ForwardDecl.h:16
lldb_private::ThreadList
Definition: ThreadList.h:26
lldb_private::ProcessWindows::DoGetMemoryRegionInfo
Status DoGetMemoryRegionInfo(lldb::addr_t vm_addr, MemoryRegionInfo &info) override
DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has removed non address bits from loa...
Definition: ProcessWindows.cpp:609
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:206
lldb_private::ProcessWindows::GetSTDERR
size_t GetSTDERR(char *buf, size_t buf_size, Status &error) override
Get any available STDERR.
Definition: ProcessWindows.cpp:130
lldb_private::ProcessWindows::OnCreateThread
void OnCreateThread(const HostThread &thread) override
Definition: ProcessWindows.cpp:764
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:352
lldb_private::ProcessWindows::DoDeallocateMemory
Status DoDeallocateMemory(lldb::addr_t ptr) override
Actually deallocate memory in the process.
Definition: ProcessWindows.cpp:605
lldb_private::ProcessAttachInfo
Definition: Process.h:113
lldb_private::ProcessWindows::DidLaunch
void DidLaunch() override
Called after launching a process.
Definition: ProcessWindows.cpp:269
lldb_private::ProcessWindows::GetSystemArchitecture
ArchSpec GetSystemArchitecture() override
Get the system architecture for this process.
Definition: ProcessWindows.cpp:580
lldb_private::ProcessWindows::DestroyRequiresHalt
bool DestroyRequiresHalt() override
Definition: ProcessWindows.h:69
lldb_private::ModuleSpec
Definition: ModuleSpec.h:27
lldb_private::ProcessWindows::OnDebuggerConnected
void OnDebuggerConnected(lldb::addr_t image_base) override
Definition: ProcessWindows.cpp:650
lldb_private::Status
Definition: Status.h:44
uint32_t
lldb_private::ProcessWindows::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition: ProcessWindows.h:35
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:118
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:508
lldb_private::ProcessWindows::DoDetach
Status DoDetach(bool keep_stopped) override
Detaches from a running or stopped process.
Definition: ProcessWindows.cpp:167
lldb_private::ProcessWindows::DoDestroy
Status DoDestroy() override
Definition: ProcessWindows.cpp:256
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:598
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:698
ProcessDebugger.h
lldb_private::ProcessWindows::GetPluginName
llvm::StringRef GetPluginName() override
Definition: ProcessWindows.h:48
lldb_private::ProcessWindows::WatchpointInfo::slot_id
uint32_t slot_id
Definition: ProcessWindows.h:112
lldb_private::DynamicLoaderWindowsDYLD
Definition: DynamicLoaderWindowsDYLD.h:19
lldb_private::ProcessWindows::ProcessWindows
ProcessWindows(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
Definition: ProcessWindows.cpp:116
lldb_private::ProcessWindows::WatchpointInfo::write
bool write
Definition: ProcessWindows.h:116
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:186
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86
lldb_private::ProcessWindows::WatchpointInfo::address
lldb::addr_t address
Definition: ProcessWindows.h:113
lldb_private::ProcessWindows::EnableBreakpointSite
Status EnableBreakpointSite(BreakpointSite *bp_site) override
Definition: ProcessWindows.cpp:141
lldb_private::ProcessWindows::OnUnloadDll
void OnUnloadDll(lldb::addr_t module_addr) override
Definition: ProcessWindows.cpp:808