This PR is in reference to porting LLDB on AIX. Link to discussions on llvm discourse and github: 1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640 2. https://github.com/llvm/llvm-project/issues/101657 The complete changes for porting are present in this draft PR: https://github.com/llvm/llvm-project/pull/102601 - Added testcase for `GetProgramFileSpec()` & `FindProcesses()` - Added changes to get the host information for AIX (info like FindProcessesImpl() GetProgramFileSpec()), continue from the PR https://github.com/llvm/llvm-project/pull/134354
37 lines
1.3 KiB
C++
37 lines
1.3 KiB
C++
//===-- HostInfoAIX.cpp -------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "lldb/Host/aix/HostInfoAIX.h"
|
|
#include "lldb/Host/posix/Support.h"
|
|
#include <sys/procfs.h>
|
|
|
|
using namespace lldb_private;
|
|
|
|
void HostInfoAIX::Initialize(SharedLibraryDirectoryHelper *helper) {
|
|
HostInfoPosix::Initialize(helper);
|
|
}
|
|
|
|
void HostInfoAIX::Terminate() { HostInfoBase::Terminate(); }
|
|
|
|
FileSpec HostInfoAIX::GetProgramFileSpec() {
|
|
static FileSpec g_program_filespec;
|
|
struct psinfo psinfoData;
|
|
auto BufferOrError = getProcFile(getpid(), "psinfo");
|
|
if (BufferOrError) {
|
|
std::unique_ptr<llvm::MemoryBuffer> PsinfoBuffer =
|
|
std::move(*BufferOrError);
|
|
memcpy(&psinfoData, PsinfoBuffer->getBufferStart(), sizeof(psinfoData));
|
|
llvm::StringRef exe_path(
|
|
psinfoData.pr_psargs,
|
|
strnlen(psinfoData.pr_psargs, sizeof(psinfoData.pr_psargs)));
|
|
if (!exe_path.empty())
|
|
g_program_filespec.SetFile(exe_path, FileSpec::Style::native);
|
|
}
|
|
return g_program_filespec;
|
|
}
|