aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Utility/ArchSpec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Utility/ArchSpec.cpp')
-rw-r--r--lldb/source/Utility/ArchSpec.cpp54
1 files changed, 30 insertions, 24 deletions
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index 74a437042345..a99aed82bc88 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StringList.h"
@@ -357,10 +358,10 @@ static const ArchDefinitionEntry g_elf_arch_entries[] = {
0xFFFFFFFFu, 0xFFFFFFFFu}, // Intel MCU // FIXME: is this correct?
{ArchSpec::eCore_ppc_generic, llvm::ELF::EM_PPC, LLDB_INVALID_CPUTYPE,
0xFFFFFFFFu, 0xFFFFFFFFu}, // PowerPC
- {ArchSpec::eCore_ppc64le_generic, llvm::ELF::EM_PPC64, LLDB_INVALID_CPUTYPE,
- 0xFFFFFFFFu, 0xFFFFFFFFu}, // PowerPC64le
- {ArchSpec::eCore_ppc64_generic, llvm::ELF::EM_PPC64, LLDB_INVALID_CPUTYPE,
- 0xFFFFFFFFu, 0xFFFFFFFFu}, // PowerPC64
+ {ArchSpec::eCore_ppc64le_generic, llvm::ELF::EM_PPC64,
+ ArchSpec::eCore_ppc64le_generic, 0xFFFFFFFFu, 0xFFFFFFFFu}, // PowerPC64le
+ {ArchSpec::eCore_ppc64_generic, llvm::ELF::EM_PPC64,
+ ArchSpec::eCore_ppc64_generic, 0xFFFFFFFFu, 0xFFFFFFFFu}, // PowerPC64
{ArchSpec::eCore_arm_generic, llvm::ELF::EM_ARM, LLDB_INVALID_CPUTYPE,
0xFFFFFFFFu, 0xFFFFFFFFu}, // ARM
{ArchSpec::eCore_arm_aarch64, llvm::ELF::EM_AARCH64, LLDB_INVALID_CPUTYPE,
@@ -399,8 +400,8 @@ static const ArchDefinitionEntry g_elf_arch_entries[] = {
LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu}, // HEXAGON
{ArchSpec::eCore_arc, llvm::ELF::EM_ARC_COMPACT2, LLDB_INVALID_CPUTYPE,
0xFFFFFFFFu, 0xFFFFFFFFu}, // ARC
- {ArchSpec::eCore_avr, llvm::ELF::EM_AVR, LLDB_INVALID_CPUTYPE,
- 0xFFFFFFFFu, 0xFFFFFFFFu}, // AVR
+ {ArchSpec::eCore_avr, llvm::ELF::EM_AVR, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu,
+ 0xFFFFFFFFu}, // AVR
{ArchSpec::eCore_riscv32, llvm::ELF::EM_RISCV,
ArchSpec::eRISCVSubType_riscv32, 0xFFFFFFFFu, 0xFFFFFFFFu}, // riscv32
{ArchSpec::eCore_riscv64, llvm::ELF::EM_RISCV,
@@ -902,7 +903,7 @@ bool ArchSpec::SetArchitecture(ArchitectureType arch_type, uint32_t cpu,
m_triple.setArch(core_def->machine);
}
} else {
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET | LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_PLATFORM));
+ Log *log(GetLog(LLDBLog::Target | LLDBLog::Process | LLDBLog::Platform));
LLDB_LOGF(log,
"Unable to find a core definition for cpu 0x%" PRIx32
" sub %" PRId32,
@@ -978,7 +979,16 @@ bool ArchSpec::IsEqualTo(const ArchSpec &rhs, bool exact_match) const {
const llvm::Triple::VendorType lhs_triple_vendor = lhs_triple.getVendor();
const llvm::Triple::VendorType rhs_triple_vendor = rhs_triple.getVendor();
- if (lhs_triple_vendor != rhs_triple_vendor) {
+
+ const llvm::Triple::OSType lhs_triple_os = lhs_triple.getOS();
+ const llvm::Triple::OSType rhs_triple_os = rhs_triple.getOS();
+
+ bool both_windows = lhs_triple.isOSWindows() && rhs_triple.isOSWindows();
+
+ // On Windows, the vendor field doesn't have any practical effect, but
+ // it is often set to either "pc" or "w64".
+ if ((lhs_triple_vendor != rhs_triple_vendor) &&
+ (exact_match || !both_windows)) {
const bool rhs_vendor_specified = rhs.TripleVendorWasSpecified();
const bool lhs_vendor_specified = TripleVendorWasSpecified();
// Both architectures had the vendor specified, so if they aren't equal
@@ -992,8 +1002,6 @@ bool ArchSpec::IsEqualTo(const ArchSpec &rhs, bool exact_match) const {
return false;
}
- const llvm::Triple::OSType lhs_triple_os = lhs_triple.getOS();
- const llvm::Triple::OSType rhs_triple_os = rhs_triple.getOS();
const llvm::Triple::EnvironmentType lhs_triple_env =
lhs_triple.getEnvironment();
const llvm::Triple::EnvironmentType rhs_triple_env =
@@ -1031,6 +1039,9 @@ bool ArchSpec::IsEqualTo(const ArchSpec &rhs, bool exact_match) const {
return true;
}
+ if (!exact_match && both_windows)
+ return true; // The Windows environments (MSVC vs GNU) are compatible
+
return IsCompatibleEnvironment(lhs_triple_env, rhs_triple_env);
}
@@ -1395,23 +1406,18 @@ bool lldb_private::operator==(const ArchSpec &lhs, const ArchSpec &rhs) {
}
bool ArchSpec::IsFullySpecifiedTriple() const {
- const auto &user_specified_triple = GetTriple();
+ if (!TripleOSWasSpecified())
+ return false;
- bool user_triple_fully_specified = false;
+ if (!TripleVendorWasSpecified())
+ return false;
- if ((user_specified_triple.getOS() != llvm::Triple::UnknownOS) ||
- TripleOSWasSpecified()) {
- if ((user_specified_triple.getVendor() != llvm::Triple::UnknownVendor) ||
- TripleVendorWasSpecified()) {
- const unsigned unspecified = 0;
- if (!user_specified_triple.isOSDarwin() ||
- user_specified_triple.getOSMajorVersion() != unspecified) {
- user_triple_fully_specified = true;
- }
- }
- }
+ const unsigned unspecified = 0;
+ const llvm::Triple &triple = GetTriple();
+ if (triple.isOSDarwin() && triple.getOSMajorVersion() == unspecified)
+ return false;
- return user_triple_fully_specified;
+ return true;
}
void ArchSpec::PiecewiseTripleCompare(