Full core file support has been added for mach-o core files.

Tracking modules down when you have a UUID and a path has been improved.

DynamicLoaderDarwinKernel no longer parses mach-o load commands and it
now uses the memory based modules now that we can load modules from memory.

Added a target setting named "target.exec-search-paths" which can be used
to supply a list of directories to use when trying to look for executables.
This allows one or more directories to be used when searching for modules
that may not exist in the SDK/PDK. The target automatically adds the directory
for the main executable to this list so this should help us in tracking down
shared libraries and other binaries. 

llvm-svn: 150426
diff --git a/lldb/source/Host/macosx/Host.mm b/lldb/source/Host/macosx/Host.mm
index ac5f5f6..fe3c450 100644
--- a/lldb/source/Host/macosx/Host.mm
+++ b/lldb/source/Host/macosx/Host.mm
@@ -137,6 +137,28 @@
     }
 }
 
+bool
+Host::GetBundleDirectory (const FileSpec &file, FileSpec &bundle_directory)
+{
+#if defined (__APPLE__)
+    if (file.GetFileType () == FileSpec::eFileTypeDirectory)
+    {
+        char path[PATH_MAX];
+        if (file.GetPath(path, sizeof(path)))
+        {
+            CFCBundle bundle (path);
+            if (bundle.GetPath (path, sizeof(path)))
+            {
+                bundle_directory.SetFile (path, false);
+                return true;
+            }
+        }
+    }
+#endif
+    bundle_directory.Clear();
+    return false;
+}
+
 
 bool
 Host::ResolveExecutableInBundle (FileSpec &file)
@@ -1215,7 +1237,8 @@
         lldb::ModuleSP exe_module_sp;
         error = host_platform_sp->ResolveExecutable (exe_spec,
                                                      arch_spec,
-                                                     exe_module_sp);
+                                                     exe_module_sp,
+                                                     NULL);
     
         if (error.Fail())
             return error;
diff --git a/lldb/source/Host/macosx/Symbols.cpp b/lldb/source/Host/macosx/Symbols.cpp
index 8201266..50161de 100644
--- a/lldb/source/Host/macosx/Symbols.cpp
+++ b/lldb/source/Host/macosx/Symbols.cpp
@@ -367,7 +367,8 @@
 
                     if (out_exec_fspec)
                     {
-                        CFCReleaser<CFDictionaryRef> dict(::DBGCopyDSYMPropertyLists (dsym_url.get()));;
+                        CFCReleaser<CFDictionaryRef> dict(::DBGCopyDSYMPropertyLists (dsym_url.get()));
+                        bool success = false;
                         if (dict.get())
                         {
                             char uuid_cstr_buf[64];
@@ -381,10 +382,13 @@
                                 {
                                     ++items_found;
                                     out_exec_fspec->SetFile(path, path[0] == '~');
+                                    if (out_exec_fspec->Exists())
+                                        success = true;
                                 }
                             }
                         }
-                        else
+
+                        if (!success)
                         {
                             // No dictionary, check near the dSYM bundle for an executable that matches...
                             if (::CFURLGetFileSystemRepresentation (dsym_url.get(), true, (UInt8*)path, sizeof(path)-1))
diff --git a/lldb/source/Host/macosx/cfcpp/CFCBundle.cpp b/lldb/source/Host/macosx/cfcpp/CFCBundle.cpp
index 6e68af5..71b0749 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCBundle.cpp
+++ b/lldb/source/Host/macosx/cfcpp/CFCBundle.cpp
@@ -55,6 +55,22 @@
     return get() != NULL;
 }
 
+bool
+CFCBundle::GetPath (char *dst, size_t dst_len)
+{
+    CFBundleRef bundle = get();
+    if (bundle)
+    {
+        CFCReleaser<CFURLRef> bundle_url (CFBundleCopyBundleURL (bundle));
+        if (bundle_url.get())
+        {
+            Boolean resolveAgainstBase = 0;
+            return ::CFURLGetFileSystemRepresentation (bundle_url.get(), resolveAgainstBase, (UInt8 *)dst, dst_len) != 0;
+        }
+    }
+    return false;
+}   
+
 CFStringRef
 CFCBundle::GetIdentifier () const
 {
diff --git a/lldb/source/Host/macosx/cfcpp/CFCBundle.h b/lldb/source/Host/macosx/cfcpp/CFCBundle.h
index c07a48c..1cd1b68 100644
--- a/lldb/source/Host/macosx/cfcpp/CFCBundle.h
+++ b/lldb/source/Host/macosx/cfcpp/CFCBundle.h
@@ -34,6 +34,9 @@
     GetValueForInfoDictionaryKey(CFStringRef key) const;
 
     bool
+    GetPath (char *dst, size_t dst_len);
+
+    bool
     SetPath (const char *path);
 
 private: