[Lldb-commits] [PATCH] D70155: [LLDB] Avoid triple corruption while merging core info from platform and target triples
This revision was automatically updated to reflect the committed changes. Closed by commit rG8b8185bb1b45: Avoid triple corruption while merging core info (authored by omjavaid). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70155/new/ https://reviews.llvm.org/D70155 Files: lldb/source/Utility/ArchSpec.cpp lldb/unittests/Utility/ArchSpecTest.cpp Index: lldb/unittests/Utility/ArchSpecTest.cpp === --- lldb/unittests/Utility/ArchSpecTest.cpp +++ lldb/unittests/Utility/ArchSpecTest.cpp @@ -216,6 +216,41 @@ EXPECT_EQ(llvm::Triple::EnvironmentType::UnknownEnvironment, A.GetTriple().getEnvironment()); } + { +ArchSpec A("arm--linux-eabihf"); +ArchSpec B("armv8l--linux-gnueabihf"); + +EXPECT_TRUE(A.IsValid()); +EXPECT_TRUE(B.IsValid()); + +EXPECT_EQ(llvm::Triple::ArchType::arm, A.GetTriple().getArch()); +EXPECT_EQ(llvm::Triple::ArchType::arm, B.GetTriple().getArch()); + +EXPECT_EQ(ArchSpec::eCore_arm_generic, A.GetCore()); +EXPECT_EQ(ArchSpec::eCore_arm_armv8l, B.GetCore()); + +EXPECT_EQ(llvm::Triple::VendorType::UnknownVendor, + A.GetTriple().getVendor()); +EXPECT_EQ(llvm::Triple::VendorType::UnknownVendor, + B.GetTriple().getVendor()); + +EXPECT_EQ(llvm::Triple::OSType::Linux, A.GetTriple().getOS()); +EXPECT_EQ(llvm::Triple::OSType::Linux, B.GetTriple().getOS()); + +EXPECT_EQ(llvm::Triple::EnvironmentType::EABIHF, + A.GetTriple().getEnvironment()); +EXPECT_EQ(llvm::Triple::EnvironmentType::GNUEABIHF, + B.GetTriple().getEnvironment()); + +A.MergeFrom(B); +EXPECT_EQ(llvm::Triple::ArchType::arm, A.GetTriple().getArch()); +EXPECT_EQ(ArchSpec::eCore_arm_armv8l, A.GetCore()); +EXPECT_EQ(llvm::Triple::VendorType::UnknownVendor, + A.GetTriple().getVendor()); +EXPECT_EQ(llvm::Triple::OSType::Linux, A.GetTriple().getOS()); +EXPECT_EQ(llvm::Triple::EnvironmentType::EABIHF, + A.GetTriple().getEnvironment()); + } } TEST(ArchSpecTest, MergeFromMachOUnknown) { Index: lldb/source/Utility/ArchSpec.cpp === --- lldb/source/Utility/ArchSpec.cpp +++ lldb/source/Utility/ArchSpec.cpp @@ -868,7 +868,7 @@ IsCompatibleMatch(other) && GetCore() == ArchSpec::eCore_arm_generic && other.GetCore() != ArchSpec::eCore_arm_generic) { m_core = other.GetCore(); -CoreUpdated(true); +CoreUpdated(false); } if (GetFlags() == 0) { SetFlags(other.GetFlags()); Index: lldb/unittests/Utility/ArchSpecTest.cpp === --- lldb/unittests/Utility/ArchSpecTest.cpp +++ lldb/unittests/Utility/ArchSpecTest.cpp @@ -216,6 +216,41 @@ EXPECT_EQ(llvm::Triple::EnvironmentType::UnknownEnvironment, A.GetTriple().getEnvironment()); } + { +ArchSpec A("arm--linux-eabihf"); +ArchSpec B("armv8l--linux-gnueabihf"); + +EXPECT_TRUE(A.IsValid()); +EXPECT_TRUE(B.IsValid()); + +EXPECT_EQ(llvm::Triple::ArchType::arm, A.GetTriple().getArch()); +EXPECT_EQ(llvm::Triple::ArchType::arm, B.GetTriple().getArch()); + +EXPECT_EQ(ArchSpec::eCore_arm_generic, A.GetCore()); +EXPECT_EQ(ArchSpec::eCore_arm_armv8l, B.GetCore()); + +EXPECT_EQ(llvm::Triple::VendorType::UnknownVendor, + A.GetTriple().getVendor()); +EXPECT_EQ(llvm::Triple::VendorType::UnknownVendor, + B.GetTriple().getVendor()); + +EXPECT_EQ(llvm::Triple::OSType::Linux, A.GetTriple().getOS()); +EXPECT_EQ(llvm::Triple::OSType::Linux, B.GetTriple().getOS()); + +EXPECT_EQ(llvm::Triple::EnvironmentType::EABIHF, + A.GetTriple().getEnvironment()); +EXPECT_EQ(llvm::Triple::EnvironmentType::GNUEABIHF, + B.GetTriple().getEnvironment()); + +A.MergeFrom(B); +EXPECT_EQ(llvm::Triple::ArchType::arm, A.GetTriple().getArch()); +EXPECT_EQ(ArchSpec::eCore_arm_armv8l, A.GetCore()); +EXPECT_EQ(llvm::Triple::VendorType::UnknownVendor, + A.GetTriple().getVendor()); +EXPECT_EQ(llvm::Triple::OSType::Linux, A.GetTriple().getOS()); +EXPECT_EQ(llvm::Triple::EnvironmentType::EABIHF, + A.GetTriple().getEnvironment()); + } } TEST(ArchSpecTest, MergeFromMachOUnknown) { Index: lldb/source/Utility/ArchSpec.cpp === --- lldb/source/Utility/ArchSpec.cpp +++ lldb/source/Utility/ArchSpec.cpp @@ -868,7 +868,7 @@ IsCompatibleMatch(other) && GetCore() == ArchSpec::eCore_arm_generic && other.GetCore() != ArchSpec::eCore_arm_generic) { m_core = other.GetCore(); -CoreUpdated(true); +CoreUpdated(false); } if (GetFlags() == 0) { SetFlags(other.GetFlags()); ___ lldb-commits mailing list
[Lldb-commits] [PATCH] D70155: [LLDB] Avoid triple corruption while merging core info from platform and target triples
jasonmolenda accepted this revision. jasonmolenda added a comment. This revision is now accepted and ready to land. Thanks for the ping, yes this looks good to me. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70155/new/ https://reviews.llvm.org/D70155 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D70155: [LLDB] Avoid triple corruption while merging core info from platform and target triples
omjavaid added a comment. Ping @jasonmolenda Any comments or LGTM? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70155/new/ https://reviews.llvm.org/D70155 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D70155: [LLDB] Avoid triple corruption while merging core info from platform and target triples
labath added a comment. Thanks. This behavior makes sense to me. @jasonmolenda, @clayborg, do you see any problems with this? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70155/new/ https://reviews.llvm.org/D70155 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D70155: [LLDB] Avoid triple corruption while merging core info from platform and target triples
omjavaid updated this revision to Diff 229971. omjavaid added a comment. Added a unittest as suggested by @labath. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70155/new/ https://reviews.llvm.org/D70155 Files: lldb/source/Utility/ArchSpec.cpp lldb/unittests/Utility/ArchSpecTest.cpp Index: lldb/unittests/Utility/ArchSpecTest.cpp === --- lldb/unittests/Utility/ArchSpecTest.cpp +++ lldb/unittests/Utility/ArchSpecTest.cpp @@ -216,6 +216,41 @@ EXPECT_EQ(llvm::Triple::EnvironmentType::UnknownEnvironment, A.GetTriple().getEnvironment()); } + { +ArchSpec A("arm--linux-eabihf"); +ArchSpec B("armv8l--linux-gnueabihf"); + +EXPECT_TRUE(A.IsValid()); +EXPECT_TRUE(B.IsValid()); + +EXPECT_EQ(llvm::Triple::ArchType::arm, A.GetTriple().getArch()); +EXPECT_EQ(llvm::Triple::ArchType::arm, B.GetTriple().getArch()); + +EXPECT_EQ(ArchSpec::eCore_arm_generic, A.GetCore()); +EXPECT_EQ(ArchSpec::eCore_arm_armv8l, B.GetCore()); + +EXPECT_EQ(llvm::Triple::VendorType::UnknownVendor, + A.GetTriple().getVendor()); +EXPECT_EQ(llvm::Triple::VendorType::UnknownVendor, + B.GetTriple().getVendor()); + +EXPECT_EQ(llvm::Triple::OSType::Linux, A.GetTriple().getOS()); +EXPECT_EQ(llvm::Triple::OSType::Linux, B.GetTriple().getOS()); + +EXPECT_EQ(llvm::Triple::EnvironmentType::EABIHF, + A.GetTriple().getEnvironment()); +EXPECT_EQ(llvm::Triple::EnvironmentType::GNUEABIHF, + B.GetTriple().getEnvironment()); + +A.MergeFrom(B); +EXPECT_EQ(llvm::Triple::ArchType::arm, A.GetTriple().getArch()); +EXPECT_EQ(ArchSpec::eCore_arm_armv8l, A.GetCore()); +EXPECT_EQ(llvm::Triple::VendorType::UnknownVendor, + A.GetTriple().getVendor()); +EXPECT_EQ(llvm::Triple::OSType::Linux, A.GetTriple().getOS()); +EXPECT_EQ(llvm::Triple::EnvironmentType::EABIHF, + A.GetTriple().getEnvironment()); + } } TEST(ArchSpecTest, MergeFromMachOUnknown) { Index: lldb/source/Utility/ArchSpec.cpp === --- lldb/source/Utility/ArchSpec.cpp +++ lldb/source/Utility/ArchSpec.cpp @@ -868,7 +868,7 @@ IsCompatibleMatch(other) && GetCore() == ArchSpec::eCore_arm_generic && other.GetCore() != ArchSpec::eCore_arm_generic) { m_core = other.GetCore(); -CoreUpdated(true); +CoreUpdated(false); } if (GetFlags() == 0) { SetFlags(other.GetFlags()); Index: lldb/unittests/Utility/ArchSpecTest.cpp === --- lldb/unittests/Utility/ArchSpecTest.cpp +++ lldb/unittests/Utility/ArchSpecTest.cpp @@ -216,6 +216,41 @@ EXPECT_EQ(llvm::Triple::EnvironmentType::UnknownEnvironment, A.GetTriple().getEnvironment()); } + { +ArchSpec A("arm--linux-eabihf"); +ArchSpec B("armv8l--linux-gnueabihf"); + +EXPECT_TRUE(A.IsValid()); +EXPECT_TRUE(B.IsValid()); + +EXPECT_EQ(llvm::Triple::ArchType::arm, A.GetTriple().getArch()); +EXPECT_EQ(llvm::Triple::ArchType::arm, B.GetTriple().getArch()); + +EXPECT_EQ(ArchSpec::eCore_arm_generic, A.GetCore()); +EXPECT_EQ(ArchSpec::eCore_arm_armv8l, B.GetCore()); + +EXPECT_EQ(llvm::Triple::VendorType::UnknownVendor, + A.GetTriple().getVendor()); +EXPECT_EQ(llvm::Triple::VendorType::UnknownVendor, + B.GetTriple().getVendor()); + +EXPECT_EQ(llvm::Triple::OSType::Linux, A.GetTriple().getOS()); +EXPECT_EQ(llvm::Triple::OSType::Linux, B.GetTriple().getOS()); + +EXPECT_EQ(llvm::Triple::EnvironmentType::EABIHF, + A.GetTriple().getEnvironment()); +EXPECT_EQ(llvm::Triple::EnvironmentType::GNUEABIHF, + B.GetTriple().getEnvironment()); + +A.MergeFrom(B); +EXPECT_EQ(llvm::Triple::ArchType::arm, A.GetTriple().getArch()); +EXPECT_EQ(ArchSpec::eCore_arm_armv8l, A.GetCore()); +EXPECT_EQ(llvm::Triple::VendorType::UnknownVendor, + A.GetTriple().getVendor()); +EXPECT_EQ(llvm::Triple::OSType::Linux, A.GetTriple().getOS()); +EXPECT_EQ(llvm::Triple::EnvironmentType::EABIHF, + A.GetTriple().getEnvironment()); + } } TEST(ArchSpecTest, MergeFromMachOUnknown) { Index: lldb/source/Utility/ArchSpec.cpp === --- lldb/source/Utility/ArchSpec.cpp +++ lldb/source/Utility/ArchSpec.cpp @@ -868,7 +868,7 @@ IsCompatibleMatch(other) && GetCore() == ArchSpec::eCore_arm_generic && other.GetCore() != ArchSpec::eCore_arm_generic) { m_core = other.GetCore(); -CoreUpdated(true); +CoreUpdated(false); } if (GetFlags() == 0) { SetFlags(other.GetFlags()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D70155: [LLDB] Avoid triple corruption while merging core info from platform and target triples
labath added a comment. Can you add a test case for this? I assuming it could be similar to one of the existing ArchSpec::MergeFrom tests in https://github.com/llvm/llvm-project/blob/7dd7a3607596a51044b8706ebf6df2e613ce1e9b/lldb/unittests/Utility/ArchSpecTest.cpp#L137 CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70155/new/ https://reviews.llvm.org/D70155 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D70155: [LLDB] Avoid triple corruption while merging core info from platform and target triples
omjavaid created this revision. omjavaid added reviewers: labath, jasonmolenda, clayborg. Herald added a subscriber: kristof.beyls. This patch fixes a bug where when target triple created from elf information is arm-*-linux-eabihf and platform triple is armv8l-*-linux-gnueabihf. Merging both triple results in armv8l--unknown-unknown. This happens because we order a triple update while calling CoreUpdated and CoreUpdated creates a new triple with no vendor or environment information. Making sure we do not update triple and just update to more specific core fixes the issue. https://reviews.llvm.org/D70155 Files: lldb/source/Utility/ArchSpec.cpp Index: lldb/source/Utility/ArchSpec.cpp === --- lldb/source/Utility/ArchSpec.cpp +++ lldb/source/Utility/ArchSpec.cpp @@ -868,7 +868,7 @@ IsCompatibleMatch(other) && GetCore() == ArchSpec::eCore_arm_generic && other.GetCore() != ArchSpec::eCore_arm_generic) { m_core = other.GetCore(); -CoreUpdated(true); +CoreUpdated(false); } if (GetFlags() == 0) { SetFlags(other.GetFlags()); Index: lldb/source/Utility/ArchSpec.cpp === --- lldb/source/Utility/ArchSpec.cpp +++ lldb/source/Utility/ArchSpec.cpp @@ -868,7 +868,7 @@ IsCompatibleMatch(other) && GetCore() == ArchSpec::eCore_arm_generic && other.GetCore() != ArchSpec::eCore_arm_generic) { m_core = other.GetCore(); -CoreUpdated(true); +CoreUpdated(false); } if (GetFlags() == 0) { SetFlags(other.GetFlags()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits