[Lldb-commits] [lldb] r154968 - in /lldb/branches/lldb-platform-work: ./ source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h source/Symbol/ClangASTImporter.cpp source/Target/Process.cpp

Johnny Chen johnny.chen at apple.com
Tue Apr 17 17:12:31 PDT 2012


Author: johnny
Date: Tue Apr 17 19:12:31 2012
New Revision: 154968

URL: http://llvm.org/viewvc/llvm-project?rev=154968&view=rev
Log:
Merge changes from ToT:

svn merge -r 154887:154966 https://johnny@llvm.org/svn/llvm-project/lldb/trunk .

Modified:
    lldb/branches/lldb-platform-work/   (props changed)
    lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
    lldb/branches/lldb-platform-work/source/Symbol/ClangASTImporter.cpp
    lldb/branches/lldb-platform-work/source/Target/Process.cpp

Propchange: lldb/branches/lldb-platform-work/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr 17 19:12:31 2012
@@ -1 +1 @@
-/lldb/trunk:154224-154887
+/lldb/trunk:154224-154966

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp?rev=154968&r1=154967&r2=154968&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp Tue Apr 17 19:12:31 2012
@@ -28,6 +28,25 @@
 using namespace lldb;
 using namespace lldb_private;
 
+PlatformRemoteiOS::SDKDirectoryInfo::SDKDirectoryInfo (const lldb_private::ConstString &dirname) :
+    directory(dirname),
+    build()
+{
+    const char *dirname_cstr = dirname.GetCString();
+    const char *pos = Args::StringToVersion (dirname_cstr,
+                                             version_major,
+                                             version_minor,
+                                             version_update);
+    
+    if (pos && pos[0] == ' ' && pos[1] == '(')
+    {
+        const char *build_start = pos + 2;
+        const char *end_paren = strchr (build_start, ')');
+        if (end_paren && build_start < end_paren)
+            build.SetCStringWithLength(build_start, end_paren - build_start);
+    }
+}
+
 //------------------------------------------------------------------
 // Static Variables
 //------------------------------------------------------------------
@@ -223,93 +242,171 @@
     return error;
 }
 
-const char *
-PlatformRemoteiOS::GetDeviceSupportDirectoryForOSVersion()
+FileSpec::EnumerateDirectoryResult 
+PlatformRemoteiOS::GetContainedFilesIntoVectorOfStringsCallback (void *baton,
+                                                                 FileSpec::FileType file_type,
+                                                                 const FileSpec &file_spec)
 {
-    if (m_sdk_sysroot)
-        return m_sdk_sysroot.GetCString();
+    ((PlatformRemoteiOS::SDKDirectoryInfoCollection *)baton)->push_back(PlatformRemoteiOS::SDKDirectoryInfo(file_spec.GetFilename()));
+    return FileSpec::eEnumerateDirectoryResultNext;
+}
 
-    if (m_device_support_directory_for_os_version.empty())
+bool
+PlatformRemoteiOS::UpdateSDKDirectoryInfosInNeeded()
+{
+    if (m_sdk_directory_infos.empty())
     {
-        const char *device_support_dir = GetDeveloperDirectory();
-        const bool resolve_path = true;
+        const char *device_support_dir = GetDeviceSupportDirectory();
         if (device_support_dir)
         {
-            m_device_support_directory_for_os_version.assign (device_support_dir);
-            m_device_support_directory_for_os_version.append ("/Platforms/iPhoneOS.platform/DeviceSupport");
+            const bool find_directories = true;
+            const bool find_files = false;
+            const bool find_other = false;
+            FileSpec::EnumerateDirectory (m_device_support_directory.c_str(),
+                                          find_directories,
+                                          find_files,
+                                          find_other,
+                                          GetContainedFilesIntoVectorOfStringsCallback,
+                                          &m_sdk_directory_infos);
+        }
+    }
+    return !m_sdk_directory_infos.empty();
+}
 
-            uint32_t major = 0;
-            uint32_t minor = 0;
-            uint32_t update = 0;
-            FileSpec file_spec;
-            char resolved_path[PATH_MAX];
-            if (GetOSVersion(major, minor, update))
+const PlatformRemoteiOS::SDKDirectoryInfo *
+PlatformRemoteiOS::GetSDKDirectoryForCurrentOSVersion ()
+{
+    uint32_t major, minor, update;
+    if (GetOSVersion(major, minor, update))
+    {
+        if (UpdateSDKDirectoryInfosInNeeded())
+        {
+            uint32_t i;
+            const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+            // First try for an exact match of major, minor and update
+            for (i=0; i<num_sdk_infos; ++i)
             {
-                if (major != UINT32_MAX && minor != UINT32_MAX && update != UINT32_MAX)
+                const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
+                if (sdk_dir_info.version_major == major &&
+                    sdk_dir_info.version_minor == minor &&
+                    sdk_dir_info.version_update == update)
                 {
-                    ::snprintf (resolved_path, 
-                                sizeof(resolved_path), 
-                                "%s/%i.%i.%i", 
-                                m_device_support_directory_for_os_version.c_str(), 
-                                major, 
-                                minor, 
-                                update);
-                    
-                    file_spec.SetFile(resolved_path, resolve_path);
-                    if (file_spec.Exists() && file_spec.GetPath(resolved_path, sizeof(resolved_path)))
-                    {
-                        m_device_support_directory_for_os_version.assign (resolved_path);
-                        return m_device_support_directory_for_os_version.c_str();
-                    }
+                    return &sdk_dir_info;
                 }
-
-                if (major != UINT32_MAX && minor != UINT32_MAX)
+            }
+            // First try for an exact match of major and minor
+            for (i=0; i<num_sdk_infos; ++i)
+            {
+                const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
+                if (sdk_dir_info.version_major == major &&
+                    sdk_dir_info.version_minor == minor)
                 {
-                    ::snprintf (resolved_path, 
-                                sizeof(resolved_path), 
-                                "%s/%i.%i", 
-                                m_device_support_directory_for_os_version.c_str(), 
-                                major, 
-                                minor);
-                    
-                    file_spec.SetFile(resolved_path, resolve_path);
-                    if (file_spec.Exists() && file_spec.GetPath(resolved_path, sizeof(resolved_path)))
-                    {
-                        m_device_support_directory_for_os_version.assign (resolved_path);
-                        return m_device_support_directory_for_os_version.c_str();
-                    }
+                    return &sdk_dir_info;
                 }
             }
-            else
+            // Lastly try to match of major version only..
+            for (i=0; i<num_sdk_infos; ++i)
             {
-                // Use the default as we have no OS version selected
-                m_device_support_directory_for_os_version.append ("/Latest");
-                file_spec.SetFile(m_device_support_directory_for_os_version.c_str(), resolve_path);
-                
-                if (file_spec.Exists() && file_spec.GetPath(resolved_path, sizeof(resolved_path)))
+                const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
+                if (sdk_dir_info.version_major == major)
                 {
-                    if (m_major_os_version == UINT32_MAX)
-                    {
-                        const char *resolved_latest_dirname = file_spec.GetFilename().GetCString();
-                        const char *pos = Args::StringToVersion (resolved_latest_dirname, 
-                                                                 m_major_os_version,
-                                                                 m_minor_os_version,
-                                                                 m_update_os_version);
+                    return &sdk_dir_info;
+                }
+            }
+        }
+    }
+    return NULL;
+}
 
-                        if (m_build_update.empty() && pos[0] == ' ' && pos[1] == '(')
+const PlatformRemoteiOS::SDKDirectoryInfo *
+PlatformRemoteiOS::GetSDKDirectoryForLatestOSVersion ()
+{
+    const PlatformRemoteiOS::SDKDirectoryInfo *result = NULL;
+    if (UpdateSDKDirectoryInfosInNeeded())
+    {
+        const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
+        // First try for an exact match of major, minor and update
+        for (uint32_t i=0; i<num_sdk_infos; ++i)
+        {
+            const SDKDirectoryInfo &sdk_dir_info = m_sdk_directory_infos[i];
+            if (sdk_dir_info.version_major != UINT32_MAX)
+            {
+                if (result == NULL || sdk_dir_info.version_major > result->version_major)
+                {
+                    result = &sdk_dir_info;
+                }
+                else if (sdk_dir_info.version_major == result->version_major)
+                {
+                    if (sdk_dir_info.version_minor > result->version_minor)
+                    {
+                        result = &sdk_dir_info;
+                    }
+                    else if (sdk_dir_info.version_minor == result->version_minor)
+                    {
+                        if (sdk_dir_info.version_update > result->version_update)
                         {
-                            const char *end_paren = strchr (pos + 2, ')');
-                            m_build_update.assign (pos + 2, end_paren);
+                            result = &sdk_dir_info;
                         }
                     }
-                    m_device_support_directory_for_os_version.assign (resolved_path);
-                    return m_device_support_directory_for_os_version.c_str();
                 }
             }
         }
-        // Assign a single NULL character so we know we tried to find the device
-        // support directory and we don't keep trying to find it over and over.
-        m_device_support_directory_for_os_version.assign (1, '\0');
+    }
+    return result;
+}
+
+
+
+const char *
+PlatformRemoteiOS::GetDeviceSupportDirectory()
+{
+    if (m_device_support_directory.empty())
+    {
+        const char *device_support_dir = GetDeveloperDirectory();
+        if (device_support_dir)
+        {
+            m_device_support_directory.assign (device_support_dir);
+            m_device_support_directory.append ("/Platforms/iPhoneOS.platform/DeviceSupport");
+        }
+        else
+        {
+            // Assign a single NULL character so we know we tried to find the device
+            // support directory and we don't keep trying to find it over and over.
+            m_device_support_directory.assign (1, '\0');
+        }
+    }
+    // We should have put a single NULL character into m_device_support_directory
+    // or it should have a valid path if the code gets here
+    assert (m_device_support_directory.empty() == false);
+    if (m_device_support_directory[0])
+        return m_device_support_directory.c_str();
+    return NULL;
+}
+            
+
+const char *
+PlatformRemoteiOS::GetDeviceSupportDirectoryForOSVersion()
+{
+    if (m_sdk_sysroot)
+        return m_sdk_sysroot.GetCString();
+
+    if (m_device_support_directory_for_os_version.empty())
+    {
+        const PlatformRemoteiOS::SDKDirectoryInfo *sdk_dir_info = GetSDKDirectoryForCurrentOSVersion ();
+        if (sdk_dir_info == NULL)
+            sdk_dir_info = GetSDKDirectoryForLatestOSVersion ();
+        if (sdk_dir_info)
+        {
+            m_device_support_directory_for_os_version = GetDeviceSupportDirectory();
+            m_device_support_directory_for_os_version.append(1, '/');
+            m_device_support_directory_for_os_version.append(sdk_dir_info->directory.GetCString());
+        }
+        else
+        {
+            // Assign a single NULL character so we know we tried to find the device
+            // support directory and we don't keep trying to find it over and over.
+            m_device_support_directory_for_os_version.assign (1, '\0');
+        }
     }
     // We should have put a single NULL character into m_device_support_directory_for_os_version
     // or it should have a valid path if the code gets here

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h?rev=154968&r1=154967&r2=154968&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h Tue Apr 17 19:12:31 2012
@@ -13,6 +13,8 @@
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
+#include "lldb/Host/FileSpec.h"
+
 // Project includes
 #include "PlatformDarwin.h"
 
@@ -113,13 +115,42 @@
                                      lldb_private::ArchSpec &arch);
 
 protected:
+    struct SDKDirectoryInfo
+    {
+        SDKDirectoryInfo (const lldb_private::ConstString &dirname);
+        lldb_private::ConstString directory;
+        lldb_private::ConstString build;
+        uint32_t version_major;
+        uint32_t version_minor;
+        uint32_t version_update;
+    };
+    typedef std::vector<SDKDirectoryInfo> SDKDirectoryInfoCollection;
+    std::string m_device_support_directory;
+    SDKDirectoryInfoCollection m_sdk_directory_infos;
     std::string m_device_support_directory_for_os_version;
     std::string m_build_update;
     //std::vector<FileSpec> m_device_support_os_dirs;
-    
+
+    bool
+    UpdateSDKDirectoryInfosInNeeded();
+
+    const char *
+    GetDeviceSupportDirectory();
+
     const char *
     GetDeviceSupportDirectoryForOSVersion();
 
+    const SDKDirectoryInfo *
+    GetSDKDirectoryForLatestOSVersion ();
+
+    const SDKDirectoryInfo *
+    GetSDKDirectoryForCurrentOSVersion ();
+
+    static lldb_private::FileSpec::EnumerateDirectoryResult
+    GetContainedFilesIntoVectorOfStringsCallback (void *baton,
+                                                  lldb_private::FileSpec::FileType file_type,
+                                                  const lldb_private::FileSpec &file_spec);
+
 private:
     DISALLOW_COPY_AND_ASSIGN (PlatformRemoteiOS);
 

Modified: lldb/branches/lldb-platform-work/source/Symbol/ClangASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Symbol/ClangASTImporter.cpp?rev=154968&r1=154967&r2=154968&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Symbol/ClangASTImporter.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Symbol/ClangASTImporter.cpp Tue Apr 17 19:12:31 2012
@@ -61,9 +61,14 @@
             if (log)
             {
                 if (NamedDecl *named_decl = dyn_cast<NamedDecl>(decl))
-                    log->Printf("  [ClangASTImporter] WARNING: Failed to import a %s '%s'", decl->getDeclKindName(), named_decl->getNameAsString().c_str());
+                    log->Printf("  [ClangASTImporter] WARNING: Failed to import a %s '%s', metadata 0x%llx",
+                                decl->getDeclKindName(),
+                                named_decl->getNameAsString().c_str(),
+                                GetDeclMetadata(decl));
                 else
-                    log->Printf("  [ClangASTImporter] WARNING: Failed to import a %s", decl->getDeclKindName());
+                    log->Printf("  [ClangASTImporter] WARNING: Failed to import a %s, metadata 0x%llx",
+                                decl->getDeclKindName(),
+                                GetDeclMetadata(decl));
             }
         }
         

Modified: lldb/branches/lldb-platform-work/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Target/Process.cpp?rev=154968&r1=154967&r2=154968&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Target/Process.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Target/Process.cpp Tue Apr 17 19:12:31 2012
@@ -1391,6 +1391,9 @@
 uint32_t
 Process::LoadImage (const FileSpec &image_spec, Error &error)
 {
+    char path[PATH_MAX];
+    image_spec.GetPath(path, sizeof(path));
+
     DynamicLoader *loader = GetDynamicLoader();
     if (loader)
     {
@@ -1413,8 +1416,6 @@
                 frame_sp->CalculateExecutionContext (exe_ctx);
                 bool unwind_on_error = true;
                 StreamString expr;
-                char path[PATH_MAX];
-                image_spec.GetPath(path, sizeof(path));
                 expr.Printf("dlopen (\"%s\", 2)", path);
                 const char *prefix = "extern \"C\" void* dlopen (const char *path, int mode);\n";
                 lldb::ValueObjectSP result_valobj_sp;
@@ -1437,6 +1438,8 @@
             }
         }
     }
+    if (!error.AsCString())
+        error.SetErrorStringWithFormat("unable to load '%s'", path);
     return LLDB_INVALID_IMAGE_TOKEN;
 }
 





More information about the lldb-commits mailing list