Ghidra Decompiler Analysis Engine
Public Member Functions | List of all members
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...
 
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...
 

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()

ContextCache::ContextCache ( ContextDatabase db)

Construct given a context database.

Parameters
dbis the context database that will be encapsulated

Member Function Documentation

◆ getContext()

void 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

◆ setContext() [1/2]

void 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

◆ setContext() [2/2]

void 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

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