diff options
author | Zachary Turner <zturner@google.com> | 2017-03-06 23:42:14 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-03-06 23:42:14 +0000 |
commit | 7f6a7a37521e3610be7242ccec7ca9a15c1c307a (patch) | |
tree | e2b7f59e0254269500347dfbd067108d86ca70a0 /lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp | |
parent | 15492af547112d272572994bfef2d560ce651d7b (diff) | |
download | bcm5719-llvm-7f6a7a37521e3610be7242ccec7ca9a15c1c307a.tar.gz bcm5719-llvm-7f6a7a37521e3610be7242ccec7ca9a15c1c307a.zip |
Remove FileSpec::ReadFileContents.
This functionality is subsumed by DataBufferLLVM, which is
also more efficient since it will try to mmap. However, we
don't yet support mmaping writable private sections, and in
some cases we were using ReadFileContents and then modifying
the buffer. To address that I've added a flag to the
DataBufferLLVM methods that allow you to map privately, which
disables the mmaping path entirely. Eventually we should teach
DataBufferLLVM to use mmap with writable private, but that is
orthogonal to this effort.
Differential Revision: https://reviews.llvm.org/D30622
llvm-svn: 297095
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index b9577b5d1f2..df665129ae2 100644 --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -68,7 +68,7 @@ ObjectFile *ObjectFilePECOFF::CreateInstance(const lldb::ModuleSP &module_sp, lldb::offset_t length) { if (!data_sp) { data_sp = - DataBufferLLVM::CreateFromPath(file->GetPath(), length, file_offset); + DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length, file_offset); if (!data_sp) return nullptr; data_offset = 0; @@ -80,7 +80,7 @@ ObjectFile *ObjectFilePECOFF::CreateInstance(const lldb::ModuleSP &module_sp, // Update the data to contain the entire file if it doesn't already if (data_sp->GetByteSize() < length) { data_sp = - DataBufferLLVM::CreateFromPath(file->GetPath(), length, file_offset); + DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length, file_offset); if (!data_sp) return nullptr; } @@ -430,7 +430,10 @@ bool ObjectFilePECOFF::ParseCOFFOptionalHeader(lldb::offset_t *offset_ptr) { DataExtractor ObjectFilePECOFF::ReadImageData(uint32_t offset, size_t size) { if (m_file) { - DataBufferSP buffer_sp(m_file.ReadFileContents(offset, size)); + // A bit of a hack, but we intend to write to this buffer, so we can't + // mmap it. + auto buffer_sp = + DataBufferLLVM::CreateSliceFromPath(m_file.GetPath(), size, offset, true); return DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize()); } ProcessSP process_sp(m_process_wp.lock()); |