decompiler  1.0.0
Public Member Functions | Private Attributes | List of all members
ghidra::ContextCache Class Reference

A helper class for caching the active context blob to minimize database lookups. More...

#include <globalcontext.hh>

Public Member Functions

 ContextCache (ContextDatabase *db)
 Construct given a context database. More...
 
ContextDatabasegetDatabase (void) const
 Retrieve the encapsulated database object.
 
void allowSet (bool val)
 Toggle whether setContext() calls are ignored.
 
void getContext (const Address &addr, uintm *buf) const
 Retrieve the context blob for the given address. More...
 
void setContext (const Address &addr, int4 num, uintm mask, uintm value)
 Change the value of a context variable at the given address with no bound. More...
 
void setContext (const Address &addr1, const Address &addr2, int4 num, uintm mask, uintm value)
 Change the value of a context variable across an explicit address range. More...
 

Private Attributes

ContextDatabasedatabase
 The encapsulated context database.
 
bool allowset
 If set to false, and setContext() call is dropped.
 
AddrSpacecurspace
 Address space of the current valid range.
 
uintb first
 Starting offset of the current valid range.
 
uintb last
 Ending offset of the current valid range.
 
const uintm * context
 The current cached context blob.
 

Detailed Description

A helper class for caching the active context blob to minimize database lookups.

This merely caches the last retrieved context blob ("array of words") and the range of addresses over which the blob is valid. It encapsulates the ContextDatabase itself and exposes a minimal interface (getContext() and setContext()).

Constructor & Destructor Documentation

◆ ContextCache()

ghidra::ContextCache::ContextCache ( ContextDatabase db)

Construct given a context database.

Parameters
dbis the context database that will be encapsulated

Member Function Documentation

◆ getContext()

void ghidra::ContextCache::getContext ( const Address addr,
uintm *  buf 
) const

Retrieve the context blob for the given address.

Check if the address is in the current valid range. If it is, return the cached blob. Otherwise, make a call to the database and cache a new block and valid range.

Parameters
addris the given address
bufis where the blob should be stored

References ghidra::Address::getOffset(), and ghidra::Address::getSpace().

◆ setContext() [1/2]

void ghidra::ContextCache::setContext ( const Address addr,
int4  num,
uintm  mask,
uintm  value 
)

Change the value of a context variable at the given address with no bound.

The context value is set starting at the given address and paints memory up to the next explicit change point.

Parameters
addris the given starting address
numis the word index of the context variable
maskis the mask delimiting the context variable
valueis the (already shifted) value to set

References ghidra::Address::getOffset(), and ghidra::Address::getSpace().

◆ setContext() [2/2]

void ghidra::ContextCache::setContext ( const Address addr1,
const Address addr2,
int4  num,
uintm  mask,
uintm  value 
)

Change the value of a context variable across an explicit address range.

The context value is painted across the range. The context variable is marked as explicitly changing at the starting address of the range.

Parameters
addr1is the starting address of the given range
addr2is the ending address of the given range
numis the word index of the context variable
maskis the mask delimiting the context variable
valueis the (already shifted) value to set

References ghidra::Address::getOffset(), and ghidra::Address::getSpace().


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