Author: David Spickett Date: 2022-01-20T10:47:05Z New Revision: 585abe3ba506e410b382f8130f72b9368573a781
URL: https://github.com/llvm/llvm-project/commit/585abe3ba506e410b382f8130f72b9368573a781 DIFF: https://github.com/llvm/llvm-project/commit/585abe3ba506e410b382f8130f72b9368573a781.diff LOG: [lldb] Rename MemoryTagManager RemoveNonAddressBits to RemoveTagBits This better describes the intent of the method. Which for AArch64 is removing the top byte which includes the memory tags. It does not include pointer signatures, for those we need to use the ABI plugin. The rename makes this a little more clear. It's a bit awkward that the memory tag manager is removing the whole top byte not just the memory tags but it's an improvement for now. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D117671 Added: Modified: lldb/include/lldb/Target/MemoryTagManager.h lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Target/MemoryTagManager.h b/lldb/include/lldb/Target/MemoryTagManager.h index a5e0deba14a90..ed4d04f712ab5 100644 --- a/lldb/include/lldb/Target/MemoryTagManager.h +++ b/lldb/include/lldb/Target/MemoryTagManager.h @@ -35,8 +35,8 @@ class MemoryTagManager { // you get will have been shifted down 56 before being returned. virtual lldb::addr_t GetLogicalTag(lldb::addr_t addr) const = 0; - // Remove non address bits from a pointer - virtual lldb::addr_t RemoveNonAddressBits(lldb::addr_t addr) const = 0; + // Remove tag bits from a pointer + virtual lldb::addr_t RemoveTagBits(lldb::addr_t addr) const = 0; // Return the diff erence between two addresses, ignoring any logical tags they // have. If your tags are just part of a larger set of ignored bits, this diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index 74366d720814f..b1ac247346a79 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -1365,10 +1365,9 @@ Status NativeProcessLinux::ReadMemoryTags(int32_t type, lldb::addr_t addr, // lldb will align the range it requests but it is not required to by // the protocol so we'll do it again just in case. - // Remove non address bits too. Ptrace calls may work regardless but that + // Remove tag bits too. Ptrace calls may work regardless but that // is not a guarantee. - MemoryTagManager::TagRange range(details->manager->RemoveNonAddressBits(addr), - len); + MemoryTagManager::TagRange range(details->manager->RemoveTagBits(addr), len); range = details->manager->ExpandToGranule(range); // Allocate enough space for all tags to be read @@ -1420,10 +1419,9 @@ Status NativeProcessLinux::WriteMemoryTags(int32_t type, lldb::addr_t addr, // lldb will align the range it requests but it is not required to by // the protocol so we'll do it again just in case. - // Remove non address bits too. Ptrace calls may work regardless but that + // Remove tag bits too. Ptrace calls may work regardless but that // is not a guarantee. - MemoryTagManager::TagRange range(details->manager->RemoveNonAddressBits(addr), - len); + MemoryTagManager::TagRange range(details->manager->RemoveTagBits(addr), len); range = details->manager->ExpandToGranule(range); // Not checking number of tags here, we may repeat them below diff --git a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp index d74b66b58afc9..fba23401c88f9 100644 --- a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp +++ b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp @@ -20,7 +20,7 @@ MemoryTagManagerAArch64MTE::GetLogicalTag(lldb::addr_t addr) const { } lldb::addr_t -MemoryTagManagerAArch64MTE::RemoveNonAddressBits(lldb::addr_t addr) const { +MemoryTagManagerAArch64MTE::RemoveTagBits(lldb::addr_t addr) const { // Here we're ignoring the whole top byte. If you've got MTE // you must also have TBI (top byte ignore). // The other 4 bits could contain other extension bits or @@ -30,7 +30,7 @@ MemoryTagManagerAArch64MTE::RemoveNonAddressBits(lldb::addr_t addr) const { ptr diff _t MemoryTagManagerAArch64MTE::AddressDiff(lldb::addr_t addr1, lldb::addr_t addr2) const { - return RemoveNonAddressBits(addr1) - RemoveNonAddressBits(addr2); + return RemoveTagBits(addr1) - RemoveTagBits(addr2); } lldb::addr_t MemoryTagManagerAArch64MTE::GetGranuleSize() const { @@ -84,7 +84,7 @@ MemoryTagManagerAArch64MTE::MakeTaggedRange( // Region addresses will not have memory tags. So when searching // we must use an untagged address. - MemoryRegionInfo::RangeType tag_range(RemoveNonAddressBits(addr), len); + MemoryRegionInfo::RangeType tag_range(RemoveTagBits(addr), len); tag_range = ExpandToGranule(tag_range); // Make a copy so we can use the original for errors and the final return. diff --git a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h index d4e8249da93fb..7825ba0a92490 100644 --- a/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h +++ b/lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h @@ -27,7 +27,7 @@ class MemoryTagManagerAArch64MTE : public MemoryTagManager { size_t GetTagSizeInBytes() const override; lldb::addr_t GetLogicalTag(lldb::addr_t addr) const override; - lldb::addr_t RemoveNonAddressBits(lldb::addr_t addr) const override; + lldb::addr_t RemoveTagBits(lldb::addr_t addr) const override; ptr diff _t AddressDiff(lldb::addr_t addr1, lldb::addr_t addr2) const override; TagRange ExpandToGranule(TagRange range) const override; diff --git a/lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp b/lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp index 0460b3fc1359b..1a34b05ac671a 100644 --- a/lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp +++ b/lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp @@ -247,16 +247,17 @@ TEST(MemoryTagManagerAArch64MTETest, MakeTaggedRange) { ASSERT_EQ(*got, expected_range); } -TEST(MemoryTagManagerAArch64MTETest, RemoveNonAddressBits) { +TEST(MemoryTagManagerAArch64MTETest, RemoveTagBits) { MemoryTagManagerAArch64MTE manager; ASSERT_EQ(0, 0); + // Removes the whole top byte ASSERT_EQ((lldb::addr_t)0x00ffeedd11223344, - manager.RemoveNonAddressBits(0x00ffeedd11223344)); + manager.RemoveTagBits(0x00ffeedd11223344)); ASSERT_EQ((lldb::addr_t)0x0000000000000000, - manager.RemoveNonAddressBits(0xFF00000000000000)); + manager.RemoveTagBits(0xff00000000000000)); ASSERT_EQ((lldb::addr_t)0x0055555566666666, - manager.RemoveNonAddressBits(0xee55555566666666)); + manager.RemoveTagBits(0xee55555566666666)); } TEST(MemoryTagManagerAArch64MTETest, AddressDiff) { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits