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
16
18
20 static FileSpec g_program_filespec;
21 struct psinfo psinfoData;
22 auto BufferOrError = getProcFile(getpid(), "psinfo");
23 if (BufferOrError) {
24 std::unique_ptr<llvm::MemoryBuffer> PsinfoBuffer =
25 std::move(*BufferOrError);
26 memcpy(&psinfoData, PsinfoBuffer->getBufferStart(), sizeof(psinfoData));
27 llvm::StringRef exe_path(
28 psinfoData.pr_psargs,
29 strnlen(psinfoData.pr_psargs, sizeof(psinfoData.pr_psargs)));
30 if (!exe_path.empty())
31 g_program_filespec.SetFile(exe_path, FileSpec::Style::native);
32 }
33 return g_program_filespec;
34}
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()
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)