LLDB  mainline
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 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_Plugins_Process_Windows_Common_ProcessWindows_H_
10 #define liblldb_Plugins_Process_Windows_Common_ProcessWindows_H_
12 #include "lldb/Target/Process.h"
13 #include "lldb/Utility/Status.h"
14 #include "lldb/lldb-forward.h"
16 #include "llvm/Support/Mutex.h"
18 #include "IDebugDelegate.h"
21 namespace lldb_private {
23 class HostProcess;
24 class ProcessWindowsData;
26 class ProcessWindows : public Process, public IDebugDelegate {
27 public:
28  // Static functions.
29  static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
30  lldb::ListenerSP listener_sp,
31  const FileSpec *);
33  static void Initialize();
35  static void Terminate();
39  static const char *GetPluginDescriptionStatic();
41  // Constructors and destructors
42  ProcessWindows(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp);
46  size_t GetSTDOUT(char *buf, size_t buf_size, Status &error) override;
47  size_t GetSTDERR(char *buf, size_t buf_size, Status &error) override;
48  size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) override;
50  // lldb_private::Process overrides
51  ConstString GetPluginName() override;
52  uint32_t GetPluginVersion() override;
54  Status EnableBreakpointSite(BreakpointSite *bp_site) override;
55  Status DisableBreakpointSite(BreakpointSite *bp_site) override;
57  Status DoDetach(bool keep_stopped) override;
58  Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override;
60  lldb::pid_t pid,
61  const lldb_private::ProcessAttachInfo &attach_info) override;
62  Status DoResume() override;
63  Status DoDestroy() override;
64  Status DoHalt(bool &caused_stop) override;
66  void DidLaunch() override;
67  void DidAttach(lldb_private::ArchSpec &arch_spec) override;
69  void RefreshStateAfterStop() override;
71  bool CanDebug(lldb::TargetSP target_sp,
72  bool plugin_specified_by_name) override;
73  bool DestroyRequiresHalt() override { return false; }
74  bool UpdateThreadList(ThreadList &old_thread_list,
75  ThreadList &new_thread_list) override;
76  bool IsAlive() override;
78  size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
79  Status &error) override;
80  size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
81  Status &error) override;
82  lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions,
83  Status &error) override;
86  MemoryRegionInfo &info) override;
92  // IDebugDelegate overrides.
93  void OnExitProcess(uint32_t exit_code) override;
94  void OnDebuggerConnected(lldb::addr_t image_base) override;
95  ExceptionResult OnDebugException(bool first_chance,
96  const ExceptionRecord &record) override;
97  void OnCreateThread(const HostThread &thread) override;
98  void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override;
99  void OnLoadDll(const ModuleSpec &module_spec,
100  lldb::addr_t module_addr) override;
101  void OnUnloadDll(lldb::addr_t module_addr) override;
102  void OnDebugString(const std::string &string) override;
103  void OnDebuggerError(const Status &error, uint32_t type) override;
105 private:
106  Status WaitForDebuggerConnection(DebuggerThreadSP debugger,
107  HostProcess &process);
109  // These decode the page protection bits.
110  static bool IsPageReadable(uint32_t protect);
111  static bool IsPageWritable(uint32_t protect);
112  static bool IsPageExecutable(uint32_t protect);
114  llvm::sys::Mutex m_mutex;
115  std::unique_ptr<ProcessWindowsData> m_session_data;
116 };
117 }
119 #endif // liblldb_Plugins_Process_Windows_Common_ProcessWindows_H_
Class that manages the actual breakpoint that will be inserted into the running program.
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.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
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:55
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:32
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 DoResume() override
Resumes all of a process&#39;s threads as configured using the Thread run control functions.
std::shared_ptr< DebuggerThread > DebuggerThreadSP
Definition: ForwardDecl.h:36
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
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:109
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
Definition: ForwardDecl.h:16
A plug-in interface definition class for debugging a process.
Definition: Process.h:353
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.
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:38
void OnExitProcess(uint32_t exit_code) 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