LLDB mainline
Public Member Functions | Private Member Functions | Private Attributes | List of all members
lldb_private::MemoryTagMap Class Reference

MemoryTagMap provides a way to give a sparse read result when reading memory tags for a range. More...

#include <MemoryTagMap.h>

Public Member Functions

 MemoryTagMap (const MemoryTagManager *manager)
 Init an empty tag map.
void InsertTags (lldb::addr_t addr, const std::vector< lldb::addr_t > tags)
 Insert tags into the map starting from addr.
bool Empty () const
std::vector< std::optional< lldb::addr_t > > GetTags (lldb::addr_t addr, size_t len) const
 Lookup memory tags for a range of memory from addr to addr+len.

Private Member Functions

std::optional< lldb::addr_tGetTag (lldb::addr_t addr) const
 Lookup the tag for address.

Private Attributes

std::map< lldb::addr_t, lldb::addr_tm_addr_to_tag
const MemoryTagManagerm_manager

Detailed Description

MemoryTagMap provides a way to give a sparse read result when reading memory tags for a range.

This is useful when you want to annotate some large memory dump that might include tagged memory but you don't know that it is all tagged.

Definition at line 23 of file MemoryTagMap.h.

Constructor & Destructor Documentation

◆ MemoryTagMap()

MemoryTagMap::MemoryTagMap ( const MemoryTagManager manager)

Init an empty tag map.

[in]managerNon-null pointer to a memory tag manager.

Definition at line 14 of file MemoryTagMap.cpp.

References m_manager.

Member Function Documentation

◆ Empty()

bool MemoryTagMap::Empty ( ) const

Definition at line 29 of file MemoryTagMap.cpp.

References m_addr_to_tag.

Referenced by GetMemoryTags().

◆ GetTag()

std::optional< lldb::addr_t > MemoryTagMap::GetTag ( lldb::addr_t  addr) const

Lookup the tag for address.

[in]addressThe address to lookup a tag for. This should be aligned to a granule boundary.
The tag for the granule that address refers to, or std::nullopt if it has no memory tag.

Definition at line 58 of file MemoryTagMap.cpp.

References m_addr_to_tag.

Referenced by GetTags().

◆ GetTags()

std::vector< std::optional< lldb::addr_t > > MemoryTagMap::GetTags ( lldb::addr_t  addr,
size_t  len 
) const

Lookup memory tags for a range of memory from addr to addr+len.

[in]addrThe start of the range. This may include non address bits and does not have to be granule aligned.
[in]lenThe length in bytes of the range to read tags for. This does not need to be multiple of the granule size.
A vector containing the tags found for the granules in the range. (which is the result of granule aligning the given range)

Each item in the vector is an optional tag. Meaning that if it is valid then the granule had a tag and if not, it didn't.

If the range had no tags at all, the vector will be empty. If some of the range was tagged it will have items and some of them may be std::nullopt. (this saves the caller checking whether all items are std::nullopt)

Definition at line 32 of file MemoryTagMap.cpp.

References lldb_private::MemoryTagManager::ExpandToGranule(), lldb_private::MemoryTagManager::GetGranuleSize(), lldb_private::Range< B, S >::GetRangeBase(), lldb_private::Range< B, S >::GetRangeEnd(), GetTag(), m_manager, and lldb_private::MemoryTagManager::RemoveTagBits().

◆ InsertTags()

void MemoryTagMap::InsertTags ( lldb::addr_t  addr,
const std::vector< lldb::addr_t tags 

Insert tags into the map starting from addr.

[in]addrStart address of the range to insert tags for. This address should be granule aligned and have had any non address bits removed. (ideally you would use the base of the range you used to read the tags in the first place)
[in]tagsVector of tags to insert. The first tag will be inserted at addr, the next at addr+granule size and so on until all tags have been inserted.

Definition at line 19 of file MemoryTagMap.cpp.

References lldb_private::MemoryTagManager::GetGranuleSize(), m_addr_to_tag, and m_manager.

Referenced by GetMemoryTags().

Member Data Documentation

◆ m_addr_to_tag

std::map<lldb::addr_t, lldb::addr_t> lldb_private::MemoryTagMap::m_addr_to_tag

Definition at line 85 of file MemoryTagMap.h.

Referenced by Empty(), GetTag(), and InsertTags().

◆ m_manager

const MemoryTagManager* lldb_private::MemoryTagMap::m_manager

Definition at line 93 of file MemoryTagMap.h.

Referenced by GetTags(), InsertTags(), and MemoryTagMap().

The documentation for this class was generated from the following files: