Delete DataBufferMemoryMap.

After a series of patches on the LLVM side to get the mmaping
code up to compatibility with LLDB's needs, it is now ready
to go, which means LLDB's custom mmapping code is redundant.
So this patch deletes it all and uses LLVM's code instead.

In the future, we could take this one step further and delete
even the lldb DataBuffer base class and rely entirely on
LLVM's facilities, but this is a job for another day.

Differential Revision: https://reviews.llvm.org/D30054

llvm-svn: 296159
This commit is contained in:
Zachary Turner
2017-02-24 18:56:49 +00:00
parent bb361fcba1
commit 3f4a4b3681
14 changed files with 365 additions and 766 deletions

View File

@@ -13,8 +13,8 @@
#include "llvm/Support/COFF.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataBufferLLVM.h"
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
@@ -30,6 +30,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Utility/StreamString.h"
#include "llvm/Support/MemoryBuffer.h"
#define IMAGE_DOS_SIGNATURE 0x5A4D // MZ
#define IMAGE_NT_SIGNATURE 0x00004550 // PE00
#define OPT_HEADER_MAGIC_PE32 0x010b
@@ -65,20 +67,28 @@ ObjectFile *ObjectFilePECOFF::CreateInstance(const lldb::ModuleSP &module_sp,
lldb::offset_t file_offset,
lldb::offset_t length) {
if (!data_sp) {
data_sp = file->MemoryMapFileContentsIfLocal(file_offset, length);
data_sp = DataBufferLLVM::CreateFromFileSpec(*file, length, file_offset);
if (!data_sp)
return nullptr;
data_offset = 0;
}
if (ObjectFilePECOFF::MagicBytesMatch(data_sp)) {
// Update the data to contain the entire file if it doesn't already
if (data_sp->GetByteSize() < length)
data_sp = file->MemoryMapFileContentsIfLocal(file_offset, length);
std::unique_ptr<ObjectFile> objfile_ap(new ObjectFilePECOFF(
module_sp, data_sp, data_offset, file, file_offset, length));
if (objfile_ap.get() && objfile_ap->ParseHeader())
return objfile_ap.release();
if (!ObjectFilePECOFF::MagicBytesMatch(data_sp))
return nullptr;
// Update the data to contain the entire file if it doesn't already
if (data_sp->GetByteSize() < length) {
data_sp = DataBufferLLVM::CreateFromFileSpec(*file, length, file_offset);
if (!data_sp)
return nullptr;
}
return NULL;
auto objfile_ap = llvm::make_unique<ObjectFilePECOFF>(
module_sp, data_sp, data_offset, file, file_offset, length);
if (!objfile_ap || !objfile_ap->ParseHeader())
return nullptr;
return objfile_ap.release();
}
ObjectFile *ObjectFilePECOFF::CreateMemoryInstance(