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 
30  static void Initialize();
31 
32  static void Terminate();
33 
35 
36  static const char *GetPluginDescriptionStatic();
37 
38  // Constructors and destructors
39  ProcessWindows(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp);
40 
42 
43  size_t GetSTDOUT(char *buf, size_t buf_size, Status &error) override;
44  size_t GetSTDERR(char *buf, size_t buf_size, Status &error) override;
45  size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) override;
46 
47  // lldb_private::Process overrides
48  ConstString GetPluginName() override;
49  uint32_t GetPluginVersion() 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 UpdateThreadList(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_
Class that manages the actual breakpoint that will be inserted into the running program.
std::vector< lldb::break_id_t > m_watchpoint_ids
ProcessWindows(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
void OnDebuggerConnected(lldb::addr_t image_base) override
static lldb_private::ConstString GetPluginNameStatic()
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
A class that represents a running process on the host machine.
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.
void OnDebuggerError(const Status &error, uint32_t type) override
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.
Status EnableBreakpointSite(BreakpointSite *bp_site) override
bool IsAlive() override
Check if a process is still alive.
void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override
A file utility class.
Definition: FileSpec.h:56
void DidLaunch() override
Called after launching a process.
size_t GetSTDOUT(char *buf, size_t buf_size, Status &error) override
Get any available STDOUT.
An architecture specification class.
Definition: ArchSpec.h:33
bool DestroyRequiresHalt() override
ConstString GetPluginName() override
Status DoDeallocateMemory(lldb::addr_t ptr) override
Actually deallocate memory in the process.
Status DoDetach(bool keep_stopped) override
Detaches from a running or stopped process.
Status GetWatchpointSupportInfo(uint32_t &num) override
Status DoResume() override
Resumes all of a process&#39;s threads as configured using the Thread run control functions.
lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, Status &error) override
Actually allocate memory in the process.
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *)
Status GetMemoryRegionInfo(lldb::addr_t vm_addr, MemoryRegionInfo &info) override
Locate the memory region that contains load_addr.
Status DoHalt(bool &caused_stop) override
Halts a running process.
lldb::addr_t GetImageInfoAddress() override
Get the image information address for the current process.
Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override
Launch a new process.
size_t GetSTDERR(char *buf, size_t buf_size, Status &error) override
Get any available STDERR.
void OnUnloadDll(lldb::addr_t module_addr) override
void OnLoadDll(const ModuleSpec &module_spec, lldb::addr_t module_addr) override
static llvm::raw_ostream & error(Stream &strm)
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:75
void OnCreateThread(const HostThread &thread) override
DynamicLoaderWindowsDYLD * GetDynamicLoader() override
Get the dynamic loader plug-in for this process.
uint64_t tid_t
Definition: lldb-types.h:86
ExceptionResult
Definition: ForwardDecl.h:16
A plug-in interface definition class for debugging a process.
Definition: Process.h:362
std::map< lldb::break_id_t, WatchpointInfo > m_watchpoints
size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) override
Puts data into this process&#39;s STDIN.
void OnDebugString(const std::string &string) override
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
Status DisableWatchpoint(Watchpoint *wp, bool notify=true) override
uint32_t GetPluginVersion() override
bool UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override
Status DisableBreakpointSite(BreakpointSite *bp_site) override
uint64_t addr_t
Definition: lldb-types.h:83
A uniqued constant string class.
Definition: ConstString.h:40
void OnExitProcess(uint32_t exit_code) override
Status EnableWatchpoint(Watchpoint *wp, bool notify=true) override
uint64_t pid_t
Definition: lldb-types.h:85
ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record) override
void DidAttach(lldb_private::ArchSpec &arch_spec) override
Called after attaching a process.
static const char * GetPluginDescriptionStatic()
Status DoAttachToProcessWithID(lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info) override
Attach to an existing process using a process ID.
An error handling class.
Definition: Status.h:44