Fixed GetModuleSpecifications() to work better overall:
- MachO files now correctly extract the UUID all the time
- More file size and offset verification done for universal mach-o files to watch for truncated files
- ObjectContainerBSDArchive now supports enumerating all objects in BSD archives (.a files)
- lldb_private::Module() can not be properly constructed using a ModuleSpec for a .o file in a .a file
- The BSD archive plug-in shares its cache for GetModuleSpecifications() and the create callback
- Improved printing for ModuleSpec objects

llvm-svn: 186211
diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp
index 20ed648..0c61591 100644
--- a/lldb/source/Symbol/ObjectFile.cpp
+++ b/lldb/source/Symbol/ObjectFile.cpp
@@ -186,16 +186,25 @@
 size_t
 ObjectFile::GetModuleSpecifications (const FileSpec &file,
                                      lldb::offset_t file_offset,
+                                     lldb::offset_t file_size,
                                      ModuleSpecList &specs)
 {
     DataBufferSP data_sp (file.ReadFileContents(file_offset, 512));
     if (data_sp)
-        return ObjectFile::GetModuleSpecifications (file,                    // file spec
-                                                    data_sp,                 // data bytes
-                                                    0,                       // data offset
-                                                    file_offset,             // file offset
-                                                    data_sp->GetByteSize(),  // data length
+    {
+        if (file_size == 0)
+        {
+            const lldb::offset_t actual_file_size = file.GetByteSize();
+            if (actual_file_size > file_offset)
+                file_size = actual_file_size - file_offset;
+        }
+        return ObjectFile::GetModuleSpecifications (file,       // file spec
+                                                    data_sp,    // data bytes
+                                                    0,          // data offset
+                                                    file_offset,// file offset
+                                                    file_size,  // file length
                                                     specs);
+    }
     return 0;
 }
 
@@ -204,7 +213,7 @@
                                      lldb::DataBufferSP& data_sp,
                                      lldb::offset_t data_offset,
                                      lldb::offset_t file_offset,
-                                     lldb::offset_t length,
+                                     lldb::offset_t file_size,
                                      lldb_private::ModuleSpecList &specs)
 {
     const size_t initial_count = specs.GetSize();
@@ -213,14 +222,14 @@
     // Try the ObjectFile plug-ins
     for (i = 0; (callback = PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex(i)) != NULL; ++i)
     {
-        if (callback (file, data_sp, data_offset, file_offset, length, specs) > 0)
+        if (callback (file, data_sp, data_offset, file_offset, file_size, specs) > 0)
             return specs.GetSize() - initial_count;
     }
 
     // Try the ObjectContainer plug-ins
     for (i = 0; (callback = PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex(i)) != NULL; ++i)
     {
-        if (callback (file, data_sp, data_offset, file_offset, length, specs) > 0)
+        if (callback (file, data_sp, data_offset, file_offset, file_size, specs) > 0)
             return specs.GetSize() - initial_count;
     }
     return 0;