1 | //===-- Support.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 | |
9 | #include "lldb/Host/posix/Support.h" |
10 | #include "lldb/Utility/LLDBLog.h" |
11 | #include "lldb/Utility/Log.h" |
12 | #include "llvm/Support/MemoryBuffer.h" |
13 | |
14 | llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> |
15 | lldb_private::getProcFile(::pid_t pid, const llvm::Twine &file) { |
16 | Log *log = GetLog(mask: LLDBLog::Host); |
17 | std::string File = ("/proc/"+ llvm::Twine(pid) + "/"+ file).str(); |
18 | auto Ret = llvm::MemoryBuffer::getFileAsStream(Filename: File); |
19 | if (!Ret) |
20 | LLDB_LOG(log, "Failed to open {0}: {1}", File, Ret.getError().message()); |
21 | return Ret; |
22 | } |
23 | |
24 | llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> |
25 | lldb_private::getProcFile(const llvm::Twine &file) { |
26 | Log *log = GetLog(mask: LLDBLog::Host); |
27 | std::string File = ("/proc/"+ file).str(); |
28 | auto Ret = llvm::MemoryBuffer::getFileAsStream(Filename: File); |
29 | if (!Ret) |
30 | LLDB_LOG(log, "Failed to open {0}: {1}", File, Ret.getError().message()); |
31 | return Ret; |
32 | } |
33 |