From 13b1826104584b362e83d15bc72799b03f28ebd2 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Wed, 20 Aug 2014 16:42:51 +0000 Subject: [PATCH] Move Host::GetArchitecture to HostInfo::GetArchitecture. As a side effect, this patch also eliminates all of the preprocessor conditionals previously used to implement GetArchitecture(). llvm-svn: 216074 --- lldb/include/lldb/Host/Host.h | 17 -- lldb/include/lldb/Host/HostInfoBase.h | 23 +++ lldb/include/lldb/Host/linux/HostInfoLinux.h | 4 + .../include/lldb/Host/macosx/HostInfoMacOSX.h | 7 + lldb/source/Core/ArchSpec.cpp | 15 +- lldb/source/Host/common/Host.cpp | 150 +----------------- lldb/source/Host/common/HostInfoBase.cpp | 61 ++++++- lldb/source/Host/freebsd/Host.cpp | 3 +- lldb/source/Host/linux/HostInfoLinux.cpp | 23 +++ lldb/source/Host/macosx/HostInfoMacOSX.mm | 66 ++++++++ .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 7 +- .../Platform/FreeBSD/PlatformFreeBSD.cpp | 11 +- .../Platform/Kalimba/PlatformKalimba.cpp | 4 +- .../Plugins/Platform/Linux/PlatformLinux.cpp | 13 +- .../Platform/MacOSX/PlatformDarwin.cpp | 13 +- .../Platform/MacOSX/PlatformMacOSX.cpp | 2 +- .../Platform/MacOSX/PlatformiOSSimulator.cpp | 7 +- .../Platform/Windows/PlatformWindows.cpp | 9 +- .../Process/Linux/NativeProcessLinux.cpp | 7 +- .../Process/Linux/NativeThreadLinux.cpp | 6 +- .../Plugins/Process/POSIX/POSIXThread.cpp | 10 +- .../GDBRemoteCommunicationServer.cpp | 2 +- lldb/source/Target/Platform.cpp | 2 +- 23 files changed, 239 insertions(+), 223 deletions(-) diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h index 55ccba6eb8d5..2a25c8f5325f 100644 --- a/lldb/include/lldb/Host/Host.h +++ b/lldb/include/lldb/Host/Host.h @@ -122,23 +122,6 @@ public: static void SystemLog (SystemLogType type, const char *format, va_list args); - //------------------------------------------------------------------ - /// Gets the host architecture. - /// - /// @return - /// A const architecture object that represents the host - /// architecture. - //------------------------------------------------------------------ - enum SystemDefaultArchitecture - { - eSystemDefaultArchitecture, // The overall default architecture that applications will run on this host - eSystemDefaultArchitecture32, // If this host supports 32 bit programs, return the default 32 bit arch - eSystemDefaultArchitecture64 // If this host supports 64 bit programs, return the default 64 bit arch - }; - - static const ArchSpec & - GetArchitecture (SystemDefaultArchitecture arch_kind = eSystemDefaultArchitecture); - //------------------------------------------------------------------ /// Get the process ID for the calling process. /// diff --git a/lldb/include/lldb/Host/HostInfoBase.h b/lldb/include/lldb/Host/HostInfoBase.h index af79314abad3..2d97ff308f40 100644 --- a/lldb/include/lldb/Host/HostInfoBase.h +++ b/lldb/include/lldb/Host/HostInfoBase.h @@ -10,6 +10,8 @@ #ifndef lldb_Host_HostInfoBase_h_ #define lldb_Host_HostInfoBase_h_ +#include "lldb/Core/ArchSpec.h" + #include "llvm/ADT/StringRef.h" #include @@ -60,11 +62,32 @@ class HostInfoBase //------------------------------------------------------------------ static llvm::StringRef GetTargetTriple(); + //------------------------------------------------------------------ + /// Gets the host architecture. + /// + /// @return + /// A const architecture object that represents the host + /// architecture. + //------------------------------------------------------------------ + enum ArchitectureKind + { + eArchKindDefault, // The overall default architecture that applications will run on this host + eArchKind32, // If this host supports 32 bit programs, return the default 32 bit arch + eArchKind64 // If this host supports 64 bit programs, return the default 64 bit arch + }; + + static const ArchSpec &GetArchitecture(ArchitectureKind arch_kind = eArchKindDefault); + protected: + static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64); + static uint32_t m_number_cpus; static std::string m_vendor_string; static std::string m_os_string; static std::string m_host_triple; + + static ArchSpec m_host_arch_32; + static ArchSpec m_host_arch_64; }; } diff --git a/lldb/include/lldb/Host/linux/HostInfoLinux.h b/lldb/include/lldb/Host/linux/HostInfoLinux.h index 84731d79ab45..e3031e59c4e2 100644 --- a/lldb/include/lldb/Host/linux/HostInfoLinux.h +++ b/lldb/include/lldb/Host/linux/HostInfoLinux.h @@ -20,6 +20,8 @@ namespace lldb_private class HostInfoLinux : public HostInfoPosix { + friend class HostInfoBase; + private: // Static class, unconstructable. HostInfoLinux(); @@ -30,6 +32,8 @@ class HostInfoLinux : public HostInfoPosix static llvm::StringRef GetDistributionId(); protected: + static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64); + static std::string m_distribution_id; static uint32_t m_os_major; static uint32_t m_os_minor; diff --git a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h index 039dcb4f7948..1c791557553c 100644 --- a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h +++ b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h @@ -15,8 +15,12 @@ namespace lldb_private { +class ArchSpec; + class HostInfoMacOSX : public HostInfoPosix { + friend class HostInfoBase; + private: // Static class, unconstructable. HostInfoMacOSX(); @@ -26,6 +30,9 @@ class HostInfoMacOSX : public HostInfoPosix static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update); static bool GetOSBuildString(std::string &s); static bool GetOSKernelDescription(std::string &s); + + protected: + static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64); }; } diff --git a/lldb/source/Core/ArchSpec.cpp b/lldb/source/Core/ArchSpec.cpp index 056de221a70e..d36411506305 100644 --- a/lldb/source/Core/ArchSpec.cpp +++ b/lldb/source/Core/ArchSpec.cpp @@ -20,8 +20,9 @@ #include "llvm/Support/Host.h" #include "lldb/Utility/SafeMachO.h" #include "lldb/Core/RegularExpression.h" +#include "lldb/Core/StringList.h" #include "lldb/Host/Endian.h" -#include "lldb/Host/Host.h" +#include "lldb/Host/HostInfo.h" #include "lldb/Target/Platform.h" using namespace lldb; @@ -620,11 +621,11 @@ ArchSpec::SetTriple (const char *triple_cstr) { // Special case for the current host default architectures... if (triple_stref.equals (LLDB_ARCH_DEFAULT_32BIT)) - *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture32); + *this = HostInfo::GetArchitecture(HostInfo::eArchKind32); else if (triple_stref.equals (LLDB_ARCH_DEFAULT_64BIT)) - *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture64); + *this = HostInfo::GetArchitecture(HostInfo::eArchKind64); else if (triple_stref.equals (LLDB_ARCH_DEFAULT)) - *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture); + *this = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); } else { @@ -651,11 +652,11 @@ ArchSpec::SetTriple (const char *triple_cstr, Platform *platform) { // Special case for the current host default architectures... if (triple_stref.equals (LLDB_ARCH_DEFAULT_32BIT)) - *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture32); + *this = HostInfo::GetArchitecture(HostInfo::eArchKind32); else if (triple_stref.equals (LLDB_ARCH_DEFAULT_64BIT)) - *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture64); + *this = HostInfo::GetArchitecture(HostInfo::eArchKind64); else if (triple_stref.equals (LLDB_ARCH_DEFAULT)) - *this = Host::GetArchitecture (Host::eSystemDefaultArchitecture); + *this = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); } else { diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index 43aa5bacfe03..3c2d098732f8 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -36,10 +36,6 @@ #include #include #include -#include -#ifndef CPU_SUBTYPE_X86_64_H -#define CPU_SUBTYPE_X86_64_H ((cpu_subtype_t)8) -#endif #endif #if defined (__linux__) || defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__) || defined(__NetBSD__) @@ -321,150 +317,6 @@ Host::SystemLog (SystemLogType type, const char *format, ...) va_end (args); } -const ArchSpec & -Host::GetArchitecture (SystemDefaultArchitecture arch_kind) -{ - static bool g_supports_32 = false; - static bool g_supports_64 = false; - static ArchSpec g_host_arch_32; - static ArchSpec g_host_arch_64; - -#if defined (__APPLE__) - - // Apple is different in that it can support both 32 and 64 bit executables - // in the same operating system running concurrently. Here we detect the - // correct host architectures for both 32 and 64 bit including if 64 bit - // executables are supported on the system. - - if (g_supports_32 == false && g_supports_64 == false) - { - // All apple systems support 32 bit execution. - g_supports_32 = true; - uint32_t cputype, cpusubtype; - uint32_t is_64_bit_capable = false; - size_t len = sizeof(cputype); - ArchSpec host_arch; - // These will tell us about the kernel architecture, which even on a 64 - // bit machine can be 32 bit... - if (::sysctlbyname("hw.cputype", &cputype, &len, NULL, 0) == 0) - { - len = sizeof (cpusubtype); - if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) != 0) - cpusubtype = CPU_TYPE_ANY; - - len = sizeof (is_64_bit_capable); - if (::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0) == 0) - { - if (is_64_bit_capable) - g_supports_64 = true; - } - - if (is_64_bit_capable) - { - if (cputype & CPU_ARCH_ABI64) - { - // We have a 64 bit kernel on a 64 bit system - g_host_arch_64.SetArchitecture (eArchTypeMachO, cputype, cpusubtype); - } - else - { - // We have a 64 bit kernel that is returning a 32 bit cputype, the - // cpusubtype will be correct as if it were for a 64 bit architecture - g_host_arch_64.SetArchitecture (eArchTypeMachO, cputype | CPU_ARCH_ABI64, cpusubtype); - } - - // Now we need modify the cpusubtype for the 32 bit slices. - uint32_t cpusubtype32 = cpusubtype; -#if defined (__i386__) || defined (__x86_64__) - if (cpusubtype == CPU_SUBTYPE_486 || cpusubtype == CPU_SUBTYPE_X86_64_H) - cpusubtype32 = CPU_SUBTYPE_I386_ALL; -#elif defined (__arm__) || defined (__arm64__) || defined (__aarch64__) - if (cputype == CPU_TYPE_ARM || cputype == CPU_TYPE_ARM64) - cpusubtype32 = CPU_SUBTYPE_ARM_V7S; -#endif - g_host_arch_32.SetArchitecture (eArchTypeMachO, cputype & ~(CPU_ARCH_MASK), cpusubtype32); - - if (cputype == CPU_TYPE_ARM || cputype == CPU_TYPE_ARM64) - { - g_host_arch_32.GetTriple().setOS(llvm::Triple::IOS); - g_host_arch_64.GetTriple().setOS(llvm::Triple::IOS); - } - else - { - g_host_arch_32.GetTriple().setOS(llvm::Triple::MacOSX); - g_host_arch_64.GetTriple().setOS(llvm::Triple::MacOSX); - } - } - else - { - // We have a 32 bit kernel on a 32 bit system - g_host_arch_32.SetArchitecture (eArchTypeMachO, cputype, cpusubtype); - g_host_arch_64.Clear(); - } - } - } - -#else // #if defined (__APPLE__) - - if (g_supports_32 == false && g_supports_64 == false) - { - llvm::Triple triple(llvm::sys::getDefaultTargetTriple()); - - g_host_arch_32.Clear(); - g_host_arch_64.Clear(); - - // If the OS is Linux, "unknown" in the vendor slot isn't what we want - // for the default triple. It's probably an artifact of config.guess. - if (triple.getOS() == llvm::Triple::Linux && triple.getVendor() == llvm::Triple::UnknownVendor) - triple.setVendorName (""); -#if defined(__linux__) - const char *distribution_id = HostInfo::GetDistributionId().data(); -#else - const char *distribution_id = ""; -#endif - switch (triple.getArch()) - { - default: - g_host_arch_32.SetTriple(triple); - g_host_arch_32.SetDistributionId (distribution_id); - g_supports_32 = true; - break; - - case llvm::Triple::x86_64: - g_host_arch_64.SetTriple(triple); - g_host_arch_64.SetDistributionId (distribution_id); - g_supports_64 = true; - g_host_arch_32.SetTriple(triple.get32BitArchVariant()); - g_host_arch_32.SetDistributionId (distribution_id); - g_supports_32 = true; - break; - - case llvm::Triple::mips64: - case llvm::Triple::sparcv9: - case llvm::Triple::ppc64: - g_host_arch_64.SetTriple(triple); - g_host_arch_64.SetDistributionId (distribution_id); - g_supports_64 = true; - break; - } - - g_supports_32 = g_host_arch_32.IsValid(); - g_supports_64 = g_host_arch_64.IsValid(); - } - -#endif // #else for #if defined (__APPLE__) - - if (arch_kind == eSystemDefaultArchitecture32) - return g_host_arch_32; - else if (arch_kind == eSystemDefaultArchitecture64) - return g_host_arch_64; - - if (g_supports_64) - return g_host_arch_64; - - return g_host_arch_32; -} - lldb::pid_t Host::GetCurrentProcessID() { @@ -1475,7 +1327,7 @@ Host::GetDummyTarget (lldb_private::Debugger &debugger) { ArchSpec arch(Target::GetDefaultArchitecture()); if (!arch.IsValid()) - arch = Host::GetArchitecture (); + arch = HostInfo::GetArchitecture(); Error err = debugger.GetTargetList().CreateTarget(debugger, NULL, arch.GetTriple().getTriple().c_str(), diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp index 5433bf0e568f..3b90680d4512 100644 --- a/lldb/source/Host/common/HostInfoBase.cpp +++ b/lldb/source/Host/common/HostInfoBase.cpp @@ -10,8 +10,12 @@ #include "lldb/Host/Config.h" #include "lldb/Core/ArchSpec.h" -#include "lldb/Host/HostInfoBase.h" #include "lldb/Host/Host.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Host/HostInfoBase.h" + +#include "llvm/ADT/Triple.h" +#include "llvm/Support/Host.h" #include @@ -22,6 +26,8 @@ uint32_t HostInfoBase::m_number_cpus = 0; std::string HostInfoBase::m_vendor_string; std::string HostInfoBase::m_os_string; std::string HostInfoBase::m_host_triple; +ArchSpec HostInfoBase::m_host_arch_32; +ArchSpec HostInfoBase::m_host_arch_64; uint32_t HostInfoBase::GetNumberCPUS() @@ -42,7 +48,7 @@ HostInfoBase::GetVendorString() static bool is_initialized = false; if (!is_initialized) { - const ArchSpec &host_arch = Host::GetArchitecture(); + const ArchSpec &host_arch = HostInfo::GetArchitecture(); const llvm::StringRef &str_ref = host_arch.GetTriple().getVendorName(); m_vendor_string.assign(str_ref.begin(), str_ref.end()); is_initialized = true; @@ -56,7 +62,7 @@ HostInfoBase::GetOSString() static bool is_initialized = false; if (!is_initialized) { - const ArchSpec &host_arch = Host::GetArchitecture(); + const ArchSpec &host_arch = HostInfo::GetArchitecture(); const llvm::StringRef &str_ref = host_arch.GetTriple().getOSName(); m_os_string.assign(str_ref.begin(), str_ref.end()); is_initialized = true; @@ -70,9 +76,56 @@ HostInfoBase::GetTargetTriple() static bool is_initialized = false; if (!is_initialized) { - const ArchSpec &host_arch = Host::GetArchitecture(); + const ArchSpec &host_arch = HostInfo::GetArchitecture(); m_host_triple = host_arch.GetTriple().getTriple(); is_initialized = true; } return m_host_triple; } + +const ArchSpec & +HostInfoBase::GetArchitecture(ArchitectureKind arch_kind) +{ + static bool is_initialized = false; + if (!is_initialized) + { + HostInfo::ComputeHostArchitectureSupport(m_host_arch_32, m_host_arch_64); + is_initialized = true; + } + + // If an explicit 32 or 64-bit architecture was requested, return that. + if (arch_kind == eArchKind32) + return m_host_arch_32; + if (arch_kind == eArchKind64) + return m_host_arch_64; + + // Otherwise prefer the 64-bit architecture if it is valid. + return (m_host_arch_64.IsValid()) ? m_host_arch_64 : m_host_arch_32; +} + +void +HostInfoBase::ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64) +{ + llvm::Triple triple(llvm::sys::getDefaultTargetTriple()); + + arch_32.Clear(); + arch_64.Clear(); + + switch (triple.getArch()) + { + default: + arch_32.SetTriple(triple); + break; + + case llvm::Triple::x86_64: + arch_64.SetTriple(triple); + arch_32.SetTriple(triple.get32BitArchVariant()); + break; + + case llvm::Triple::mips64: + case llvm::Triple::sparcv9: + case llvm::Triple::ppc64: + arch_64.SetTriple(triple); + break; + } +} diff --git a/lldb/source/Host/freebsd/Host.cpp b/lldb/source/Host/freebsd/Host.cpp index bd13ff76392a..8174015b8289 100644 --- a/lldb/source/Host/freebsd/Host.cpp +++ b/lldb/source/Host/freebsd/Host.cpp @@ -26,6 +26,7 @@ #include "lldb/Core/Error.h" #include "lldb/Host/Endian.h" #include "lldb/Host/Host.h" +#include "lldb/Host/HostInfo.h" #include "lldb/Core/Module.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/StreamFile.h" @@ -222,7 +223,7 @@ GetFreeBSDProcessCPUType (ProcessInstanceInfo &process_info) { if (process_info.ProcessIDIsValid()) { - process_info.GetArchitecture() = Host::GetArchitecture (Host::eSystemDefaultArchitecture); + process_info.GetArchitecture() = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); return true; } process_info.GetArchitecture().Clear(); diff --git a/lldb/source/Host/linux/HostInfoLinux.cpp b/lldb/source/Host/linux/HostInfoLinux.cpp index 8e620f43ca64..53a42d3d8464 100644 --- a/lldb/source/Host/linux/HostInfoLinux.cpp +++ b/lldb/source/Host/linux/HostInfoLinux.cpp @@ -147,3 +147,26 @@ HostInfoLinux::GetDistributionId() return m_distribution_id.c_str(); } + +void +HostInfoLinux::ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64) +{ + HostInfoPosix::ComputeHostArchitectureSupport(arch_32, arch_64); + + const char *distribution_id = GetDistributionId().data(); + + // On Linux, "unknown" in the vendor slot isn't what we want for the default + // triple. It's probably an artifact of config.guess. + if (arch_32.IsValid()) + { + arch_32.SetDistributionId(distribution_id); + if (arch_32.GetTriple().getVendor() == llvm::Triple::UnknownVendor) + arch_32.GetTriple().setVendorName(""); + } + if (arch_64.IsValid()) + { + arch_64.SetDistributionId(distribution_id); + if (arch_64.GetTriple().getVendor() == llvm::Triple::UnknownVendor) + arch_64.GetTriple().setVendorName(""); + } +} diff --git a/lldb/source/Host/macosx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/HostInfoMacOSX.mm index 5f1540293021..f8d83a23ff70 100644 --- a/lldb/source/Host/macosx/HostInfoMacOSX.mm +++ b/lldb/source/Host/macosx/HostInfoMacOSX.mm @@ -10,6 +10,8 @@ #include "lldb/Host/macosx/HostInfoMacOSX.h" #include "lldb/Interpreter/Args.h" +#include "lldb/Utility/SafeMachO.h" + // C++ Includes #include @@ -83,3 +85,67 @@ HostInfoMacOSX::GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update) } return false; } + +void +HostInfoMacOSX::ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64) +{ + // All apple systems support 32 bit execution. + uint32_t cputype, cpusubtype; + uint32_t is_64_bit_capable = false; + size_t len = sizeof(cputype); + ArchSpec host_arch; + // These will tell us about the kernel architecture, which even on a 64 + // bit machine can be 32 bit... + if (::sysctlbyname("hw.cputype", &cputype, &len, NULL, 0) == 0) + { + len = sizeof(cpusubtype); + if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) != 0) + cpusubtype = CPU_TYPE_ANY; + + len = sizeof(is_64_bit_capable); + ::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0); + + if (is_64_bit_capable) + { + if (cputype & CPU_ARCH_ABI64) + { + // We have a 64 bit kernel on a 64 bit system + arch_64.SetArchitecture(eArchTypeMachO, cputype, cpusubtype); + } + else + { + // We have a 64 bit kernel that is returning a 32 bit cputype, the + // cpusubtype will be correct as if it were for a 64 bit architecture + arch_64.SetArchitecture(eArchTypeMachO, cputype | CPU_ARCH_ABI64, cpusubtype); + } + + // Now we need modify the cpusubtype for the 32 bit slices. + uint32_t cpusubtype32 = cpusubtype; +#if defined(__i386__) || defined(__x86_64__) + if (cpusubtype == CPU_SUBTYPE_486 || cpusubtype == CPU_SUBTYPE_X86_64_H) + cpusubtype32 = CPU_SUBTYPE_I386_ALL; +#elif defined(__arm__) || defined(__arm64__) || defined(__aarch64__) + if (cputype == CPU_TYPE_ARM || cputype == CPU_TYPE_ARM64) + cpusubtype32 = CPU_SUBTYPE_ARM_V7S; +#endif + arch_32.SetArchitecture(eArchTypeMachO, cputype & ~(CPU_ARCH_MASK), cpusubtype32); + + if (cputype == CPU_TYPE_ARM || cputype == CPU_TYPE_ARM64) + { + arch_32.GetTriple().setOS(llvm::Triple::IOS); + arch_64.GetTriple().setOS(llvm::Triple::IOS); + } + else + { + arch_32.GetTriple().setOS(llvm::Triple::MacOSX); + arch_64.GetTriple().setOS(llvm::Triple::MacOSX); + } + } + else + { + // We have a 32 bit kernel on a 32 bit system + arch_32.SetArchitecture(eArchTypeMachO, cputype, cpusubtype); + arch_64.Clear(); + } + } +} diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 606d1f879f18..946557060e27 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -27,7 +27,6 @@ #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" -#include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "llvm/ADT/PointerUnion.h" @@ -588,7 +587,7 @@ ObjectFileELF::GetModuleSpecifications (const lldb_private::FileSpec& file, llvm::Triple &spec_triple = spec.GetArchitecture ().GetTriple (); if (spec_triple.getVendor () == llvm::Triple::VendorType::UnknownVendor) { - const llvm::Triple &host_triple = Host::GetArchitecture ().GetTriple (); + const llvm::Triple &host_triple = HostInfo::GetArchitecture().GetTriple(); if (spec_triple.getOS () == host_triple.getOS ()) spec_triple.setVendor (host_triple.getVendor ()); } @@ -1276,7 +1275,7 @@ ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl §ion_headers, { case 4: { - const ArchSpec host_arch32 = Host::GetArchitecture (Host::eSystemDefaultArchitecture32); + const ArchSpec host_arch32 = HostInfo::GetArchitecture(HostInfo::eArchKind32); if (host_arch32.GetCore() == arch_spec.GetCore()) { arch_spec.GetTriple().setOSName(HostInfo::GetOSString().data()); @@ -1286,7 +1285,7 @@ ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl §ion_headers, break; case 8: { - const ArchSpec host_arch64 = Host::GetArchitecture (Host::eSystemDefaultArchitecture64); + const ArchSpec host_arch64 = HostInfo::GetArchitecture(HostInfo::eArchKind64); if (host_arch64.GetCore() == arch_spec.GetCore()) { arch_spec.GetTriple().setOSName(HostInfo::GetOSString().data()); diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp index b7744c0d1c52..7aa940a530b4 100644 --- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -27,6 +27,7 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Host/Host.h" +#include "lldb/Host/HostInfo.h" using namespace lldb; using namespace lldb_private; @@ -122,7 +123,7 @@ PlatformFreeBSD::Initialize () #if defined (__FreeBSD__) // Force a host flag to true for the default platform object. PlatformSP default_platform_sp (new PlatformFreeBSD(true)); - default_platform_sp->SetSystemArchitecture (Host::GetArchitecture()); + default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); Platform::SetDefaultPlatform (default_platform_sp); #endif PluginManager::RegisterPlugin(PlatformFreeBSD::GetPluginNameStatic(false), @@ -638,19 +639,19 @@ PlatformFreeBSD::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) // From macosx;s plugin code. For FreeBSD we may want to support more archs. if (idx == 0) { - arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture); + arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); return arch.IsValid(); } else if (idx == 1) { - ArchSpec platform_arch (Host::GetArchitecture (Host::eSystemDefaultArchitecture)); - ArchSpec platform_arch64 (Host::GetArchitecture (Host::eSystemDefaultArchitecture64)); + ArchSpec platform_arch(HostInfo::GetArchitecture(HostInfo::eArchKindDefault)); + ArchSpec platform_arch64(HostInfo::GetArchitecture(HostInfo::eArchKind64)); if (platform_arch.IsExactMatch(platform_arch64)) { // 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 = Host::GetArchitecture (Host::eSystemDefaultArchitecture32); + arch = HostInfo::GetArchitecture(HostInfo::eArchKind32); return arch.IsValid(); } } diff --git a/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp b/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp index 549dd93d6668..f1bfadd662a5 100644 --- a/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp +++ b/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp @@ -23,7 +23,7 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamString.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Host/Host.h" +#include "lldb/Host/HostInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/Process.h" @@ -131,7 +131,7 @@ PlatformKalimba::ResolveExecutable (const FileSpec &exe_file, bool is_os_specified = (module_triple.getOS() != llvm::Triple::UnknownOS); if (!is_vendor_specified || !is_os_specified) { - const llvm::Triple &host_triple = Host::GetArchitecture (Host::eSystemDefaultArchitecture).GetTriple(); + const llvm::Triple &host_triple = HostInfo::GetArchitecture(HostInfo::eArchKindDefault).GetTriple(); if (!is_vendor_specified) module_triple.setVendorName (host_triple.getVendorName()); diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index 5b3615bb0f4b..a717c85a1eda 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -30,7 +30,7 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamString.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Host/Host.h" +#include "lldb/Host/HostInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/Process.h" @@ -155,7 +155,7 @@ PlatformLinux::Initialize () { #if defined(__linux__) PlatformSP default_platform_sp (new PlatformLinux(true)); - default_platform_sp->SetSystemArchitecture (Host::GetArchitecture()); + default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); Platform::SetDefaultPlatform (default_platform_sp); #endif PluginManager::RegisterPlugin(PlatformLinux::GetPluginNameStatic(false), @@ -248,7 +248,7 @@ PlatformLinux::ResolveExecutable (const FileSpec &exe_file, bool is_os_specified = (module_triple.getOS() != llvm::Triple::UnknownOS); if (!is_vendor_specified || !is_os_specified) { - const llvm::Triple &host_triple = Host::GetArchitecture (Host::eSystemDefaultArchitecture).GetTriple(); + const llvm::Triple &host_triple = HostInfo::GetArchitecture(HostInfo::eArchKindDefault).GetTriple(); if (!is_vendor_specified) module_triple.setVendorName (host_triple.getVendorName()); @@ -374,17 +374,16 @@ PlatformLinux::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) { if (idx == 0) { - arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture); + arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); return arch.IsValid(); } else if (idx == 1) { // If the default host architecture is 64-bit, look for a 32-bit variant - ArchSpec hostArch - = Host::GetArchitecture(Host::eSystemDefaultArchitecture); + ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit()) { - arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture32); + arch = HostInfo::GetArchitecture(HostInfo::eArchKind32); return arch.IsValid(); } } diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 71740c163560..8f7582b1e3c1 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -23,6 +23,7 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" +#include "lldb/Host/HostInfo.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Symbols.h" #include "lldb/Symbol/ObjectFile.h" @@ -761,7 +762,7 @@ PlatformDarwin::ModuleIsExcludedForNonModuleSpecificSearches (lldb_private::Targ bool PlatformDarwin::x86GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) { - ArchSpec host_arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture); + ArchSpec host_arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); if (host_arch.GetCore() == ArchSpec::eCore_x86_64_x86_64h) { switch (idx) @@ -775,7 +776,7 @@ PlatformDarwin::x86GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch return true; case 2: - arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture32); + arch = HostInfo::GetArchitecture(HostInfo::eArchKind32); return true; default: return false; @@ -785,19 +786,19 @@ PlatformDarwin::x86GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch { if (idx == 0) { - arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture); + arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); return arch.IsValid(); } else if (idx == 1) { - ArchSpec platform_arch (Host::GetArchitecture (Host::eSystemDefaultArchitecture)); - ArchSpec platform_arch64 (Host::GetArchitecture (Host::eSystemDefaultArchitecture64)); + ArchSpec platform_arch(HostInfo::GetArchitecture(HostInfo::eArchKindDefault)); + ArchSpec platform_arch64(HostInfo::GetArchitecture(HostInfo::eArchKind64)); 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); + arch = HostInfo::GetArchitecture(HostInfo::eArchKind32); return arch.IsValid(); } } diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp index 6fb0079b23b6..8f7e7520f5e3 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -44,7 +44,7 @@ PlatformMacOSX::Initialize () { #if defined (__APPLE__) PlatformSP default_platform_sp (new PlatformMacOSX(true)); - default_platform_sp->SetSystemArchitecture (Host::GetArchitecture()); + default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); Platform::SetDefaultPlatform (default_platform_sp); #endif PluginManager::RegisterPlugin (PlatformMacOSX::GetPluginNameStatic(false), diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp index cc1f432aab82..0d4523e46b07 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp @@ -23,6 +23,7 @@ #include "lldb/Core/StreamString.h" #include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" +#include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" @@ -425,8 +426,8 @@ PlatformiOSSimulator::FindProcesses (const ProcessInstanceInfoMatch &match_info, bool PlatformiOSSimulator::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) { - static const ArchSpec platform_arch (Host::GetArchitecture (Host::eSystemDefaultArchitecture)); - static const ArchSpec platform_arch64 (Host::GetArchitecture (Host::eSystemDefaultArchitecture64)); + static const ArchSpec platform_arch(HostInfo::GetArchitecture(HostInfo::eArchKindDefault)); + static const ArchSpec platform_arch64(HostInfo::GetArchitecture(HostInfo::eArchKind64)); if (idx == 0) { @@ -450,7 +451,7 @@ PlatformiOSSimulator::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &a } else if (idx == 2 || idx == 3) { - arch = Host::GetArchitecture (Host::eSystemDefaultArchitecture32); + arch = HostInfo::GetArchitecture(HostInfo::eArchKind32); if (arch.IsValid()) { if (idx == 2) diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp index 331f2c30cdd5..82015e4613a8 100644 --- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp +++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp @@ -22,7 +22,6 @@ #include "lldb/Core/Error.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/Module.h" @@ -41,9 +40,9 @@ namespace SupportedArchList() { AddArch(ArchSpec("i686-pc-windows")); - AddArch(Host::GetArchitecture(Host::eSystemDefaultArchitecture)); - AddArch(Host::GetArchitecture(Host::eSystemDefaultArchitecture32)); - AddArch(Host::GetArchitecture(Host::eSystemDefaultArchitecture64)); + AddArch(HostInfo::GetArchitecture(HostInfo::eArchKindDefault)); + AddArch(HostInfo::GetArchitecture(HostInfo::eArchKind32)); + AddArch(HostInfo::GetArchitecture(HostInfo::eArchKind64)); AddArch(ArchSpec("i386-pc-windows")); } @@ -154,7 +153,7 @@ PlatformWindows::Initialize(void) WSAStartup(MAKEWORD(2,2), &dummy); // Force a host flag to true for the default platform object. PlatformSP default_platform_sp (new PlatformWindows(true)); - default_platform_sp->SetSystemArchitecture (Host::GetArchitecture()); + default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); Platform::SetDefaultPlatform (default_platform_sp); #endif PluginManager::RegisterPlugin(PlatformWindows::GetPluginNameStatic(false), diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index 9d88bb26535a..32915d2b4e43 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -38,6 +38,7 @@ #include "lldb/Core/Scalar.h" #include "lldb/Core/State.h" #include "lldb/Host/Host.h" +#include "lldb/Host/HostInfo.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/NativeRegisterContext.h" #include "lldb/Target/ProcessLaunchInfo.h" @@ -1266,10 +1267,8 @@ NativeProcessLinux::AttachToInferior (lldb::pid_t pid, lldb_private::Error &erro ModuleSP exe_module_sp; FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths()); - error = platform_sp->ResolveExecutable(process_info.GetExecutableFile(), - Host::GetArchitecture(), - exe_module_sp, - executable_search_paths.GetSize() ? &executable_search_paths : NULL); + error = platform_sp->ResolveExecutable(process_info.GetExecutableFile(), HostInfo::GetArchitecture(), exe_module_sp, + executable_search_paths.GetSize() ? &executable_search_paths : NULL); if (!error.Success()) return; diff --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp index d5f2753e5a34..a1b674efee7f 100644 --- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -17,6 +17,7 @@ #include "lldb/Core/Log.h" #include "lldb/Core/State.h" #include "lldb/Host/Host.h" +#include "lldb/Host/HostInfo.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-private-log.h" #include "Plugins/Process/Utility/RegisterContextLinux_i386.h" @@ -129,14 +130,15 @@ NativeThreadLinux::GetRegisterContext () { case llvm::Triple::x86: case llvm::Triple::x86_64: - if (Host::GetArchitecture().GetAddressByteSize() == 4) + if (HostInfo::GetArchitecture().GetAddressByteSize() == 4) { // 32-bit hosts run with a RegisterContextLinux_i386 context. reg_interface = static_cast(new RegisterContextLinux_i386(target_arch)); } else { - assert((Host::GetArchitecture ().GetAddressByteSize () == 8) && "Register setting path assumes this is a 64-bit host"); + assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) && + "Register setting path assumes this is a 64-bit host"); // X86_64 hosts know how to work with 64-bit and 32-bit EXEs using the x86_64 register context. reg_interface = static_cast (new RegisterContextLinux_x86_64 (target_arch)); } diff --git a/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp b/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp index 47b50c573765..53b0d6d16e46 100644 --- a/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp +++ b/lldb/source/Plugins/Process/POSIX/POSIXThread.cpp @@ -20,6 +20,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/State.h" #include "lldb/Host/Host.h" +#include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" @@ -180,14 +181,15 @@ POSIXThread::GetRegisterContext() { case llvm::Triple::x86: case llvm::Triple::x86_64: - if (Host::GetArchitecture().GetAddressByteSize() == 4) + if (HostInfo::GetArchitecture().GetAddressByteSize() == 4) { // 32-bit hosts run with a RegisterContextLinux_i386 context. reg_interface = static_cast(new RegisterContextLinux_i386(target_arch)); } else { - assert((Host::GetArchitecture().GetAddressByteSize() == 8) && "Register setting path assumes this is a 64-bit host"); + assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) && + "Register setting path assumes this is a 64-bit host"); // X86_64 hosts know how to work with 64-bit and 32-bit EXEs using the x86_64 register context. reg_interface = static_cast(new RegisterContextLinux_x86_64(target_arch)); } @@ -596,7 +598,7 @@ unsigned POSIXThread::GetRegisterIndexFromOffset(unsigned offset) { unsigned reg = LLDB_INVALID_REGNUM; - ArchSpec arch = Host::GetArchitecture(); + ArchSpec arch = HostInfo::GetArchitecture(); switch (arch.GetMachine()) { @@ -626,7 +628,7 @@ const char * POSIXThread::GetRegisterName(unsigned reg) { const char * name = nullptr; - ArchSpec arch = Host::GetArchitecture(); + ArchSpec arch = HostInfo::GetArchitecture(); switch (arch.GetMachine()) { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp index 965382026258..dc99a990c5f5 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp @@ -1188,7 +1188,7 @@ GDBRemoteCommunicationServer::Handle_qHostInfo (StringExtractorGDBRemote &packet // $cputype:16777223;cpusubtype:3;ostype:Darwin;vendor:apple;endian:little;ptrsize:8;#00 - ArchSpec host_arch (Host::GetArchitecture ()); + ArchSpec host_arch(HostInfo::GetArchitecture()); const llvm::Triple &host_triple = host_arch.GetTriple(); response.PutCString("triple:"); response.PutCString(host_triple.getTriple().c_str()); diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index 2392efd3f4f8..5082b908b2e6 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -914,7 +914,7 @@ Platform::GetSystemArchitecture() if (!m_system_arch.IsValid()) { // We have a local host platform - m_system_arch = Host::GetArchitecture(); + m_system_arch = HostInfo::GetArchitecture(); m_system_arch_set_while_connected = m_system_arch.IsValid(); } }