Skip to content

Commit 66bdca4

Browse files
Updated after building lldb-server
1 parent 46d7652 commit 66bdca4

File tree

5 files changed

+89
-40
lines changed

5 files changed

+89
-40
lines changed

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ endif()
292292

293293
# Figure out if lldb could use lldb-server. If so, then we'll
294294
# ensure we build lldb-server when an lldb target is being built.
295-
if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD|OpenBSD|Windows")
295+
if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD|OpenBSD|Windows|AIX")
296296
set(LLDB_CAN_USE_LLDB_SERVER ON)
297297
else()
298298
set(LLDB_CAN_USE_LLDB_SERVER OFF)

lldb/source/Plugins/Process/AIX/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ add_lldb_library(lldbPluginProcessAIX
1212
LINK_COMPONENTS
1313
Support
1414
)
15+
16+
target_compile_definitions(lldbPluginProcessAIX PRIVATE "-D_ALL_SOURCE")

lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "NativeProcessAIX.h"
10+
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
1011
#include "lldb/Host/Host.h"
1112
#include "lldb/Host/HostProcess.h"
1213
#include "lldb/Host/ProcessLaunchInfo.h"
14+
#include "lldb/Host/posix/ProcessLauncherPosixFork.h"
1315
#include "lldb/Symbol/ObjectFile.h"
1416
#include "lldb/Utility/Log.h"
1517
#include "lldb/Utility/State.h"
@@ -21,6 +23,7 @@
2123
#include <cstring>
2224
#include <sstream>
2325
#include <string>
26+
#include <sys/ptrace.h>
2427
#include <unistd.h>
2528

2629
using namespace lldb;
@@ -34,17 +37,17 @@ static_assert(sizeof(long) >= k_ptrace_word_size,
3437

3538
// Simple helper function to ensure flags are enabled on the given file
3639
// descriptor.
37-
static llvm::Error EnsureFDFlags(int fd, int flags) {
38-
Error error;
40+
static Status EnsureFDFlags(int fd, int flags) {
41+
Status error;
3942

4043
int status = fcntl(fd, F_GETFL);
4144
if (status == -1) {
42-
error = errorCodeToError(errnoAsErrorCode());
45+
error = Status::FromErrno();
4346
return error;
4447
}
4548

4649
if (fcntl(fd, F_SETFL, status | flags) == -1) {
47-
error = errorCodeToError(errnoAsErrorCode());
50+
error = Status::FromErrno();
4851
return error;
4952
}
5053

@@ -123,6 +126,10 @@ NativeProcessAIX::Manager::Attach(
123126
pid, -1, native_delegate, Info.GetArchitecture(), *this, *tids_or));
124127
}
125128

129+
lldb::addr_t NativeProcessAIX::GetSharedLibraryInfoAddress() {
130+
return LLDB_INVALID_ADDRESS;
131+
}
132+
126133
NativeProcessAIX::Extension
127134
NativeProcessAIX::Manager::GetSupportedExtensions() const {
128135
NativeProcessAIX::Extension supported = {};
@@ -155,7 +162,8 @@ NativeProcessAIX::NativeProcessAIX(::pid_t pid, int terminal_fd,
155162

156163
llvm::Expected<std::vector<::pid_t>> NativeProcessAIX::Attach(::pid_t pid) {
157164

158-
Error status;
165+
Log *log = GetLog(POSIXLog::Process);
166+
Status status;
159167
if ((status = PtraceWrapper(PT_ATTACH, pid)).Fail()) {
160168
return errorCodeToError(errnoAsErrorCode());
161169
}
@@ -172,59 +180,76 @@ llvm::Expected<std::vector<::pid_t>> NativeProcessAIX::Attach(::pid_t pid) {
172180
return std::move(tids);
173181
}
174182

175-
void NativeProcessAIX::MonitorSIGTRAP(const WaitStatus status,
176-
NativeThreadAIX &thread) {}
177-
178-
void NativeProcessAIX::MonitorBreakpoint(NativeThreadAIX &thread) {}
179-
180183
bool NativeProcessAIX::SupportHardwareSingleStepping() const { return false; }
181184

182185
Status NativeProcessAIX::Resume(const ResumeActionList &resume_actions) {
183186
return Status();
184187
}
185188

186-
Error NativeProcessAIX::Halt() {
187-
Error error;
189+
Status NativeProcessAIX::Halt() {
190+
Status error;
188191
return error;
189192
}
190193

191-
Error NativeProcessAIX::Detach() {
192-
Error error;
194+
Status NativeProcessAIX::Detach() {
195+
Status error;
193196
return error;
194197
}
195198

196-
Error NativeProcessAIX::Signal(int signo) {
197-
Error error;
199+
Status NativeProcessAIX::Signal(int signo) {
200+
Status error;
198201
return error;
199202
}
200203

201-
Error NativeProcessAIX::Interrupt() { return Status(); }
204+
Status NativeProcessAIX::Interrupt() { return Status(); }
202205

203-
Error NativeProcessAIX::Kill() {
204-
Error error;
206+
Status NativeProcessAIX::Kill() {
207+
Status error;
205208
return error;
206209
}
207210

208-
Error NativeProcessAIX::SetBreakpoint(lldb::addr_t addr, uint32_t size,
209-
bool hardware) {
211+
Status NativeProcessAIX::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
212+
size_t &bytes_read) {
213+
return Status();
214+
}
215+
216+
Status NativeProcessAIX::WriteMemory(lldb::addr_t addr, const void *buf,
217+
size_t size, size_t &bytes_written) {
218+
return Status();
219+
}
220+
221+
size_t NativeProcessAIX::UpdateThreads() {
222+
// The NativeProcessAIX monitoring threads are always up to date with
223+
// respect to thread state and they keep the thread list populated properly.
224+
// All this method needs to do is return the thread count.
225+
return m_threads.size();
226+
}
227+
228+
Status NativeProcessAIX::GetLoadedModuleFileSpec(const char *module_path,
229+
FileSpec &file_spec) {
230+
return Status();
231+
}
232+
233+
Status NativeProcessAIX::SetBreakpoint(lldb::addr_t addr, uint32_t size,
234+
bool hardware) {
210235
if (hardware)
211236
return SetHardwareBreakpoint(addr, size);
212237
else
213238
return SetSoftwareBreakpoint(addr, size);
214239
}
215240

216-
Error NativeProcessAIX::RemoveBreakpoint(lldb::addr_t addr, bool hardware) {
241+
Status NativeProcessAIX::RemoveBreakpoint(lldb::addr_t addr, bool hardware) {
217242
if (hardware)
218243
return RemoveHardwareBreakpoint(addr);
219244
else
220245
return NativeProcessProtocol::RemoveBreakpoint(addr);
221246
}
222247

223-
int8_t NativeProcessAIX::GetSignalInfo(WaitStatus wstatus) const {
224-
return wstatus.status;
248+
Status NativeProcessAIX::GetSignalInfo(lldb::tid_t tid, void *siginfo) const {
249+
return Status();
225250
}
226251

227-
Error NativeProcessAIX::Detach(lldb::tid_t tid) {
252+
Status NativeProcessAIX::Detach(lldb::tid_t tid) {
228253
if (tid == LLDB_INVALID_THREAD_ID)
229254
return Status();
230255

@@ -233,10 +258,10 @@ Error NativeProcessAIX::Detach(lldb::tid_t tid) {
233258

234259
// Wrapper for ptrace to catch errors and log calls. Note that ptrace sets
235260
// errno on error because -1 can be a valid result (i.e. for PTRACE_PEEK*)
236-
Error NativeProcessAIX::PtraceWrapper(int req, lldb::pid_t pid, void *addr,
237-
void *data, size_t data_size,
238-
long *result) {
239-
Error error;
261+
Status NativeProcessAIX::PtraceWrapper(int req, lldb::pid_t pid, void *addr,
262+
void *data, size_t data_size,
263+
long *result) {
264+
Status error;
240265
long int ret;
241266

242267
Log *log = GetLog(POSIXLog::Ptrace);
@@ -252,7 +277,7 @@ Error NativeProcessAIX::PtraceWrapper(int req, lldb::pid_t pid, void *addr,
252277
}
253278

254279
if (errno) {
255-
error = errorCodeToError(errnoAsErrorCode());
280+
error = Status::FromErrno();
256281
ret = -1;
257282
}
258283

lldb/source/Plugins/Process/AIX/NativeProcessAIX.h

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "Plugins/Process/Utility/NativeProcessSoftwareSingleStep.h"
1313
#include "lldb/Host/Debug.h"
1414
#include "lldb/Host/common/NativeProcessProtocol.h"
15+
#include "lldb/Host/linux/Support.h"
1516
#include "lldb/Target/MemoryRegionInfo.h"
1617
#include "lldb/Utility/ArchSpec.h"
1718
#include "lldb/Utility/FileSpec.h"
@@ -20,9 +21,7 @@
2021
#include <csignal>
2122
#include <unordered_set>
2223

23-
namespace lldb_private {
24-
25-
namespace process_aix {
24+
namespace lldb_private::process_aix {
2625
/// \class NativeProcessAIX
2726
/// Manages communication with the inferior (debugee) process.
2827
///
@@ -78,20 +77,44 @@ class NativeProcessAIX : public NativeProcessProtocol {
7877

7978
Status Kill() override;
8079

80+
lldb::addr_t GetSharedLibraryInfoAddress() override;
81+
82+
Status ReadMemory(lldb::addr_t addr, void *buf, size_t size,
83+
size_t &bytes_read) override;
84+
85+
Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
86+
size_t &bytes_written) override;
87+
88+
size_t UpdateThreads() override;
89+
8190
const ArchSpec &GetArchitecture() const override { return m_arch; }
8291

8392
Status SetBreakpoint(lldb::addr_t addr, uint32_t size,
8493
bool hardware) override;
8594

8695
Status RemoveBreakpoint(lldb::addr_t addr, bool hardware = false) override;
8796

97+
Status GetLoadedModuleFileSpec(const char *module_path,
98+
FileSpec &file_spec) override;
99+
100+
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
101+
GetAuxvData() const override {
102+
return getProcFile(GetID(), "auxv");
103+
}
104+
88105
Status GetFileLoadAddress(const llvm::StringRef &file_name,
89106
lldb::addr_t &load_addr) override;
90107

91108
static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
92109
void *data = nullptr, size_t data_size = 0,
93110
long *result = nullptr);
94111

112+
bool SupportHardwareSingleStepping() const;
113+
114+
/// Writes a siginfo_t structure corresponding to the given thread ID to the
115+
/// memory region pointed to by \p siginfo.
116+
Status GetSignalInfo(lldb::tid_t tid, void *siginfo) const;
117+
95118
private:
96119
Manager &m_manager;
97120
ArchSpec m_arch;
@@ -104,16 +127,11 @@ class NativeProcessAIX : public NativeProcessProtocol {
104127
// Returns a list of process threads that we have attached to.
105128
static llvm::Expected<std::vector<::pid_t>> Attach(::pid_t pid);
106129

107-
void MonitorSIGTRAP(const WaitStatus status, NativeThreadAIX &thread);
108-
109-
void MonitorBreakpoint(NativeThreadAIX &thread);
110-
111130
Status Detach(lldb::tid_t tid);
112131

113132
void SigchldHandler();
114133
};
115134

116-
} // namespace process_aix
117-
} // namespace lldb_private
135+
} // namespace lldb_private::process_aix
118136

119137
#endif // #ifndef LIBLLDB_NATIVEPROCESSAIX_H_

lldb/tools/lldb-server/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
88
list(APPEND LLDB_PLUGINS lldbPluginProcessLinux)
99
endif()
1010

11+
if(CMAKE_SYSTEM_NAME MATCHES "AIX")
12+
list(APPEND LLDB_PLUGINS lldbPluginProcessAIX)
13+
endif()
14+
1115
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
1216
list(APPEND LLDB_PLUGINS lldbPluginProcessFreeBSD)
1317
endif()

0 commit comments

Comments
 (0)