Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/lldb/source/Host/aix/HostInfoAIX.cpp
213799 views
1
//===-- HostInfoAIX.cpp -------------------------------------------------===//
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
#include "lldb/Host/aix/HostInfoAIX.h"
10
#include "lldb/Host/posix/Support.h"
11
#include <sys/procfs.h>
12
13
using namespace lldb_private;
14
15
void HostInfoAIX::Initialize(SharedLibraryDirectoryHelper *helper) {
16
HostInfoPosix::Initialize(helper);
17
}
18
19
void HostInfoAIX::Terminate() { HostInfoBase::Terminate(); }
20
21
FileSpec HostInfoAIX::GetProgramFileSpec() {
22
static FileSpec g_program_filespec;
23
struct psinfo psinfoData;
24
auto BufferOrError = getProcFile(getpid(), "psinfo");
25
if (BufferOrError) {
26
std::unique_ptr<llvm::MemoryBuffer> PsinfoBuffer =
27
std::move(*BufferOrError);
28
memcpy(&psinfoData, PsinfoBuffer->getBufferStart(), sizeof(psinfoData));
29
llvm::StringRef exe_path(
30
psinfoData.pr_psargs,
31
strnlen(psinfoData.pr_psargs, sizeof(psinfoData.pr_psargs)));
32
if (!exe_path.empty())
33
g_program_filespec.SetFile(exe_path, FileSpec::Style::native);
34
}
35
return g_program_filespec;
36
}
37
38