Ghidra Decompiler Analysis Engine
|
Go to the documentation of this file.
16 #ifndef __GLOBALCONTEXT__
17 #define __GLOBALCONTEXT__
39 int4 getShift(
void)
const {
return shift; }
40 uintm getMask(
void)
const {
return mask; }
41 int4 getWord(
void)
const {
return word; }
48 uintm newval = vec[word];
49 newval &= ~(mask<<shift);
50 newval |= ((val & mask)<<shift);
59 return ((vec[word]>>shift)&mask);
140 const Address &addr2,int4 num,uintm mask)=0;
199 virtual const uintm *
getContext(
const Address &addr,uintb &first,uintb &last)
const=0;
224 virtual void saveXml(ostream &s)
const=0;
247 const Address &endad,uintm value);
267 FreeArray(
void) { size=0; array = (uintm *)0; mask = (uintm *)0; }
268 ~FreeArray(
void) {
if (size!=0) {
delete [] array;
delete [] mask; } }
270 FreeArray &operator=(
const FreeArray &op2);
274 map<string,ContextBitRange> variables;
277 void saveContext(ostream &s,
const Address &addr,
const uintm *vec)
const;
281 virtual void getRegionForSet(vector<uintm *> &res,
const Address &addr1,
282 const Address &addr2,int4 num,uintm mask);
283 virtual void getRegionToChangePoint(vector<uintm *> &res,
const Address &addr,int4 num,uintm mask);
284 virtual uintm *getDefaultValue(
void) {
return database.defaultValue().array; }
285 virtual const uintm *getDefaultValue(
void)
const {
return database.defaultValue().array; }
293 virtual const uintm *
getContext(
const Address &addr,uintb &first,uintb &last)
const;
299 virtual void saveXml(ostream &s)
const;
315 mutable const uintm *context;
319 void allowSet(
bool val) { allowset = val; }
_valuetype & getValue(const _linetype &pnt)
Get the value object at a point.
Definition: partmap.hh:81
static void saveTracked(ostream &s, const Address &addr, const TrackedSet &vec)
Save all tracked register values for a specific address to an XML stream.
Definition: globalcontext.cc:69
virtual void getRegionToChangePoint(vector< uintm * > &res, const Address &addr, int4 num, uintm mask)=0
Grab the context blob(s) starting at the given address up to the first point of change.
void restoreXml(const Element *el, const AddrSpaceManager *manage)
Restore this from an XML stream.
Definition: globalcontext.cc:47
An in-memory implementation of the ContextDatabase interface.
Definition: globalcontext.hh:256
A region where processor data is stored.
Definition: space.hh:73
The partmap<> template mapping a linear space to value objects.
virtual const uintm * getContext(const Address &addr) const =0
Get the context blob of values associated with a given address.
virtual TrackedSet & createSet(const Address &addr1, const Address &addr2)
Create a tracked register set that is valid over the given range.
Definition: globalcontext.cc:482
virtual void restoreXml(const Element *el, const AddrSpaceManager *manage)
Restore the state of this database object from a serialized XML stream.
Definition: globalcontext.cc:512
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.
Definition: globalcontext.cc:190
virtual ContextBitRange & getVariable(const string &nm)=0
Retrieve the context variable description object by name.
Description of a context variable within the disassembly context blob.
Definition: globalcontext.hh:30
virtual void saveXml(ostream &s) const =0
Serialize the entire database to an XML stream.
An XML element. A node in the DOM tree.
Definition: xml.hh:150
void setVariableDefault(const string &nm, uintm val)
Provide a default value for a context variable.
Definition: globalcontext.cc:109
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.
Definition: globalcontext.cc:601
uintb getTrackedValue(const VarnodeData &mem, const Address &point) const
Get the value of a tracked register at a specific address.
Definition: globalcontext.cc:229
VarnodeData loc
Storage details of the register being tracked.
Definition: globalcontext.hh:69
vector< TrackedContext > TrackedSet
A set of tracked registers and their values (at one code point)
Definition: globalcontext.hh:74
virtual int4 getContextSize(void) const =0
Retrieve the number of words (uintm) in a context blob.
static void restoreTracked(const Element *el, const AddrSpaceManager *manage, TrackedSet &vec)
Restore a sequence of tracked register values from an XML stream.
Definition: globalcontext.cc:90
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.
Definition: globalcontext.cc:207
virtual void restoreXml(const Element *el, const AddrSpaceManager *manage)=0
Restore the state of this database object from a serialized XML stream.
uintm getValue(const uintm *vec) const
Retrieve this value from a given context blob.
Definition: globalcontext.hh:58
virtual const uintm * getContext(const Address &addr) const
Get the context blob of values associated with a given address.
Definition: globalcontext.hh:292
virtual TrackedSet & getTrackedDefault(void)
Get the set of default values for all tracked registers.
Definition: globalcontext.hh:295
virtual TrackedSet & createSet(const Address &addr1, const Address &addr2)=0
Create a tracked register set that is valid over the given range.
virtual void registerVariable(const string &nm, int4 sbit, int4 ebit)
Register a new named context variable (as a bit range) with the database.
Definition: globalcontext.cc:380
A helper class for caching the active context blob to minimize database lookups.
Definition: globalcontext.hh:309
virtual uintm * getDefaultValue(void)=0
Retrieve the memory region holding all default context values.
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
void setValue(uintm *vec, uintm val) const
Set this value within a given context blob.
Definition: globalcontext.hh:47
An interface to a database of disassembly/decompiler context information.
Definition: globalcontext.hh:108
A tracked register (Varnode) and the value it contains.
Definition: globalcontext.hh:68
void getContext(const Address &addr, uintm *buf) const
Retrieve the context blob for the given address.
Definition: globalcontext.cc:582
virtual void restoreFromSpec(const Element *el, const AddrSpaceManager *manage)
Add initial context state from XML tags in compiler/processor specifications.
Definition: globalcontext.cc:539
virtual void getRegionForSet(vector< uintm * > &res, const Address &addr1, const Address &addr2, int4 num, uintm mask)=0
Grab the context blob(s) for the given address range, marking bits that will be set.
void setContextChangePoint(const Address &addr, int4 num, uintm mask, uintm value)
Set a specific context value starting at the given address.
Definition: globalcontext.cc:167
uintb val
The value of the register.
Definition: globalcontext.hh:70
ContextCache(ContextDatabase *db)
Construct given a context database.
Definition: globalcontext.cc:570
void setVariable(const string &nm, const Address &addr, uintm value)
Set a context value at the given address.
Definition: globalcontext.cc:131
virtual int4 getContextSize(void) const
Retrieve the number of words (uintm) in a context blob.
Definition: globalcontext.hh:289
void saveXml(ostream &s) const
Save this to an XML stream.
Definition: globalcontext.cc:35
virtual void restoreFromSpec(const Element *el, const AddrSpaceManager *manage)=0
Add initial context state from XML tags in compiler/processor specifications.
ContextBitRange(int4 sbit, int4 ebit)
Construct a context value given an absolute bit range.
Definition: globalcontext.cc:23
virtual void registerVariable(const string &nm, int4 sbit, int4 ebit)=0
Register a new named context variable (as a bit range) with the database.
virtual TrackedSet & getTrackedDefault(void)=0
Get the set of default values for all tracked registers.
Data defining a specific memory location.
Definition: pcoderaw.hh:33
Raw descriptions of varnodes and p-code ops.
virtual const TrackedSet & getTrackedSet(const Address &addr) const =0
Get the set of tracked register values associated with the given address.
A manager for different address spaces.
Definition: translate.hh:218
virtual void saveXml(ostream &s) const
Serialize the entire database to an XML stream.
Definition: globalcontext.cc:490
virtual const TrackedSet & getTrackedSet(const Address &addr) const
Get the set of tracked register values associated with the given address.
Definition: globalcontext.hh:296