[Lldb-commits] [lldb] r199854 - Add support for Haswell on x86_64.

Greg Clayton gclayton at apple.com
Wed Jan 22 15:42:03 PST 2014


Author: gclayton
Date: Wed Jan 22 17:42:03 2014
New Revision: 199854

URL: http://llvm.org/viewvc/llvm-project?rev=199854&view=rev
Log:
Add support for Haswell on x86_64.

<rdar://problem/15312873>

Modified:
    lldb/trunk/include/lldb/Core/ArchSpec.h
    lldb/trunk/source/Core/ArchSpec.cpp
    lldb/trunk/source/Core/DataExtractor.cpp
    lldb/trunk/source/Host/macosx/Host.mm
    lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
    lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
    lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
    lldb/trunk/tools/debugserver/source/DNB.cpp

Modified: lldb/trunk/include/lldb/Core/ArchSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=199854&r1=199853&r2=199854&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ArchSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ArchSpec.h Wed Jan 22 17:42:03 2014
@@ -91,6 +91,7 @@ public:
         eCore_x86_32_i486sx,
         
         eCore_x86_64_x86_64,
+        eCore_x86_64_x86_64h, // Haswell enabled x86_64
         eCore_uknownMach32,
         eCore_uknownMach64,
         kNumCores,

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=199854&r1=199853&r2=199854&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Wed Jan 22 17:42:03 2014
@@ -104,6 +104,7 @@ static const CoreDefinition g_core_defin
     { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86    , ArchSpec::eCore_x86_32_i486sx  , "i486sx"    },
 
     { eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , ArchSpec::eCore_x86_64_x86_64  , "x86_64"    },
+    { eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , ArchSpec::eCore_x86_64_x86_64h , "x86_64h"   },
     { eByteOrderLittle, 4, 4, 4 , llvm::Triple::UnknownArch , ArchSpec::eCore_uknownMach32  , "unknown-mach-32" },
     { eByteOrderLittle, 8, 4, 4 , llvm::Triple::UnknownArch , ArchSpec::eCore_uknownMach64  , "unknown-mach-64" }
 };
@@ -205,10 +206,11 @@ static const ArchDefinitionEntry g_macho
     { ArchSpec::eCore_x86_32_i386     , llvm::MachO::CPU_TYPE_I386      , 3      , UINT32_MAX , SUBTYPE_MASK },
     { ArchSpec::eCore_x86_32_i486     , llvm::MachO::CPU_TYPE_I386      , 4      , UINT32_MAX , SUBTYPE_MASK },
     { ArchSpec::eCore_x86_32_i486sx   , llvm::MachO::CPU_TYPE_I386      , 0x84   , UINT32_MAX , SUBTYPE_MASK },
-    { ArchSpec::eCore_x86_32_i386     , llvm::MachO::CPU_TYPE_I386      , CPU_ANY, UINT32_MAX , UINT32_MAX  },
+    { ArchSpec::eCore_x86_32_i386     , llvm::MachO::CPU_TYPE_I386      , CPU_ANY, UINT32_MAX , UINT32_MAX   },
     { ArchSpec::eCore_x86_64_x86_64   , llvm::MachO::CPU_TYPE_X86_64    , 3      , UINT32_MAX , SUBTYPE_MASK },
     { ArchSpec::eCore_x86_64_x86_64   , llvm::MachO::CPU_TYPE_X86_64    , 4      , UINT32_MAX , SUBTYPE_MASK },
-    { ArchSpec::eCore_x86_64_x86_64   , llvm::MachO::CPU_TYPE_X86_64    , CPU_ANY, UINT32_MAX , UINT32_MAX  },
+    { ArchSpec::eCore_x86_64_x86_64h  , llvm::MachO::CPU_TYPE_X86_64    , 8      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_x86_64_x86_64   , llvm::MachO::CPU_TYPE_X86_64    , CPU_ANY, UINT32_MAX , UINT32_MAX   },
     // Catch any unknown mach architectures so we can always use the object and symbol mach-o files
     { ArchSpec::eCore_uknownMach32    , 0                               , 0      , 0xFF000000u, 0x00000000u },
     { ArchSpec::eCore_uknownMach64    , llvm::MachO::CPU_ARCH_ABI64     , 0      , 0xFF000000u, 0x00000000u }
@@ -894,7 +896,7 @@ cores_match (const ArchSpec::Core core1,
         if (core2 == ArchSpec::kCore_arm_any)
             return true;
         break;
-        
+    
     case ArchSpec::kCore_x86_32_any:
         if ((core2 >= ArchSpec::kCore_x86_32_first && core2 <= ArchSpec::kCore_x86_32_last) || (core2 == ArchSpec::kCore_x86_32_any))
             return true;

Modified: lldb/trunk/source/Core/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=199854&r1=199853&r2=199854&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataExtractor.cpp (original)
+++ lldb/trunk/source/Core/DataExtractor.cpp Wed Jan 22 17:42:03 2014
@@ -1809,6 +1809,7 @@ DataExtractor::Dump (Stream *s,
                                     case ArchSpec::eCore_x86_32_i486:
                                     case ArchSpec::eCore_x86_32_i486sx:
                                     case ArchSpec::eCore_x86_64_x86_64:
+                                    case ArchSpec::eCore_x86_64_x86_64h:
                                         // clang will assert when contructing the apfloat if we use a 16 byte integer value
                                         if (GetAPInt (*this, &offset, 10, apint))
                                         {

Modified: lldb/trunk/source/Host/macosx/Host.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=199854&r1=199853&r2=199854&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/Host.mm Wed Jan 22 17:42:03 2014
@@ -1625,9 +1625,11 @@ LaunchProcessPosixSpawn (const char *exe
     // to set which CPU subtype to launch...
     const ArchSpec &arch_spec = launch_info.GetArchitecture();
     cpu_type_t cpu = arch_spec.GetMachOCPUType();
-    if (cpu != 0 && 
+    cpu_type_t sub = arch_spec.GetMachOCPUSubType();
+    if (cpu != 0 &&
         cpu != UINT32_MAX && 
-        cpu != LLDB_INVALID_CPUTYPE)
+        cpu != LLDB_INVALID_CPUTYPE &&
+        !(cpu == 0x01000007 && sub == 8)) // If haswell is specified, don't try to set the CPU type or we will fail
     {
         size_t ocount = 0;
         error.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX);

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=199854&r1=199853&r2=199854&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp Wed Jan 22 17:42:03 2014
@@ -312,6 +312,7 @@ PlatformFreeBSD::GetSoftwareBreakpointTr
 
     case ArchSpec::eCore_x86_32_i386:
     case ArchSpec::eCore_x86_64_x86_64:
+    case ArchSpec::eCore_x86_64_x86_64h:
         {
             static const uint8_t g_i386_opcode[] = { 0xCC };
             trap_opcode = g_i386_opcode;

Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=199854&r1=199853&r2=199854&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Wed Jan 22 17:42:03 2014
@@ -390,6 +390,7 @@ PlatformLinux::GetSoftwareBreakpointTrap
 
     case ArchSpec::eCore_x86_32_i386:
     case ArchSpec::eCore_x86_64_x86_64:
+    case ArchSpec::eCore_x86_64_x86_64h:
         {
             static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC };
             trap_opcode = g_i386_breakpoint_opcode;

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=199854&r1=199853&r2=199854&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Wed Jan 22 17:42:03 2014
@@ -978,23 +978,46 @@ PlatformDarwin::GetQueueIDForThreadQAddr
 bool
 PlatformDarwin::x86GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
 {
-    if (idx == 0)
+    ArchSpec host_arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
+    if (host_arch.GetCore() == ArchSpec::eCore_x86_64_x86_64h)
     {
-        arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
-        return arch.IsValid();
+        switch (idx)
+        {
+            case 0:
+                arch = host_arch;
+                return true;
+
+            case 1:
+                arch.SetTriple("x86_64-apple-macosx");
+                return true;
+
+            case 2:
+                arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture32);
+                return true;
+
+            default: return false;
+        }
     }
-    else if (idx == 1)
+    else
     {
-        ArchSpec platform_arch (Host::GetArchitecture (Host::eSystemDefaultArchitecture));
-        ArchSpec platform_arch64 (Host::GetArchitecture (Host::eSystemDefaultArchitecture64));
-        if (platform_arch.IsExactMatch(platform_arch64))
+        if (idx == 0)
         {
-            // This macosx 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 = Host::GetArchitecture (Host::eSystemDefaultArchitecture32);
+            arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
             return arch.IsValid();
         }
+        else if (idx == 1)
+        {
+            ArchSpec platform_arch (Host::GetArchitecture (Host::eSystemDefaultArchitecture));
+            ArchSpec platform_arch64 (Host::GetArchitecture (Host::eSystemDefaultArchitecture64));
+            if (platform_arch.IsExactMatch(platform_arch64))
+            {
+                // This macosx 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 = Host::GetArchitecture (Host::eSystemDefaultArchitecture32);
+                return arch.IsValid();
+            }
+        }
     }
     return false;
 }

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp?rev=199854&r1=199853&r2=199854&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp Wed Jan 22 17:42:03 2014
@@ -22,11 +22,12 @@
 
 // Other libraries and framework includes
 // Project includes
-#include "lldb/Core/Error.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Core/Error.h"
 #include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
+#include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/StreamString.h"
 #include "lldb/Host/FileSpec.h"
@@ -325,5 +326,34 @@ PlatformMacOSX::GetSharedModule (const l
                                  lldb::ModuleSP *old_module_sp_ptr,
                                  bool *did_create_ptr)
 {
-    return GetSharedModuleWithLocalCache(module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
+    Error error = GetSharedModuleWithLocalCache(module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
+    
+    if (module_sp)
+    {
+        if (module_spec.GetArchitecture().GetCore() == ArchSpec::eCore_x86_64_x86_64h)
+        {
+            ObjectFile *objfile = module_sp->GetObjectFile();
+            if (objfile == NULL)
+            {
+                // We didn't find an x86_64h slice, fall back to a x86_64 slice
+                ModuleSpec module_spec_x86_64 (module_spec);
+                module_spec_x86_64.GetArchitecture() = ArchSpec("x86_64-apple-macosx");
+                lldb::ModuleSP x86_64_module_sp;
+                lldb::ModuleSP old_x86_64_module_sp;
+                bool did_create = false;
+                Error x86_64_error = GetSharedModuleWithLocalCache(module_spec_x86_64, x86_64_module_sp, module_search_paths_ptr, &old_x86_64_module_sp, &did_create);
+                if (x86_64_module_sp && x86_64_module_sp->GetObjectFile())
+                {
+                    module_sp = x86_64_module_sp;
+                    if (old_module_sp_ptr)
+                        *old_module_sp_ptr = old_x86_64_module_sp;
+                    if (did_create_ptr)
+                        *did_create_ptr = did_create;
+                    return x86_64_error;
+                }
+            }
+        }
+    }
+    return error;
 }
+

Modified: lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp?rev=199854&r1=199853&r2=199854&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp Wed Jan 22 17:42:03 2014
@@ -283,6 +283,7 @@ PlatformWindows::GetSoftwareBreakpointTr
     {
     case ArchSpec::eCore_x86_32_i386:
     case ArchSpec::eCore_x86_64_x86_64:
+    case ArchSpec::eCore_x86_64_x86_64h:
         {
             static const uint8_t g_i386_opcode[] = { 0xCC };
             trap_opcode = g_i386_opcode;

Modified: lldb/trunk/tools/debugserver/source/DNB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.cpp?rev=199854&r1=199853&r2=199854&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNB.cpp (original)
+++ lldb/trunk/tools/debugserver/source/DNB.cpp Wed Jan 22 17:42:03 2014
@@ -2067,7 +2067,7 @@ DNBSetArchitecture (const char *arch)
     {
         if (strcasecmp (arch, "i386") == 0)
             return DNBArchProtocol::SetArchitecture (CPU_TYPE_I386);
-        else if (strcasecmp (arch, "x86_64") == 0)
+        else if ((strcasecmp (arch, "x86_64") == 0) || (strcasecmp (arch, "x86_64h") == 0))
             return DNBArchProtocol::SetArchitecture (CPU_TYPE_X86_64);
         else if (strstr (arch, "arm") == arch)
             return DNBArchProtocol::SetArchitecture (CPU_TYPE_ARM);





More information about the lldb-commits mailing list