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
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 5901a1b..a6d5a85 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -860,7 +860,7 @@
                                             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;
@@ -872,7 +872,7 @@
   // 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;
     data_offset = 0;
@@ -911,7 +911,8 @@
       size_t header_and_load_cmds =
           header.sizeofcmds + MachHeaderSizeFromMagic(header.magic);
       if (header_and_load_cmds >= data_sp->GetByteSize()) {
-        data_sp = file.ReadFileContents(file_offset, header_and_load_cmds);
+        data_sp = DataBufferLLVM::CreateSliceFromPath(
+            file.GetPath(), header_and_load_cmds, file_offset);
         data.SetData(data_sp);
         data_offset = MachHeaderSizeFromMagic(header.magic);
       }
@@ -1123,8 +1124,8 @@
                   ReadMemory(process_sp, m_memory_addr, header_and_lc_size);
             } else {
               // Read in all only the load command data from the file on disk
-              data_sp =
-                  m_file.ReadFileContents(m_file_offset, header_and_lc_size);
+              data_sp = DataBufferLLVM::CreateSliceFromPath(
+                  m_file.GetPath(), header_and_lc_size, m_file_offset);
               if (data_sp->GetByteSize() != header_and_lc_size)
                 return false;
             }
@@ -2095,7 +2096,7 @@
                                          const ByteOrder byte_order,
                                          const uint32_t addr_byte_size) {
   UUID dsc_uuid;
-  DataBufferSP DscData = DataBufferLLVM::CreateFromPath(
+  DataBufferSP DscData = DataBufferLLVM::CreateSliceFromPath(
       dyld_shared_cache.GetPath(),
       sizeof(struct lldb_copy_dyld_cache_header_v1), 0);
   if (!DscData)
@@ -2703,7 +2704,7 @@
 
       // Process the dyld shared cache header to find the unmapped symbols
 
-      DataBufferSP dsc_data_sp = DataBufferLLVM::CreateFromPath(
+      DataBufferSP dsc_data_sp = DataBufferLLVM::CreateSliceFromPath(
           dsc_filespec.GetPath(), sizeof(struct lldb_copy_dyld_cache_header_v1),
           0);
       if (!dsc_uuid.IsValid()) {
@@ -2738,7 +2739,7 @@
             mappingOffset >= sizeof(struct lldb_copy_dyld_cache_header_v1)) {
 
           DataBufferSP dsc_mapping_info_data_sp =
-              DataBufferLLVM::CreateFromPath(
+              DataBufferLLVM::CreateSliceFromPath(
                   dsc_filespec.GetPath(),
                   sizeof(struct lldb_copy_dyld_cache_mapping_info),
                   mappingOffset);
@@ -2765,7 +2766,7 @@
           if (localSymbolsOffset && localSymbolsSize) {
             // Map the local symbols
             DataBufferSP dsc_local_symbols_data_sp =
-                DataBufferLLVM::CreateFromPath(dsc_filespec.GetPath(),
+                DataBufferLLVM::CreateSliceFromPath(dsc_filespec.GetPath(),
                                                localSymbolsSize,
                                                localSymbolsOffset);