Made a ModuleSpec class in Module.h which can specify a module using one or
more of the local path, platform path, associated symbol file, UUID, arch,
object name and object offset. This allows many of the calls that were
GetSharedModule to reduce the number of arguments that were used in a call
to these functions. It also allows a module to be created with a ModuleSpec
which allows many things to be specified prior to any accessors being called
on the Module class itself. 

I was running into problems when adding support for "target symbol add"
where you can specify a stand alone debug info file after debugging has started
where I needed to specify the associated symbol file path and if I waited until
after construction, the wrong  symbol file had already been located. By using
the ModuleSpec it allows us to construct a module with as little or as much
information as needed and not have to change the parameter list.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@151476 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Host/macosx/Symbols.cpp b/source/Host/macosx/Symbols.cpp
index 50161de..efd8fbb 100644
--- a/source/Host/macosx/Symbols.cpp
+++ b/source/Host/macosx/Symbols.cpp
@@ -21,6 +21,7 @@
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/DataBuffer.h"
 #include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/Timer.h"
 #include "lldb/Core/UUID.h"
 #include "lldb/Host/Endian.h"
@@ -286,9 +287,7 @@
 static int
 LocateMacOSXFilesUsingDebugSymbols
 (
-    const FileSpec *exec_fspec, // An executable path that may or may not be correct if UUID is specified
-    const ArchSpec* arch,       // Limit the search to files with this architecture if non-NULL
-    const lldb_private::UUID *uuid,           // Match the UUID value if non-NULL,
+    const ModuleSpec &module_spec,
     FileSpec *out_exec_fspec,   // If non-NULL, try and find the executable
     FileSpec *out_dsym_fspec    // If non-NULL try and find the debug symbol file
 )
@@ -303,6 +302,9 @@
 
 #if !defined (__arm__) // No DebugSymbols on the iOS devices
 
+    const UUID *uuid = module_spec.GetUUIDPtr();
+    const ArchSpec *arch = module_spec.GetArchitecturePtr();
+
     if (uuid && uuid->IsValid())
     {
         // Try and locate the dSYM file using DebugSymbols first
@@ -330,7 +332,7 @@
             if (module_uuid_ref.get())
             {
                 CFCReleaser<CFURLRef> exec_url;
-
+                const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
                 if (exec_fspec)
                 {
                     char exec_cf_path[PATH_MAX];
@@ -450,8 +452,9 @@
 }
 
 static bool
-LocateDSYMInVincinityOfExecutable (const FileSpec *exec_fspec, const ArchSpec* arch, const lldb_private::UUID *uuid, FileSpec &dsym_fspec)
+LocateDSYMInVincinityOfExecutable (const ModuleSpec &module_spec, FileSpec &dsym_fspec)
 {
+    const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
     if (exec_fspec)
     {
         char path[PATH_MAX];
@@ -466,7 +469,7 @@
 
                 dsym_fspec.SetFile(path, false);
 
-                if (dsym_fspec.Exists() && FileAtPathContainsArchAndUUID (dsym_fspec, arch, uuid))
+                if (dsym_fspec.Exists() && FileAtPathContainsArchAndUUID (dsym_fspec, module_spec.GetArchitecturePtr(), module_spec.GetUUIDPtr()))
                 {
                     return true;
                 }
@@ -484,7 +487,7 @@
                             strncat(path, ".dSYM/Contents/Resources/DWARF/", sizeof(path));
                             strncat(path, exec_fspec->GetFilename().AsCString(), sizeof(path));
                             dsym_fspec.SetFile(path, false);
-                            if (dsym_fspec.Exists() && FileAtPathContainsArchAndUUID (dsym_fspec, arch, uuid))
+                            if (dsym_fspec.Exists() && FileAtPathContainsArchAndUUID (dsym_fspec, module_spec.GetArchitecturePtr(), module_spec.GetUUIDPtr()))
                                 return true;
                             else
                             {
@@ -510,8 +513,11 @@
 }
 
 FileSpec
-Symbols::LocateExecutableObjectFile (const FileSpec *exec_fspec, const ArchSpec* arch, const lldb_private::UUID *uuid)
+Symbols::LocateExecutableObjectFile (const ModuleSpec &module_spec)
 {
+    const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
+    const ArchSpec *arch = module_spec.GetArchitecturePtr();
+    const UUID *uuid = module_spec.GetUUIDPtr();
     Timer scoped_timer (__PRETTY_FUNCTION__,
                         "LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)",
                         exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
@@ -519,16 +525,20 @@
                         uuid);
 
     FileSpec objfile_fspec;
-    if (exec_fspec && FileAtPathContainsArchAndUUID (*exec_fspec, arch, uuid))
-        objfile_fspec = *exec_fspec;
+    if (exec_fspec && FileAtPathContainsArchAndUUID (exec_fspec, arch, uuid))
+        objfile_fspec = exec_fspec;
     else
-        LocateMacOSXFilesUsingDebugSymbols (exec_fspec, arch, uuid, &objfile_fspec, NULL);
+        LocateMacOSXFilesUsingDebugSymbols (module_spec, &objfile_fspec, NULL);
     return objfile_fspec;
 }
 
 FileSpec
-Symbols::LocateExecutableSymbolFile (const FileSpec *exec_fspec, const ArchSpec* arch, const lldb_private::UUID *uuid)
+Symbols::LocateExecutableSymbolFile (const ModuleSpec &module_spec)
 {
+    const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
+    const ArchSpec *arch = module_spec.GetArchitecturePtr();
+    const UUID *uuid = module_spec.GetUUIDPtr();
+
     Timer scoped_timer (__PRETTY_FUNCTION__,
                         "LocateExecutableSymbolFile (file = %s, arch = %s, uuid = %p)",
                         exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
@@ -538,10 +548,10 @@
     FileSpec symbol_fspec;
     // First try and find the dSYM in the same directory as the executable or in
     // an appropriate parent directory
-    if (LocateDSYMInVincinityOfExecutable (exec_fspec, arch, uuid, symbol_fspec) == false)
+    if (LocateDSYMInVincinityOfExecutable (module_spec, symbol_fspec) == false)
     {
         // We failed to easily find the dSYM above, so use DebugSymbols
-        LocateMacOSXFilesUsingDebugSymbols (exec_fspec, arch, uuid, NULL, &symbol_fspec);
+        LocateMacOSXFilesUsingDebugSymbols (module_spec, NULL, &symbol_fspec);
     }
     return symbol_fspec;
 }