1 //===-- Support.cpp -------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Host/linux/Support.h"
10 #include "lldb/Utility/LLDBLog.h"
11 #include "lldb/Utility/Log.h"
12 #include "llvm/Support/MemoryBuffer.h"
14 llvm::ErrorOr
<std::unique_ptr
<llvm::MemoryBuffer
>>
15 lldb_private::getProcFile(::pid_t pid
, ::pid_t tid
, const llvm::Twine
&file
) {
16 Log
*log
= GetLog(LLDBLog::Host
);
18 ("/proc/" + llvm::Twine(pid
) + "/task/" + llvm::Twine(tid
) + "/" + file
)
20 auto Ret
= llvm::MemoryBuffer::getFileAsStream(File
);
22 LLDB_LOG(log
, "Failed to open {0}: {1}", File
, Ret
.getError().message());
26 llvm::ErrorOr
<std::unique_ptr
<llvm::MemoryBuffer
>>
27 lldb_private::getProcFile(::pid_t pid
, const llvm::Twine
&file
) {
28 Log
*log
= GetLog(LLDBLog::Host
);
29 std::string File
= ("/proc/" + llvm::Twine(pid
) + "/" + file
).str();
30 auto Ret
= llvm::MemoryBuffer::getFileAsStream(File
);
32 LLDB_LOG(log
, "Failed to open {0}: {1}", File
, Ret
.getError().message());
36 llvm::ErrorOr
<std::unique_ptr
<llvm::MemoryBuffer
>>
37 lldb_private::getProcFile(const llvm::Twine
&file
) {
38 Log
*log
= GetLog(LLDBLog::Host
);
39 std::string File
= ("/proc/" + file
).str();
40 auto Ret
= llvm::MemoryBuffer::getFileAsStream(File
);
42 LLDB_LOG(log
, "Failed to open {0}: {1}", File
, Ret
.getError().message());