decompiler
1.0.0
|
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... | |
ContextDatabase * | getDatabase (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 | |
ContextDatabase * | database |
The encapsulated context database. | |
bool | allowset |
If set to false, and setContext() call is dropped. | |
AddrSpace * | curspace |
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. | |
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()).
ghidra::ContextCache::ContextCache | ( | ContextDatabase * | db | ) |
Construct given a context database.
db | is the context database that will be encapsulated |
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.
addr | is the given address |
buf | is where the blob should be stored |
References ghidra::Address::getOffset(), and ghidra::Address::getSpace().
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.
addr | is the given starting address |
num | is the word index of the context variable |
mask | is the mask delimiting the context variable |
value | is the (already shifted) value to set |
References ghidra::Address::getOffset(), and ghidra::Address::getSpace().
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.
addr1 | is the starting address of the given range |
addr2 | is the ending address of the given range |
num | is the word index of the context variable |
mask | is the mask delimiting the context variable |
value | is the (already shifted) value to set |
References ghidra::Address::getOffset(), and ghidra::Address::getSpace().