LLDB mainline
|
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_t > | GetTag (lldb::addr_t addr) const |
Lookup the tag for address. | |
Private Attributes | |
std::map< lldb::addr_t, lldb::addr_t > | m_addr_to_tag |
const MemoryTagManager * | m_manager |
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.
MemoryTagMap::MemoryTagMap | ( | const MemoryTagManager * | manager | ) |
Init an empty tag map.
[in] | manager | Non-null pointer to a memory tag manager. |
Definition at line 14 of file MemoryTagMap.cpp.
References m_manager.
bool MemoryTagMap::Empty | ( | ) | const |
Definition at line 29 of file MemoryTagMap.cpp.
References m_addr_to_tag.
Referenced by GetMemoryTags().
|
private |
Lookup the tag for address.
[in] | address | The address to lookup a tag for. This should be aligned to a granule boundary. |
Definition at line 58 of file MemoryTagMap.cpp.
References m_addr_to_tag.
Referenced by 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] | addr | The start of the range. This may include non address bits and does not have to be granule aligned. |
[in] | len | The length in bytes of the range to read tags for. This does not need to be multiple of the granule size. |
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().
void MemoryTagMap::InsertTags | ( | lldb::addr_t | addr, |
const std::vector< lldb::addr_t > | tags | ||
) |
Insert tags into the map starting from addr.
[in] | addr | Start 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] | tags | Vector 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().
|
private |
Definition at line 85 of file MemoryTagMap.h.
Referenced by Empty(), GetTag(), and InsertTags().
|
private |
Definition at line 93 of file MemoryTagMap.h.
Referenced by GetTags(), InsertTags(), and MemoryTagMap().