9#ifndef LLDB_TARGET_MEMORY_H
10#define LLDB_TARGET_MEMORY_H
14#include "llvm/ADT/ArrayRef.h"
15#include "llvm/ADT/DenseMap.h"
16#include "llvm/ADT/SmallVector.h"
28 using Collection = llvm::DenseMap<uint64_t, std::unique_ptr<uint8_t[]>>;
51 void Clear(uint32_t new_line_byte_size) {
73 using Collection = std::map<lldb::addr_t, std::vector<uint8_t>>;
115 void Clear(
bool clear_invalid_ranges =
false);
123 llvm::SmallVector<llvm::MutableArrayRef<uint8_t>>
125 llvm::MutableArrayRef<uint8_t> buffer);
165 llvm::ArrayRef<uint8_t> src);
183 size_t bytes_filled)
const;
191 uint32_t chunk_size);
239 void Clear(
bool deallocate_memory);
static llvm::raw_ostream & error(Stream &strm)
uint32_t CalculateChunksNeededForSize(uint32_t size) const
bool FreeBlock(lldb::addr_t addr)
uint32_t GetPermissions() const
lldb::addr_t GetBaseAddress() const
lldb::addr_t ReserveBlock(uint32_t size)
const uint32_t m_permissions
Range< lldb::addr_t, uint32_t > m_range
AllocatedBlock(lldb::addr_t addr, uint32_t byte_size, uint32_t permissions, uint32_t chunk_size)
RangeVector< lldb::addr_t, uint32_t > m_free_blocks
uint32_t TotalChunks() const
RangeVector< lldb::addr_t, uint32_t > m_reserved_blocks
uint32_t GetChunkSize() const
const uint32_t m_chunk_size
uint32_t GetByteSize() const
bool Contains(lldb::addr_t addr) const
lldb::addr_t AllocateMemory(size_t byte_size, uint32_t permissions, Status &error)
bool IsInCache(lldb::addr_t addr) const
std::multimap< uint32_t, AllocatedBlockSP > PermissionsToBlockMap
const AllocatedMemoryCache & operator=(const AllocatedMemoryCache &)=delete
AllocatedMemoryCache(Process &process)
std::recursive_mutex m_mutex
void Clear(bool deallocate_memory)
bool DeallocateMemory(lldb::addr_t ptr)
std::shared_ptr< AllocatedBlock > AllocatedBlockSP
PermissionsToBlockMap m_memory_map
AllocatedMemoryCache(const AllocatedMemoryCache &)=delete
AllocatedBlockSP AllocatePage(uint32_t byte_size, uint32_t permissions, uint32_t chunk_size, Status &error)
A set of non-overlapping byte ranges at arbitrary addresses.
const_iterator begin() const
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.
Collection::const_iterator FindChunkContaining(lldb::addr_t addr) const
The chunk holding addr, or end().
std::map< lldb::addr_t, std::vector< uint8_t > > Collection
Collection::const_iterator const_iterator
Iteration yields a chunk's start address and its bytes, in address order.
const_iterator end() const
bool Holds(lldb::addr_t addr) const
void EraseRange(lldb::addr_t addr, lldb::addr_t size)
Drop every chunk that intersects [addr, addr+size).
void InsertMissing(lldb::addr_t addr, llvm::ArrayRef< uint8_t > src)
Add the bytes of [addr, addr+src.size()) that no chunk holds yet.
A set of cache entries, all of which are aligned and have the same size.
const_iterator end() const
uint64_t IndexOf(lldb::addr_t addr) const
void Clear(uint32_t new_line_byte_size)
llvm::DenseMap< uint64_t, std::unique_ptr< uint8_t[]> > Collection
Keyed by line index, so a key names a whole line.
Collection::const_iterator const_iterator
Iteration yields a line index and its bytes, in unspecified order.
uint32_t GetLineByteSize() const
uint32_t m_line_byte_size
llvm::ArrayRef< uint8_t > Lookup(lldb::addr_t addr) const
The cached bytes from addr to the end of the line holding it, empty if that line is not resident.
void Insert(lldb::addr_t addr, llvm::ArrayRef< uint8_t > src)
Add one whole line.
const_iterator begin() const
void EraseRange(lldb::addr_t addr, lldb::addr_t size)
Drop every line that intersects [addr, addr+size).
LineCache(uint32_t line_byte_size)
bool Holds(lldb::addr_t addr) const
uint32_t GetMemoryCacheLineSize() const
MemoryCache(Process &process)
std::recursive_mutex m_mutex
void AddCacheData(lldb::addr_t addr, const void *src, size_t src_len)
Allow external sources to populate data into the memory cache.
bool RemoveInvalidRange(lldb::addr_t base_addr, lldb::addr_t byte_size)
void Flush(lldb::addr_t addr, size_t size)
void InsertWholeLine(lldb::addr_t line_base_addr, llvm::ArrayRef< uint8_t > src)
llvm::SmallVector< llvm::MutableArrayRef< uint8_t > > ReadRanges(llvm::ArrayRef< Range< lldb::addr_t, size_t > > ranges, llvm::MutableArrayRef< uint8_t > buffer)
Reads memory ranges, serving hits from the cache and batching misses through Process::DoReadMemoryRan...
InvalidRanges m_invalid_ranges
void InsertPartialLine(lldb::addr_t addr, llvm::ArrayRef< uint8_t > src)
void Clear(bool clear_invalid_ranges=false)
RangeVector< lldb::addr_t, lldb::addr_t, 4 > InvalidRanges
size_t ReadFromCaches(lldb::addr_t addr, void *dst, size_t len) const
void InsertData(lldb::addr_t addr, llvm::ArrayRef< uint8_t > src)
MemoryCache(const MemoryCache &)=delete
void AddCacheData(lldb::addr_t addr, llvm::ArrayRef< uint8_t > src)
AddrRange GrowReadRange(lldb::addr_t read_addr, lldb::addr_t caller_end, size_t bytes_filled) const
size_t Read(lldb::addr_t addr, void *dst, size_t dst_len, Status &error)
void AddInvalidRange(lldb::addr_t base_addr, lldb::addr_t byte_size)
const MemoryCache & operator=(const MemoryCache &)=delete
Range< lldb::addr_t, lldb::addr_t > AddrRange
A plug-in interface definition class for debugging a process.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP