Skip to content

Commit 585abe3

Browse files
committed
[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
1 parent 782c0dd commit 585abe3

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

lldb/include/lldb/Target/MemoryTagManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class MemoryTagManager {
3535
// you get will have been shifted down 56 before being returned.
3636
virtual lldb::addr_t GetLogicalTag(lldb::addr_t addr) const = 0;
3737

38-
// Remove non address bits from a pointer
39-
virtual lldb::addr_t RemoveNonAddressBits(lldb::addr_t addr) const = 0;
38+
// Remove tag bits from a pointer
39+
virtual lldb::addr_t RemoveTagBits(lldb::addr_t addr) const = 0;
4040

4141
// Return the difference between two addresses, ignoring any logical tags they
4242
// have. If your tags are just part of a larger set of ignored bits, this

lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,10 +1365,9 @@ Status NativeProcessLinux::ReadMemoryTags(int32_t type, lldb::addr_t addr,
13651365

13661366
// lldb will align the range it requests but it is not required to by
13671367
// the protocol so we'll do it again just in case.
1368-
// Remove non address bits too. Ptrace calls may work regardless but that
1368+
// Remove tag bits too. Ptrace calls may work regardless but that
13691369
// is not a guarantee.
1370-
MemoryTagManager::TagRange range(details->manager->RemoveNonAddressBits(addr),
1371-
len);
1370+
MemoryTagManager::TagRange range(details->manager->RemoveTagBits(addr), len);
13721371
range = details->manager->ExpandToGranule(range);
13731372

13741373
// Allocate enough space for all tags to be read
@@ -1420,10 +1419,9 @@ Status NativeProcessLinux::WriteMemoryTags(int32_t type, lldb::addr_t addr,
14201419

14211420
// lldb will align the range it requests but it is not required to by
14221421
// the protocol so we'll do it again just in case.
1423-
// Remove non address bits too. Ptrace calls may work regardless but that
1422+
// Remove tag bits too. Ptrace calls may work regardless but that
14241423
// is not a guarantee.
1425-
MemoryTagManager::TagRange range(details->manager->RemoveNonAddressBits(addr),
1426-
len);
1424+
MemoryTagManager::TagRange range(details->manager->RemoveTagBits(addr), len);
14271425
range = details->manager->ExpandToGranule(range);
14281426

14291427
// Not checking number of tags here, we may repeat them below

lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ MemoryTagManagerAArch64MTE::GetLogicalTag(lldb::addr_t addr) const {
2020
}
2121

2222
lldb::addr_t
23-
MemoryTagManagerAArch64MTE::RemoveNonAddressBits(lldb::addr_t addr) const {
23+
MemoryTagManagerAArch64MTE::RemoveTagBits(lldb::addr_t addr) const {
2424
// Here we're ignoring the whole top byte. If you've got MTE
2525
// you must also have TBI (top byte ignore).
2626
// The other 4 bits could contain other extension bits or
@@ -30,7 +30,7 @@ MemoryTagManagerAArch64MTE::RemoveNonAddressBits(lldb::addr_t addr) const {
3030

3131
ptrdiff_t MemoryTagManagerAArch64MTE::AddressDiff(lldb::addr_t addr1,
3232
lldb::addr_t addr2) const {
33-
return RemoveNonAddressBits(addr1) - RemoveNonAddressBits(addr2);
33+
return RemoveTagBits(addr1) - RemoveTagBits(addr2);
3434
}
3535

3636
lldb::addr_t MemoryTagManagerAArch64MTE::GetGranuleSize() const {
@@ -84,7 +84,7 @@ MemoryTagManagerAArch64MTE::MakeTaggedRange(
8484

8585
// Region addresses will not have memory tags. So when searching
8686
// we must use an untagged address.
87-
MemoryRegionInfo::RangeType tag_range(RemoveNonAddressBits(addr), len);
87+
MemoryRegionInfo::RangeType tag_range(RemoveTagBits(addr), len);
8888
tag_range = ExpandToGranule(tag_range);
8989

9090
// Make a copy so we can use the original for errors and the final return.

lldb/source/Plugins/Process/Utility/MemoryTagManagerAArch64MTE.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class MemoryTagManagerAArch64MTE : public MemoryTagManager {
2727
size_t GetTagSizeInBytes() const override;
2828

2929
lldb::addr_t GetLogicalTag(lldb::addr_t addr) const override;
30-
lldb::addr_t RemoveNonAddressBits(lldb::addr_t addr) const override;
30+
lldb::addr_t RemoveTagBits(lldb::addr_t addr) const override;
3131
ptrdiff_t AddressDiff(lldb::addr_t addr1, lldb::addr_t addr2) const override;
3232

3333
TagRange ExpandToGranule(TagRange range) const override;

lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,17 @@ TEST(MemoryTagManagerAArch64MTETest, MakeTaggedRange) {
247247
ASSERT_EQ(*got, expected_range);
248248
}
249249

250-
TEST(MemoryTagManagerAArch64MTETest, RemoveNonAddressBits) {
250+
TEST(MemoryTagManagerAArch64MTETest, RemoveTagBits) {
251251
MemoryTagManagerAArch64MTE manager;
252252

253253
ASSERT_EQ(0, 0);
254+
// Removes the whole top byte
254255
ASSERT_EQ((lldb::addr_t)0x00ffeedd11223344,
255-
manager.RemoveNonAddressBits(0x00ffeedd11223344));
256+
manager.RemoveTagBits(0x00ffeedd11223344));
256257
ASSERT_EQ((lldb::addr_t)0x0000000000000000,
257-
manager.RemoveNonAddressBits(0xFF00000000000000));
258+
manager.RemoveTagBits(0xff00000000000000));
258259
ASSERT_EQ((lldb::addr_t)0x0055555566666666,
259-
manager.RemoveNonAddressBits(0xee55555566666666));
260+
manager.RemoveTagBits(0xee55555566666666));
260261
}
261262

262263
TEST(MemoryTagManagerAArch64MTETest, AddressDiff) {

0 commit comments

Comments
 (0)