LLDB mainline
NativeProcessWindows.h
Go to the documentation of this file.
1//===-- NativeProcessWindows.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_NativeProcessWindows_h_
10#define liblldb_NativeProcessWindows_h_
11
13#include "lldb/lldb-forward.h"
14
15#include "IDebugDelegate.h"
16#include "ProcessDebugger.h"
17
18namespace lldb_private {
19
20class HostProcess;
24
25using NativeDebugDelegateSP = std::shared_ptr<NativeDebugDelegate>;
26
27//------------------------------------------------------------------
28// NativeProcessWindows
29//------------------------------------------------------------------
31 public ProcessDebugger {
32
33public:
35 public:
37
38 llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
39 Launch(ProcessLaunchInfo &launch_info,
40 NativeDelegate &native_delegate) override;
41
42 llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
43 Attach(lldb::pid_t pid, NativeDelegate &native_delegate) override;
44
47 }
48 };
49
50 Status Resume(const ResumeActionList &resume_actions) override;
51
52 Status Halt() override;
53
54 Status Detach() override;
55
56 Status Signal(int signo) override;
57
58 Status Interrupt() override;
59
60 Status Kill() override;
61
62 Status IgnoreSignals(llvm::ArrayRef<int> signals) override;
63
65 MemoryRegionInfo &range_info) override;
66
67 Status ReadMemory(lldb::addr_t addr, void *buf, size_t size,
68 size_t &bytes_read) override;
69
70 Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
71 size_t &bytes_written) override;
72
73 llvm::Expected<lldb::addr_t> AllocateMemory(size_t size,
74 uint32_t permissions) override;
75
76 llvm::Error DeallocateMemory(lldb::addr_t addr) override;
77
79
80 bool IsAlive() const override;
81
82 size_t UpdateThreads() override;
83
84 const ArchSpec &GetArchitecture() const override { return m_arch; }
85
86 void SetArchitecture(const ArchSpec &arch_spec) { m_arch = arch_spec; }
87
88 Status SetBreakpoint(lldb::addr_t addr, uint32_t size,
89 bool hardware) override;
90
91 Status RemoveBreakpoint(lldb::addr_t addr, bool hardware = false) override;
92
93 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
94 GetAuxvData() const override;
95
96 Status GetLoadedModuleFileSpec(const char *module_path,
97 FileSpec &file_spec) override;
98
99 Status GetFileLoadAddress(const llvm::StringRef &file_name,
100 lldb::addr_t &load_addr) override;
101
102 llvm::Expected<std::vector<LoadedLibraryInfo>> GetLoadedLibraries() override;
103
104 bool HasPendingLibraryEvents() override;
105
106 // ProcessDebugger Overrides
107 void OnExitProcess(uint32_t exit_code) override;
108 void OnDebuggerConnected(lldb::addr_t image_base) override;
109 ExceptionResult OnDebugException(bool first_chance,
110 const ExceptionRecord &record) override;
111 void OnCreateThread(const HostThread &thread) override;
112 void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override;
113 void OnLoadDll(const ModuleSpec &module_spec,
114 lldb::addr_t module_addr) override;
115 void OnUnloadDll(lldb::addr_t module_addr) override;
116
117protected:
119
120 llvm::Expected<llvm::ArrayRef<uint8_t>>
121 GetSoftwareBreakpointTrapOpcode(size_t size_hint) override;
122
123 size_t GetSoftwareBreakpointPCOffset() override;
124
126
127 void StopThread(lldb::tid_t thread_id, lldb::StopReason reason,
128 std::string description = "");
129
131 lldb::StopReason reason,
132 std::string description = "");
133
134private:
136
138 llvm::Error &E);
139
140 NativeProcessWindows(lldb::pid_t pid, int terminal_fd,
141 NativeDelegate &delegate, llvm::Error &E);
142
145 ExceptionResult HandleGenericException(bool first_chance,
146 const ExceptionRecord &record);
147
149 std::map<lldb_private::FileSpec, lldb::addr_t> m_loaded_modules;
150
151 /// Set whenever an OS DLL load/unload event has been seen since the last stop
152 /// reply.
154
155 /// Whether we've seen the loader breakpoint that fires once per process at
156 /// launch / attach.
158};
159
160//------------------------------------------------------------------
161// NativeDebugDelegate
162//------------------------------------------------------------------
164public:
166
167 void OnExitProcess(uint32_t exit_code) override {
168 m_process.OnExitProcess(exit_code);
169 }
170
171 void OnDebuggerConnected(lldb::addr_t image_base) override {
172 m_process.OnDebuggerConnected(image_base);
173 }
174
176 const ExceptionRecord &record) override {
177 return m_process.OnDebugException(first_chance, record);
178 }
179
180 void OnCreateThread(const HostThread &thread) override {
181 m_process.OnCreateThread(thread);
182 }
183
184 void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override {
185 m_process.OnExitThread(thread_id, exit_code);
186 }
187
188 void OnLoadDll(const lldb_private::ModuleSpec &module_spec,
189 lldb::addr_t module_addr) override {
190 m_process.OnLoadDll(module_spec, module_addr);
191 }
192
193 void OnUnloadDll(lldb::addr_t module_addr) override {
194 m_process.OnUnloadDll(module_addr);
195 }
196
197 void OnDebugString(lldb::addr_t debug_string_addr, bool is_unicode,
198 uint16_t length_lower_word) override {
199 m_process.OnDebugString(debug_string_addr, is_unicode, length_lower_word);
200 }
201
202 void OnDebuggerError(const Status &error, uint32_t type) override {
203 return m_process.OnDebuggerError(error, type);
204 }
205
206private:
208};
209
210} // namespace lldb_private
211
212#endif // #ifndef liblldb_NativeProcessWindows_h_
static llvm::raw_ostream & error(Stream &strm)
ExceptionResult
Definition ForwardDecl.h:16
An architecture specification class.
Definition ArchSpec.h:32
A file utility class.
Definition FileSpec.h:57
void OnLoadDll(const lldb_private::ModuleSpec &module_spec, lldb::addr_t module_addr) override
void OnExitProcess(uint32_t exit_code) override
void OnDebugString(lldb::addr_t debug_string_addr, bool is_unicode, uint16_t length_lower_word) override
void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override
void OnDebuggerError(const Status &error, uint32_t type) override
ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record) override
void OnUnloadDll(lldb::addr_t module_addr) override
void OnCreateThread(const HostThread &thread) override
NativeDebugDelegate(NativeProcessWindows &process)
void OnDebuggerConnected(lldb::addr_t image_base) override
NativeProcessProtocol(lldb::pid_t pid, int terminal_fd, NativeDelegate &delegate)
Extension
Extension flag constants, returned by Manager::GetSupportedExtensions() and passed to SetEnabledExten...
llvm::Expected< std::unique_ptr< NativeProcessProtocol > > Launch(ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate) override
Launch a process for debugging.
llvm::Expected< std::unique_ptr< NativeProcessProtocol > > Attach(lldb::pid_t pid, NativeDelegate &native_delegate) override
Attach to an existing process.
Extension GetSupportedExtensions() const override
Get the bitmask of extensions supported by this process plugin.
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) override
ExceptionResult HandleBreakpointException(const ExceptionRecord &record)
llvm::Error DeallocateMemory(lldb::addr_t addr) override
Status Resume(const ResumeActionList &resume_actions) override
void OnCreateThread(const HostThread &thread) override
void OnExitProcess(uint32_t exit_code) override
Status GetLoadedModuleFileSpec(const char *module_path, FileSpec &file_spec) override
llvm::Expected< llvm::ArrayRef< uint8_t > > GetSoftwareBreakpointTrapOpcode(size_t size_hint) override
void OnDebuggerConnected(lldb::addr_t image_base) override
Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override
NativeProcessWindows(ProcessLaunchInfo &launch_info, NativeDelegate &delegate, llvm::Error &E)
Status SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware) override
ExceptionResult HandleGenericException(bool first_chance, const ExceptionRecord &record)
void SetArchitecture(const ArchSpec &arch_spec)
ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record) override
size_t GetSoftwareBreakpointPCOffset() override
Return the offset of the PC relative to the software breakpoint that was hit.
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > GetAuxvData() const override
void OnUnloadDll(lldb::addr_t module_addr) override
Status GetFileLoadAddress(const llvm::StringRef &file_name, lldb::addr_t &load_addr) override
NativeThreadWindows * GetThreadByID(lldb::tid_t thread_id)
Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) override
void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override
llvm::Expected< lldb::addr_t > AllocateMemory(size_t size, uint32_t permissions) override
Status Signal(int signo) override
Sends a process a UNIX signal signal.
Status RemoveBreakpoint(lldb::addr_t addr, bool hardware=false) override
const ArchSpec & GetArchitecture() const override
void SetStopReasonForThread(NativeThreadWindows &thread, lldb::StopReason reason, std::string description="")
Status Interrupt() override
Tells a process to interrupt all operations as if by a Ctrl-C.
void OnLoadDll(const ModuleSpec &module_spec, lldb::addr_t module_addr) override
void StopThread(lldb::tid_t thread_id, lldb::StopReason reason, std::string description="")
ExceptionResult HandleSingleStepException(const ExceptionRecord &record)
bool m_initial_stop_seen
Whether we've seen the loader breakpoint that fires once per process at launch / attach.
bool m_pending_library_events
Set whenever an OS DLL load/unload event has been seen since the last stop reply.
llvm::Expected< std::vector< LoadedLibraryInfo > > GetLoadedLibraries() override
Return the currently loaded libraries of the target in the qXfer:libraries:read form (generic name + ...
lldb::addr_t GetSharedLibraryInfoAddress() override
Status IgnoreSignals(llvm::ArrayRef< int > signals) override
std::map< lldb_private::FileSpec, lldb::addr_t > m_loaded_modules
An error handling class.
Definition Status.h:118
A class that represents a running process on the host machine.
std::shared_ptr< NativeDebugDelegate > NativeDebugDelegateSP
uint64_t pid_t
Definition lldb-types.h:83
uint64_t addr_t
Definition lldb-types.h:80
StopReason
Thread stop reasons.
uint64_t tid_t
Definition lldb-types.h:84