blob: 8fbb60052e3f6734af1e2556f81762b998037a44 [file] [log] [blame]
Pavel Labath7e437f82017-03-15 15:08:49 +00001//===-- Support.cpp ---------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/Host/linux/Support.h"
11#include "lldb/Utility/Log.h"
12#include "llvm/Support/MemoryBuffer.h"
13
14llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
15lldb_private::getProcFile(::pid_t pid, ::pid_t tid, const llvm::Twine &file) {
16 Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
17 std::string File =
18 ("/proc/" + llvm::Twine(pid) + "/task/" + llvm::Twine(tid) + "/" + file)
19 .str();
20 auto Ret = llvm::MemoryBuffer::getFileAsStream(File);
21 if (!Ret)
22 LLDB_LOG(log, "Failed to open {0}: {1}", File, Ret.getError().message());
23 return Ret;
24}
25
26llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
27lldb_private::getProcFile(::pid_t pid, const llvm::Twine &file) {
28 Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
29 std::string File = ("/proc/" + llvm::Twine(pid) + "/" + file).str();
30 auto Ret = llvm::MemoryBuffer::getFileAsStream(File);
31 if (!Ret)
32 LLDB_LOG(log, "Failed to open {0}: {1}", File, Ret.getError().message());
33 return Ret;
34}