diff options
author | Davide Italiano <davide@freebsd.org> | 2018-11-12 19:08:19 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2018-11-12 19:08:19 +0000 |
commit | 9a89d93d62525518faa518766b6fae4d14b26140 (patch) | |
tree | a65e0babe3bc9b0b1b0861aa2116784000b7a7c2 /lldb/source/Utility/DataBufferLLVM.cpp | |
parent | 163107885339985f576afef02c76978d6b2a2401 (diff) | |
download | bcm5719-llvm-9a89d93d62525518faa518766b6fae4d14b26140.tar.gz bcm5719-llvm-9a89d93d62525518faa518766b6fae4d14b26140.zip |
Revert "Extract construction of DataBufferLLVM into FileSystem"
It broke the lldb sanitizer bots.
llvm-svn: 346694
Diffstat (limited to 'lldb/source/Utility/DataBufferLLVM.cpp')
-rw-r--r-- | lldb/source/Utility/DataBufferLLVM.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lldb/source/Utility/DataBufferLLVM.cpp b/lldb/source/Utility/DataBufferLLVM.cpp index 0ab3fe5afd4..84870129094 100644 --- a/lldb/source/Utility/DataBufferLLVM.cpp +++ b/lldb/source/Utility/DataBufferLLVM.cpp @@ -27,6 +27,34 @@ DataBufferLLVM::DataBufferLLVM( DataBufferLLVM::~DataBufferLLVM() {} +std::shared_ptr<DataBufferLLVM> +DataBufferLLVM::CreateSliceFromPath(const llvm::Twine &Path, uint64_t Size, + uint64_t Offset) { + // If the file resides non-locally, pass the volatile flag so that we don't + // mmap it. + bool IsVolatile = !llvm::sys::fs::is_local(Path); + + auto Buffer = + llvm::WritableMemoryBuffer::getFileSlice(Path, Size, Offset, IsVolatile); + if (!Buffer) + return nullptr; + return std::shared_ptr<DataBufferLLVM>( + new DataBufferLLVM(std::move(*Buffer))); +} + +std::shared_ptr<DataBufferLLVM> +DataBufferLLVM::CreateFromPath(const llvm::Twine &Path) { + // If the file resides non-locally, pass the volatile flag so that we don't + // mmap it. + bool IsVolatile = !llvm::sys::fs::is_local(Path); + + auto Buffer = llvm::WritableMemoryBuffer::getFile(Path, -1, IsVolatile); + if (!Buffer) + return nullptr; + return std::shared_ptr<DataBufferLLVM>( + new DataBufferLLVM(std::move(*Buffer))); +} + uint8_t *DataBufferLLVM::GetBytes() { return reinterpret_cast<uint8_t *>(Buffer->getBufferStart()); } |