[Lldb-commits] [lldb] r238246 - Sync PlatformFreeBSD::GetSupportedArchitectureAtIndex with PlatformLinux

Ed Maste emaste at freebsd.org
Tue May 26 13:23:20 PDT 2015


Author: emaste
Date: Tue May 26 15:23:20 2015
New Revision: 238246

URL: http://llvm.org/viewvc/llvm-project?rev=238246&view=rev
Log:
Sync PlatformFreeBSD::GetSupportedArchitectureAtIndex with PlatformLinux

Reviewed by Ted Woodward
Differential Revision:	http://reviews.llvm.org/D9764

Modified:
    lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp

Modified: lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp?rev=238246&r1=238245&r2=238246&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp Tue May 26 15:23:20 2015
@@ -533,24 +533,56 @@ PlatformFreeBSD::GetSharedModule (const
 bool
 PlatformFreeBSD::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
 {
-    // From macosx;s plugin code. For FreeBSD we may want to support more archs.
-    if (idx == 0)
+    if (IsHost())
     {
-        arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
-        return arch.IsValid();
+        ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
+        if (hostArch.GetTriple().isOSFreeBSD())
+        {
+            if (idx == 0)
+            {
+                arch = hostArch;
+                return arch.IsValid();
+            }
+            else if (idx == 1)
+            {
+                // If the default host architecture is 64-bit, look for a 32-bit variant
+                if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit())
+                {
+                    arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
+                    return arch.IsValid();
+                }
+            }
+        }
     }
-    else if (idx == 1)
+    else
     {
-        ArchSpec platform_arch(HostInfo::GetArchitecture(HostInfo::eArchKindDefault));
-        ArchSpec platform_arch64(HostInfo::GetArchitecture(HostInfo::eArchKind64));
-        if (platform_arch.IsExactMatch(platform_arch64))
+        if (m_remote_platform_sp)
+            return m_remote_platform_sp->GetSupportedArchitectureAtIndex(idx, arch);
+
+        llvm::Triple triple;
+        // Set the OS to FreeBSD
+        triple.setOS(llvm::Triple::FreeBSD);
+        // Set the architecture
+        switch (idx)
         {
-            // This freebsd platform supports both 32 and 64 bit. Since we already
-            // returned the 64 bit arch for idx == 0, return the 32 bit arch
-            // for idx == 1
-            arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
-            return arch.IsValid();
+            case 0: triple.setArchName("x86_64"); break;
+            case 1: triple.setArchName("i386"); break;
+            case 2: triple.setArchName("aarch64"); break;
+            case 3: triple.setArchName("arm"); break;
+            case 4: triple.setArchName("mips64"); break;
+            case 5: triple.setArchName("mips"); break;
+            case 6: triple.setArchName("ppc64"); break;
+            case 7: triple.setArchName("ppc"); break;
+            default: return false;
         }
+        // Leave the vendor as "llvm::Triple:UnknownVendor" and don't specify the vendor by
+        // calling triple.SetVendorName("unknown") so that it is a "unspecified unknown".
+        // This means when someone calls triple.GetVendorName() it will return an empty string
+        // which indicates that the vendor can be set when two architectures are merged
+
+        // Now set the triple into "arch" and return true
+        arch.SetTriple(triple);
+        return true;
     }
     return false;
 }





More information about the lldb-commits mailing list