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;
21class NativeProcessWindows;
22class NativeThreadWindows;
23class NativeDebugDelegate;
24
25typedef std::shared_ptr<NativeDebugDelegate> NativeDebugDelegateSP;
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 };
45
46 Status Resume(const ResumeActionList &resume_actions) override;
47
48 Status Halt() override;
49
50 Status Detach() override;
51
52 Status Signal(int signo) override;
53
54 Status Interrupt() override;
55
56 Status Kill() override;
57
58 Status IgnoreSignals(llvm::ArrayRef<int> signals) override;
59
61 MemoryRegionInfo &range_info) override;
62
63 Status ReadMemory(lldb::addr_t addr, void *buf, size_t size,
64 size_t &bytes_read) override;
65
66 Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
67 size_t &bytes_written) override;
68
69 llvm::Expected<lldb::addr_t> AllocateMemory(size_t size,
70 uint32_t permissions) override;
71
72 llvm::Error DeallocateMemory(lldb::addr_t addr) override;
73
75
76 bool IsAlive() const override;
77
78 size_t UpdateThreads() override;
79
80 const ArchSpec &GetArchitecture() const override { return m_arch; }
81
82 void SetArchitecture(const ArchSpec &arch_spec) { m_arch = arch_spec; }
83
84 Status SetBreakpoint(lldb::addr_t addr, uint32_t size,
85 bool hardware) override;
86
87 Status RemoveBreakpoint(lldb::addr_t addr, bool hardware = false) override;
88
89 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
90 GetAuxvData() const override;
91
92 Status GetLoadedModuleFileSpec(const char *module_path,
93 FileSpec &file_spec) override;
94
95 Status GetFileLoadAddress(const llvm::StringRef &file_name,
96 lldb::addr_t &load_addr) override;
97
98 // ProcessDebugger Overrides
99 void OnExitProcess(uint32_t exit_code) override;
100 void OnDebuggerConnected(lldb::addr_t image_base) override;
101 ExceptionResult OnDebugException(bool first_chance,
102 const ExceptionRecord &record) override;
103 void OnCreateThread(const HostThread &thread) override;
104 void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override;
105 void OnLoadDll(const ModuleSpec &module_spec,
106 lldb::addr_t module_addr) override;
107 void OnUnloadDll(lldb::addr_t module_addr) override;
108
109protected:
111
112 llvm::Expected<llvm::ArrayRef<uint8_t>>
113 GetSoftwareBreakpointTrapOpcode(size_t size_hint) override;
114
115 size_t GetSoftwareBreakpointPCOffset() override;
116
118
119 void StopThread(lldb::tid_t thread_id, lldb::StopReason reason,
120 std::string description = "");
121
123 lldb::StopReason reason,
124 std::string description = "");
125
126private:
128
130 llvm::Error &E);
131
132 NativeProcessWindows(lldb::pid_t pid, int terminal_fd,
133 NativeDelegate &delegate, llvm::Error &E);
134
136 std::map<lldb_private::FileSpec, lldb::addr_t> m_loaded_modules;
137};
138
139//------------------------------------------------------------------
140// NativeDebugDelegate
141//------------------------------------------------------------------
143public:
145
146 void OnExitProcess(uint32_t exit_code) override {
147 m_process.OnExitProcess(exit_code);
148 }
149
150 void OnDebuggerConnected(lldb::addr_t image_base) override {
151 m_process.OnDebuggerConnected(image_base);
152 }
153
155 const ExceptionRecord &record) override {
156 return m_process.OnDebugException(first_chance, record);
157 }
158
159 void OnCreateThread(const HostThread &thread) override {
161 }
162
163 void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override {
164 m_process.OnExitThread(thread_id, exit_code);
165 }
166
167 void OnLoadDll(const lldb_private::ModuleSpec &module_spec,
168 lldb::addr_t module_addr) override {
169 m_process.OnLoadDll(module_spec, module_addr);
170 }
171
172 void OnUnloadDll(lldb::addr_t module_addr) override {
173 m_process.OnUnloadDll(module_addr);
174 }
175
176 void OnDebugString(const std::string &string) override {
177 m_process.OnDebugString(string);
178 }
179
180 void OnDebuggerError(const Status &error, uint32_t type) override {
181 return m_process.OnDebuggerError(error, type);
182 }
183
184private:
186};
187
188} // namespace lldb_private
189
190#endif // #ifndef liblldb_NativeProcessWindows_h_
static llvm::raw_ostream & error(Stream &strm)
ExceptionResult
Definition: ForwardDecl.h:16
An architecture specification class.
Definition: ArchSpec.h:31
A file utility class.
Definition: FileSpec.h:56
void OnLoadDll(const lldb_private::ModuleSpec &module_spec, lldb::addr_t module_addr) override
void OnExitProcess(uint32_t exit_code) override
void OnDebugString(const std::string &string) 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
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.
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) override
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
Status SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware) override
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
bool FindSoftwareBreakpoint(lldb::addr_t addr)
void StopThread(lldb::tid_t thread_id, lldb::StopReason reason, std::string description="")
lldb::addr_t GetSharedLibraryInfoAddress() override
Status IgnoreSignals(llvm::ArrayRef< int > signals) override
std::map< lldb_private::FileSpec, lldb::addr_t > m_loaded_modules
virtual void OnDebuggerError(const Status &error, uint32_t type)
virtual void OnDebugString(const std::string &string)
An error handling class.
Definition: Status.h:44
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