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>

Collaboration diagram for lldb_private::MemoryTagMap:
Collaboration graph
[legend]

Public Member Functions

 MemoryTagMap (const MemoryTagManager *manager)
 Init an empty tag map. More...
 
void InsertTags (lldb::addr_t addr, const std::vector< lldb::addr_t > tags)
 Insert tags into the map starting from addr. More...
 
bool Empty () const
 
std::vector< llvm::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. More...
 

Private Member Functions

llvm::Optional< lldb::addr_tGetTag (lldb::addr_t addr) const
 Lookup the tag for address. More...
 

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.

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

Definition at line 13 of file MemoryTagMap.cpp.

References m_manager.

Member Function Documentation

◆ Empty()

bool MemoryTagMap::Empty ( ) const

Definition at line 28 of file MemoryTagMap.cpp.

References m_addr_to_tag.

Referenced by GetMemoryTags().

◆ GetTag()

llvm::Optional< lldb::addr_t > MemoryTagMap::GetTag ( lldb::addr_t  addr) const
private

Lookup the tag for address.

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

Definition at line 57 of file MemoryTagMap.cpp.

References m_addr_to_tag.

Referenced by GetTags().

◆ GetTags()

std::vector< llvm::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.

Parameters
[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.
Returns
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 llvm::None. (this saves the caller checking whether all items are llvm::None)

Definition at line 31 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.

Parameters
[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 18 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
private

Definition at line 85 of file MemoryTagMap.h.

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

◆ m_manager

const MemoryTagManager* lldb_private::MemoryTagMap::m_manager
private

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: