decompiler
1.0.0
|
An in-memory implementation of the ContextDatabase interface. More...
#include <globalcontext.hh>
Classes | |
struct | FreeArray |
A context blob, holding context values across some range of code addresses. More... | |
Public Member Functions | |
virtual int4 | getContextSize (void) const |
Retrieve the number of words (uintm) in a context blob. More... | |
virtual void | registerVariable (const string &nm, int4 sbit, int4 ebit) |
Register a new named context variable (as a bit range) with the database. More... | |
virtual const uintm * | getContext (const Address &addr) const |
Get the context blob of values associated with a given address. More... | |
virtual const uintm * | getContext (const Address &addr, uintb &first, uintb &last) const |
Get the context blob of values associated with a given address and its bounding offsets. More... | |
virtual TrackedSet & | getTrackedDefault (void) |
Get the set of default values for all tracked registers. More... | |
virtual const TrackedSet & | getTrackedSet (const Address &addr) const |
Get the set of tracked register values associated with the given address. More... | |
virtual TrackedSet & | createSet (const Address &addr1, const Address &addr2) |
Create a tracked register set that is valid over the given range. More... | |
virtual void | encode (Encoder &encoder) const |
Encode the entire database to a stream. More... | |
virtual void | decode (Decoder &decoder) |
Restore the state of this database object from the given stream decoder. More... | |
virtual void | decodeFromSpec (Decoder &decoder) |
Add initial context state from elements in the compiler/processor specifications. More... | |
Public Member Functions inherited from ghidra::ContextDatabase | |
virtual | ~ContextDatabase () |
Destructor. | |
void | setVariableDefault (const string &nm, uintm val) |
Provide a default value for a context variable. More... | |
uintm | getDefaultValue (const string &nm) const |
Retrieve the default value for a context variable. More... | |
void | setVariable (const string &nm, const Address &addr, uintm value) |
Set a context value at the given address. More... | |
uintm | getVariable (const string &nm, const Address &addr) const |
Retrieve a context value at the given address. More... | |
void | setContextChangePoint (const Address &addr, int4 num, uintm mask, uintm value) |
Set a specific context value starting at the given address. More... | |
void | setContextRegion (const Address &addr1, const Address &addr2, int4 num, uintm mask, uintm value) |
Set a context variable value over a given range of addresses. More... | |
void | setVariableRegion (const string &nm, const Address &begad, const Address &endad, uintm value) |
Set a context variable by name over a given range of addresses. More... | |
uintb | getTrackedValue (const VarnodeData &mem, const Address &point) const |
Get the value of a tracked register at a specific address. More... | |
Private Member Functions | |
void | encodeContext (Encoder &encoder, const Address &addr, const uintm *vec) const |
Encode a single context block to a stream. More... | |
void | decodeContext (Decoder &decoder, const Address &addr1, const Address &addr2) |
Restore a context blob for given address range from a stream decoder. More... | |
virtual ContextBitRange & | getVariable (const string &nm) |
Retrieve the context variable description object by name. More... | |
virtual const ContextBitRange & | getVariable (const string &nm) const |
Retrieve the context variable description object by name. More... | |
virtual void | getRegionForSet (vector< uintm *> &res, const Address &addr1, const Address &addr2, int4 num, uintm mask) |
Grab the context blob(s) for the given address range, marking bits that will be set. More... | |
virtual void | getRegionToChangePoint (vector< uintm *> &res, const Address &addr, int4 num, uintm mask) |
Grab the context blob(s) starting at the given address up to the first point of change. More... | |
virtual uintm * | getDefaultValue (void) |
Retrieve the memory region holding all default context values. More... | |
virtual const uintm * | getDefaultValue (void) const |
Retrieve the memory region holding all default context values. More... | |
Private Attributes | |
int4 | size |
Number of words in a context blob (for this architecture) | |
map< string, ContextBitRange > | variables |
Map from context variable name to description object. | |
partmap< Address, FreeArray > | database |
Partition map of context blobs (FreeArray) | |
partmap< Address, TrackedSet > | trackbase |
Partition map of tracked register sets. | |
Additional Inherited Members | |
Static Protected Member Functions inherited from ghidra::ContextDatabase | |
static void | encodeTracked (Encoder &encoder, const Address &addr, const TrackedSet &vec) |
Encode all tracked register values for a specific address to a stream. More... | |
static void | decodeTracked (Decoder &decoder, TrackedSet &vec) |
Restore a sequence of tracked register values from the given stream decoder. More... | |
An in-memory implementation of the ContextDatabase interface.
Context blobs are held in a partition map on addresses. Any address within the map indicates a split point, where the value of a context variable was explicitly changed. Sets of tracked registers are held in a separate partition map.
|
virtual |
Create a tracked register set that is valid over the given range.
This really should be an internal routine. The created set is empty, old values are blown away. If old/default values are to be preserved, they must be copied back in.
addr1 | is the starting address of the given range |
addr2 | is (1 past) the ending address of the given range |
Implements ghidra::ContextDatabase.
|
virtual |
Restore the state of this database object from the given stream decoder.
decoder | is the given stream decoder |
Implements ghidra::ContextDatabase.
References ghidra::Decoder::closeElement(), ghidra::VarnodeData::decodeFromAttributes(), ghidra::VarnodeData::getAddr(), ghidra::Decoder::getNextAttributeId(), ghidra::Decoder::openElement(), and ghidra::Decoder::rewindAttributes().
|
private |
Restore a context blob for given address range from a stream decoder.
Parse either a <context_pointset> or <context_set> element. In either case, children are parsed to get context variable values. Then a context blob is reconstructed from the values. The new blob is added to the interval map based on the address range. If the start address is invalid, the default value of the context variables are painted. The second address can be invalid, if only a split point is known.
decoder | is the stream decoder |
addr1 | is the starting address of the given range |
addr2 | is the ending address of the given range |
References ghidra::Decoder::closeElement(), ghidra::ContextBitRange::getMask(), ghidra::ContextBitRange::getShift(), ghidra::ContextBitRange::getWord(), ghidra::Address::isInvalid(), ghidra::Decoder::openElement(), ghidra::Decoder::readString(), ghidra::Decoder::readUnsignedInteger(), and ghidra::ContextBitRange::setValue().
|
virtual |
Add initial context state from elements in the compiler/processor specifications.
Parse a <context_data> element from the given stream decoder from either the compiler or processor specification file for the architecture, initializing this database.
decoder | is the given stream decoder |
Implements ghidra::ContextDatabase.
References ghidra::Decoder::closeElement(), ghidra::Range::decodeFromAttributes(), ghidra::Decoder::getAddrSpaceManager(), ghidra::Range::getFirstAddr(), ghidra::Range::getLastAddrOpen(), and ghidra::Decoder::openElement().
|
virtual |
Encode the entire database to a stream.
encoder | is the stream encoder |
Implements ghidra::ContextDatabase.
References ghidra::partmap< _linetype, _valuetype >::begin(), ghidra::Encoder::closeElement(), ghidra::partmap< _linetype, _valuetype >::end(), and ghidra::Encoder::openElement().
|
private |
Encode a single context block to a stream.
The blob is broken up into individual values and written out as a series of <set> elements within a parent <context_pointset> element.
encoder | is the stream encoder |
addr | is the address of the split point where the blob is valid |
vec | is the array of words holding the blob values |
References ghidra::Encoder::closeElement(), ghidra::AddrSpace::encodeAttributes(), ghidra::Address::getOffset(), ghidra::Address::getSpace(), ghidra::Encoder::openElement(), ghidra::Encoder::writeString(), and ghidra::Encoder::writeUnsignedInteger().
|
inlinevirtual |
Get the context blob of values associated with a given address.
addr | is the given address |
Implements ghidra::ContextDatabase.
References ghidra::partmap< _linetype, _valuetype >::getValue().
|
virtual |
Get the context blob of values associated with a given address and its bounding offsets.
In addition to the memory region, the range of addresses for which the region is valid is passed back as offsets into the address space.
addr | is the given address |
first | will hold the starting offset of the valid range |
last | will hold the ending offset of the valid range |
Implements ghidra::ContextDatabase.
References ghidra::AddrSpace::getHighest(), ghidra::Address::getOffset(), and ghidra::Address::getSpace().
|
inlinevirtual |
Retrieve the number of words (uintm) in a context blob.
Implements ghidra::ContextDatabase.
|
inlineprivatevirtual |
Retrieve the memory region holding all default context values.
This fetches the active memory holding the default context values on top of which all other context values are overlaid.
Implements ghidra::ContextDatabase.
References ghidra::partmap< _linetype, _valuetype >::defaultValue().
|
inlineprivatevirtual |
Retrieve the memory region holding all default context values.
This fetches the active memory holding the default context values on top of which all other context values are overlaid.
Implements ghidra::ContextDatabase.
References ghidra::partmap< _linetype, _valuetype >::defaultValue().
|
privatevirtual |
Grab the context blob(s) for the given address range, marking bits that will be set.
This is an internal routine for obtaining the actual memory regions holding context values for the address range. This also informs the system which bits are getting set. A split is forced at the first address, and at least one memory region is passed back. The second address can be invalid in which case the memory region passed back is valid from the first address to whatever the next split point is.
res | will hold pointers to memory regions for the given range |
addr1 | is the starting address of the range |
addr2 | is (1 past) the last address of the range or is invalid |
num | is the word index for the context value that will be set |
mask | is a mask of the value being set (within its word) |
Implements ghidra::ContextDatabase.
References ghidra::partmap< _linetype, _valuetype >::begin(), ghidra::partmap< _linetype, _valuetype >::end(), ghidra::Address::isInvalid(), and ghidra::ContextBitRange::mask.
|
privatevirtual |
Grab the context blob(s) starting at the given address up to the first point of change.
This is an internal routine for obtaining the actual memory regions holding context values starting at the given address. A specific context value is specified, and all memory regions are returned up to the first address where that particular context value changes.
res | will hold pointers to memory regions being passed back |
addr | is the starting address of the regions to fetch |
num | is the word index for the specific context value being set |
mask | is a mask of the context value being set (within its word) |
Implements ghidra::ContextDatabase.
References ghidra::partmap< _linetype, _valuetype >::begin(), ghidra::partmap< _linetype, _valuetype >::end(), and ghidra::ContextBitRange::mask.
|
inlinevirtual |
Get the set of default values for all tracked registers.
Implements ghidra::ContextDatabase.
References ghidra::partmap< _linetype, _valuetype >::defaultValue().
|
inlinevirtual |
Get the set of tracked register values associated with the given address.
addr | is the given address |
Implements ghidra::ContextDatabase.
References ghidra::partmap< _linetype, _valuetype >::getValue().
|
privatevirtual |
Retrieve the context variable description object by name.
If the variable doesn't exist an exception is thrown.
nm | is the name of the context value |
Implements ghidra::ContextDatabase.
|
privatevirtual |
Retrieve the context variable description object by name.
If the variable doesn't exist an exception is thrown.
nm | is the name of the context value |
Implements ghidra::ContextDatabase.
|
virtual |
Register a new named context variable (as a bit range) with the database.
A new variable is registered by providing a name and the range of bits the value will occupy within the context blob. The full blob size is automatically increased if necessary. The variable must be contained within a single word, and all variables must be registered before any values can be set.
nm | is the name of the new variable |
sbit | is the position of the variable's most significant bit within the blob |
ebit | is the position of the variable's least significant bit within the blob |
Implements ghidra::ContextDatabase.