LLDB mainline
HostInfoAIX.cpp
Go to the documentation of this file.
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
11#include <sys/procfs.h>
12
13using namespace lldb_private;
14
18
20
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}
A file utility class.
Definition FileSpec.h:57
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition FileSpec.cpp:174
static FileSpec GetProgramFileSpec()
static void Initialize(SharedLibraryDirectoryHelper *helper=nullptr)
void(FileSpec &this_file) SharedLibraryDirectoryHelper
A helper function for determining the liblldb location.
static void Initialize(SharedLibraryDirectoryHelper *helper=nullptr)
A class that represents a running process on the host machine.
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getProcFile(::pid_t pid, ::pid_t tid, const llvm::Twine &file)