Hemang Gadhavi d1bb8d6a5c
[lldb][AIX] get host info for AIX (#134354)
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 changes to make the common host support functions under
`Host/posix` for unix-like system.
Also, created the `unittests/Host/posix/` to test the hostInfo & support
functions for unix-like system.
- Added changes to get the host information for AIX. (GetProcessInfo()) 
(Information like : executable path, arch, process status etc.)
2025-04-29 11:23:03 +05:30

25 lines
957 B
C++

//===-- Support.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/linux/Support.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "llvm/Support/MemoryBuffer.h"
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
lldb_private::getProcFile(::pid_t pid, ::pid_t tid, const llvm::Twine &file) {
Log *log = GetLog(LLDBLog::Host);
std::string File =
("/proc/" + llvm::Twine(pid) + "/task/" + llvm::Twine(tid) + "/" + file)
.str();
auto Ret = llvm::MemoryBuffer::getFileAsStream(File);
if (!Ret)
LLDB_LOG(log, "Failed to open {0}: {1}", File, Ret.getError().message());
return Ret;
}