diff options
6 files changed, 38 insertions, 24 deletions
diff --git a/lldb/include/lldb/Core/ArchSpec.h b/lldb/include/lldb/Core/ArchSpec.h index 648815c2137..75c7079be08 100644 --- a/lldb/include/lldb/Core/ArchSpec.h +++ b/lldb/include/lldb/Core/ArchSpec.h @@ -625,6 +625,7 @@ public: protected: bool IsEqualTo(const ArchSpec &rhs, bool exact_match) const; + void UpdateCore(); llvm::Triple m_triple; Core m_core = kCore_invalid; diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py index 38b55ef40c6..18c0da83260 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -39,7 +39,6 @@ class LinuxCoreTestCase(TestBase): super(LinuxCoreTestCase, self).tearDown() @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_i386(self): """Test that lldb can read the process information from an i386 linux core file.""" @@ -58,21 +57,18 @@ class LinuxCoreTestCase(TestBase): self.do_test("linux-mips64el-gnuabi64", self._mips64_n64_pid, self._mips_regions) @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions) @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_s390x(self): """Test that lldb can read the process information from an s390x linux core file.""" self.do_test("linux-s390x", self._s390x_pid, self._s390x_regions) @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_same_pid_running(self): """Test that we read the information from the core correctly even if we have a running @@ -102,7 +98,6 @@ class LinuxCoreTestCase(TestBase): self.RemoveTempFile("linux-x86_64-pid.core") @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_two_cores_same_pid(self): """Test that we handle the situation if we have two core files with the same PID @@ -132,7 +127,6 @@ class LinuxCoreTestCase(TestBase): self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions) @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_FPR_SSE(self): # check x86_64 core file diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py index 5b398c1ccf0..5a11a52e93a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py @@ -23,14 +23,12 @@ class GCoreTestCase(TestBase): _x86_64_pid = 5669 @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_i386(self): """Test that lldb can read the process information from an i386 linux core file.""" self.do_test("linux-i386", self._i386_pid) @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py index 4895c051d63..7cc3c0775ce 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py @@ -27,14 +27,12 @@ class LinuxCoreThreadsTestCase(TestBase): _x86_64_tid = 5250 @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_i386(self): """Test that lldb can read the process information from an i386 linux core file.""" self.do_test("linux-i386", self._i386_pid, self._i386_tid) @skipIf(oslist=['windows']) - @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199 @skipIf(triple='^mips') def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" diff --git a/lldb/source/Core/ArchSpec.cpp b/lldb/source/Core/ArchSpec.cpp index 60ee237aa0f..7c1b399177f 100644 --- a/lldb/source/Core/ArchSpec.cpp +++ b/lldb/source/Core/ArchSpec.cpp @@ -834,19 +834,7 @@ lldb::ByteOrder ArchSpec::GetByteOrder() const { bool ArchSpec::SetTriple(const llvm::Triple &triple) { m_triple = triple; - - llvm::StringRef arch_name(m_triple.getArchName()); - const CoreDefinition *core_def = FindCoreDefinition(arch_name); - if (core_def) { - m_core = core_def->core; - // Set the byte order to the default byte order for an architecture. - // This can be modified if needed for cases when cores handle both - // big and little endian - m_byte_order = core_def->default_byte_order; - } else { - Clear(); - } - + UpdateCore(); return IsValid(); } @@ -994,8 +982,10 @@ void ArchSpec::MergeFrom(const ArchSpec &other) { GetTriple().setVendor(other.GetTriple().getVendor()); if (TripleOSIsUnspecifiedUnknown() && !other.TripleOSIsUnspecifiedUnknown()) GetTriple().setOS(other.GetTriple().getOS()); - if (GetTriple().getArch() == llvm::Triple::UnknownArch) + if (GetTriple().getArch() == llvm::Triple::UnknownArch) { GetTriple().setArch(other.GetTriple().getArch()); + UpdateCore(); + } if (GetTriple().getEnvironment() == llvm::Triple::UnknownEnvironment && !TripleVendorWasSpecified()) { if (other.TripleVendorWasSpecified()) @@ -1190,6 +1180,20 @@ bool ArchSpec::IsEqualTo(const ArchSpec &rhs, bool exact_match) const { return false; } +void ArchSpec::UpdateCore() { + llvm::StringRef arch_name(m_triple.getArchName()); + const CoreDefinition *core_def = FindCoreDefinition(arch_name); + if (core_def) { + m_core = core_def->core; + // Set the byte order to the default byte order for an architecture. + // This can be modified if needed for cases when cores handle both + // big and little endian + m_byte_order = core_def->default_byte_order; + } else { + Clear(); + } +} + //===----------------------------------------------------------------------===// // Helper methods. diff --git a/lldb/unittests/Core/ArchSpecTest.cpp b/lldb/unittests/Core/ArchSpecTest.cpp index 32b363652f7..8fed7adba07 100644 --- a/lldb/unittests/Core/ArchSpecTest.cpp +++ b/lldb/unittests/Core/ArchSpecTest.cpp @@ -134,3 +134,22 @@ TEST(ArchSpecTest, TestSetTriple) { AS = ArchSpec(); EXPECT_FALSE(AS.SetTriple("")); } + +TEST(ArchSpecTest, MergeFrom) { + ArchSpec A; + ArchSpec B("x86_64-pc-linux"); + + EXPECT_FALSE(A.IsValid()); + ASSERT_TRUE(B.IsValid()); + EXPECT_EQ(llvm::Triple::ArchType::x86_64, B.GetTriple().getArch()); + EXPECT_EQ(llvm::Triple::VendorType::PC, B.GetTriple().getVendor()); + EXPECT_EQ(llvm::Triple::OSType::Linux, B.GetTriple().getOS()); + EXPECT_EQ(ArchSpec::eCore_x86_64_x86_64, B.GetCore()); + + A.MergeFrom(B); + ASSERT_TRUE(A.IsValid()); + EXPECT_EQ(llvm::Triple::ArchType::x86_64, A.GetTriple().getArch()); + EXPECT_EQ(llvm::Triple::VendorType::PC, A.GetTriple().getVendor()); + EXPECT_EQ(llvm::Triple::OSType::Linux, A.GetTriple().getOS()); + EXPECT_EQ(ArchSpec::eCore_x86_64_x86_64, A.GetCore()); +} |

