[Lldb-commits] [lldb] r172251 - in /lldb/trunk: include/lldb/Target/Platform.h source/Core/ArchSpec.cpp source/Interpreter/OptionGroupPlatform.cpp source/Target/Platform.cpp source/Target/Process.cpp source/Target/TargetList.cpp

Greg Clayton gclayton at apple.com
Fri Jan 11 12:49:54 PST 2013


Author: gclayton
Date: Fri Jan 11 14:49:54 2013
New Revision: 172251

URL: http://llvm.org/viewvc/llvm-project?rev=172251&view=rev
Log:
<rdar://problem/12990038>

Fixed an issue where the platform auto select code was changing the architecture and causing the wrong architecture to be assigned to the target.


Modified:
    lldb/trunk/include/lldb/Target/Platform.h
    lldb/trunk/source/Core/ArchSpec.cpp
    lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp
    lldb/trunk/source/Target/Platform.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/source/Target/TargetList.cpp

Modified: lldb/trunk/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=172251&r1=172250&r2=172251&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Platform.h (original)
+++ lldb/trunk/include/lldb/Target/Platform.h Fri Jan 11 14:49:54 2013
@@ -347,7 +347,9 @@
         /// architecture and the target triple contained within.
         //------------------------------------------------------------------
         virtual bool
-        IsCompatibleArchitecture (const ArchSpec &arch, ArchSpec *compatible_arch_ptr = NULL);
+        IsCompatibleArchitecture (const ArchSpec &arch,
+                                  bool exact_arch_match,
+                                  ArchSpec *compatible_arch_ptr);
 
         //------------------------------------------------------------------
         /// Not all platforms will support debugging a process by spawning

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=172251&r1=172250&r2=172251&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Fri Jan 11 14:49:54 2013
@@ -604,7 +604,7 @@
                     // architecture. If this is not available (might not be
                     // connected) use the first supported architecture.
                     ArchSpec compatible_arch;
-                    if (platform->IsCompatibleArchitecture (raw_arch, &compatible_arch))
+                    if (platform->IsCompatibleArchitecture (raw_arch, false, &compatible_arch))
                     {
                         if (compatible_arch.IsValid())
                         {

Modified: lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp?rev=172251&r1=172250&r2=172251&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp Fri Jan 11 14:49:54 2013
@@ -36,7 +36,7 @@
         platform_sp = Platform::Create (m_platform_name.c_str(), error);
         if (platform_sp)
         {
-            if (platform_arch.IsValid() && !platform_sp->IsCompatibleArchitecture(arch, &platform_arch))
+            if (platform_arch.IsValid() && !platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch))
             {
                 error.SetErrorStringWithFormat("platform '%s' doesn't support '%s'", platform_sp->GetName(), arch.GetTriple().getTriple().c_str());
                 platform_sp.reset();

Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=172251&r1=172250&r2=172251&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Fri Jan 11 14:49:54 2013
@@ -145,12 +145,27 @@
     {
         uint32_t idx;
         PlatformCreateInstance create_callback;
+        // First try exact arch matches across all platform plug-ins
+        bool exact = true;
         for (idx = 0; (create_callback = PluginManager::GetPlatformCreateCallbackAtIndex (idx)); ++idx)
         {
             if (create_callback)
+            {
+                platform_sp.reset(create_callback(false, &arch));
+                if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, exact, platform_arch_ptr))
+                    return platform_sp;
+            }
+        }
+        // Next try compatible arch matches across all platform plug-ins
+        exact = false;
+        for (idx = 0; (create_callback = PluginManager::GetPlatformCreateCallbackAtIndex (idx)); ++idx)
+        {
+            if (create_callback)
+            {
                 platform_sp.reset(create_callback(false, &arch));
-            if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, platform_arch_ptr))
-                return platform_sp;
+                if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, exact, platform_arch_ptr))
+                    return platform_sp;
+            }
         }
     }
     else
@@ -680,19 +695,35 @@
 /// architecture and the target triple contained within.
 //------------------------------------------------------------------
 bool
-Platform::IsCompatibleArchitecture (const ArchSpec &arch, ArchSpec *compatible_arch_ptr)
+Platform::IsCompatibleArchitecture (const ArchSpec &arch, bool exact_arch_match, ArchSpec *compatible_arch_ptr)
 {
     // If the architecture is invalid, we must answer true...
     if (arch.IsValid())
     {
         ArchSpec platform_arch;
-        for (uint32_t arch_idx=0; GetSupportedArchitectureAtIndex (arch_idx, platform_arch); ++arch_idx)
+        // Try for an exact architecture match first.
+        if (exact_arch_match)
         {
-            if (arch.IsCompatibleMatch(platform_arch))
+            for (uint32_t arch_idx=0; GetSupportedArchitectureAtIndex (arch_idx, platform_arch); ++arch_idx)
             {
-                if (compatible_arch_ptr)
-                    *compatible_arch_ptr = platform_arch;
-                return true;
+                if (arch.IsExactMatch(platform_arch))
+                {
+                    if (compatible_arch_ptr)
+                        *compatible_arch_ptr = platform_arch;
+                    return true;
+                }
+            }
+        }
+        else
+        {
+            for (uint32_t arch_idx=0; GetSupportedArchitectureAtIndex (arch_idx, platform_arch); ++arch_idx)
+            {
+                if (arch.IsCompatibleMatch(platform_arch))
+                {
+                    if (compatible_arch_ptr)
+                        *compatible_arch_ptr = platform_arch;
+                    return true;
+                }
             }
         }
     }
@@ -702,6 +733,7 @@
     
 }
 
+
 lldb::BreakpointSP
 Platform::SetThreadCreationBreakpoint (lldb_private::Target &target)
 {

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=172251&r1=172250&r2=172251&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Fri Jan 11 14:49:54 2013
@@ -2996,7 +2996,7 @@
     if (platform_sp)
     {
         const ArchSpec &target_arch = m_target.GetArchitecture();
-        if (target_arch.IsValid() && !platform_sp->IsCompatibleArchitecture (target_arch))
+        if (target_arch.IsValid() && !platform_sp->IsCompatibleArchitecture (target_arch, false, NULL))
         {
             ArchSpec platform_arch;
             platform_sp = platform_sp->GetPlatformForArchitecture (target_arch, &platform_arch);

Modified: lldb/trunk/source/Target/TargetList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=172251&r1=172250&r2=172251&view=diff
==============================================================================
--- lldb/trunk/source/Target/TargetList.cpp (original)
+++ lldb/trunk/source/Target/TargetList.cpp Fri Jan 11 14:49:54 2013
@@ -104,7 +104,7 @@
         // current architecture if we have a valid architecture.
         platform_sp = debugger.GetPlatformList().GetSelectedPlatform ();
         
-        if (arch.IsValid() && !platform_sp->IsCompatibleArchitecture(arch, &platform_arch))
+        if (arch.IsValid() && !platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch))
         {
             platform_sp = Platform::GetPlatformForArchitecture(arch, &platform_arch);
         }
@@ -142,7 +142,7 @@
     {
         if (arch.IsValid())
         {
-            if (!platform_sp->IsCompatibleArchitecture(arch))
+            if (!platform_sp->IsCompatibleArchitecture(arch, false, NULL))
                 platform_sp = Platform::GetPlatformForArchitecture(specified_arch, &arch);
         }
     }





More information about the lldb-commits mailing list