LLDB mainline
lldb_private::ChunkCache Class Reference

A set of non-overlapping byte ranges at arbitrary addresses. More...

#include <Memory.h>

Public Types

using const_iterator = Collection::const_iterator
 Iteration yields a chunk's start address and its bytes, in address order.

Public Member Functions

llvm::ArrayRef< uint8_t > Lookup (lldb::addr_t addr) const
 The cached bytes from addr to the end of the chunk holding it, empty if no chunk holds it.
bool Holds (lldb::addr_t addr) const
void InsertMissing (lldb::addr_t addr, llvm::ArrayRef< uint8_t > src)
 Add the bytes of [addr, addr+src.size()) that no chunk holds yet.
void EraseRange (lldb::addr_t addr, lldb::addr_t size)
 Drop every chunk that intersects [addr, addr+size).
void Clear ()
size_t GetSize () const
const_iterator begin () const
const_iterator end () const

Private Types

using Collection = std::map<lldb::addr_t, std::vector<uint8_t>>

Private Member Functions

Collection::const_iterator FindChunkContaining (lldb::addr_t addr) const
 The chunk holding addr, or end().

Private Attributes

Collection m_chunks

Detailed Description

A set of non-overlapping byte ranges at arbitrary addresses.

Lengths vary, so every chunk carries its own.

Definition at line 72 of file Memory.h.

Member Typedef Documentation

◆ Collection

using lldb_private::ChunkCache::Collection = std::map<lldb::addr_t, std::vector<uint8_t>>
private

Definition at line 73 of file Memory.h.

◆ const_iterator

using lldb_private::ChunkCache::const_iterator = Collection::const_iterator

Iteration yields a chunk's start address and its bytes, in address order.

Definition at line 94 of file Memory.h.

Member Function Documentation

◆ begin()

const_iterator lldb_private::ChunkCache::begin ( ) const
inline

Definition at line 95 of file Memory.h.

References m_chunks.

◆ Clear()

void lldb_private::ChunkCache::Clear ( )
inline

Definition at line 89 of file Memory.h.

References m_chunks.

◆ end()

const_iterator lldb_private::ChunkCache::end ( ) const
inline

Definition at line 96 of file Memory.h.

References m_chunks.

◆ EraseRange()

void ChunkCache::EraseRange ( lldb::addr_t addr,
lldb::addr_t size )

Drop every chunk that intersects [addr, addr+size).

Definition at line 99 of file Memory.cpp.

References m_chunks.

◆ FindChunkContaining()

ChunkCache::Collection::const_iterator ChunkCache::FindChunkContaining ( lldb::addr_t addr) const
private

The chunk holding addr, or end().

Chunks never overlap, so only the one starting at or below addr can hold it.

Definition at line 58 of file Memory.cpp.

References m_chunks.

Referenced by Lookup().

◆ GetSize()

size_t lldb_private::ChunkCache::GetSize ( ) const
inline

Definition at line 91 of file Memory.h.

References m_chunks.

◆ Holds()

bool lldb_private::ChunkCache::Holds ( lldb::addr_t addr) const
inline

Definition at line 80 of file Memory.h.

References Lookup().

◆ InsertMissing()

void ChunkCache::InsertMissing ( lldb::addr_t addr,
llvm::ArrayRef< uint8_t > src )

Add the bytes of [addr, addr+src.size()) that no chunk holds yet.

Bytes already held are kept: which read produced a byte does not matter.

Definition at line 75 of file Memory.cpp.

References Lookup(), and m_chunks.

◆ Lookup()

llvm::ArrayRef< uint8_t > ChunkCache::Lookup ( lldb::addr_t addr) const

The cached bytes from addr to the end of the chunk holding it, empty if no chunk holds it.

Definition at line 68 of file Memory.cpp.

References FindChunkContaining(), and m_chunks.

Referenced by Holds(), and InsertMissing().

Member Data Documentation

◆ m_chunks

Collection lldb_private::ChunkCache::m_chunks
private

Definition at line 103 of file Memory.h.

Referenced by begin(), Clear(), end(), EraseRange(), FindChunkContaining(), GetSize(), InsertMissing(), and Lookup().


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