Path: blob/main/contrib/llvm-project/lldb/source/Host/posix/Support.cpp
213799 views
//===-- Support.cpp -------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/Host/posix/Support.h"9#include "lldb/Utility/LLDBLog.h"10#include "lldb/Utility/Log.h"11#include "llvm/Support/MemoryBuffer.h"1213llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>14lldb_private::getProcFile(::pid_t pid, const llvm::Twine &file) {15Log *log = GetLog(LLDBLog::Host);16std::string File = ("/proc/" + llvm::Twine(pid) + "/" + file).str();17auto Ret = llvm::MemoryBuffer::getFileAsStream(File);18if (!Ret)19LLDB_LOG(log, "Failed to open {0}: {1}", File, Ret.getError().message());20return Ret;21}2223llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>24lldb_private::getProcFile(const llvm::Twine &file) {25Log *log = GetLog(LLDBLog::Host);26std::string File = ("/proc/" + file).str();27auto Ret = llvm::MemoryBuffer::getFileAsStream(File);28if (!Ret)29LLDB_LOG(log, "Failed to open {0}: {1}", File, Ret.getError().message());30return Ret;31}323334