GP-2157 Marshaling refactor. Decompiler side.

This commit is contained in:
caheckman 2022-05-17 16:15:21 -04:00
parent 672c1f11e2
commit d8c10bf229
97 changed files with 5313 additions and 3733 deletions

View file

@ -20,7 +20,7 @@
#define __CPUI_SPACE__
#include "error.hh"
#include "xml.hh"
#include "marshal.hh"
/// \brief Fundemental address space types
///
@ -40,6 +40,21 @@ class AddrSpaceManager;
struct VarnodeData;
class Translate;
extern AttributeId ATTRIB_BASE; ///< Marshaling attribute "base"
extern AttributeId ATTRIB_DEADCODEDELAY; ///< Marshaling attribute "deadcodedelay"
extern AttributeId ATTRIB_DELAY; ///< Marshaling attribute "delay"
extern AttributeId ATTRIB_LOGICALSIZE; ///< Marshaling attribute "logicalsize"
extern AttributeId ATTRIB_PHYSICAL; ///< Marshaling attribute "physical"
extern AttributeId ATTRIB_PIECE1; ///< Marshaling attribute "piece1"
extern AttributeId ATTRIB_PIECE2; ///< Marshaling attribute "piece2"
extern AttributeId ATTRIB_PIECE3; ///< Marshaling attribute "piece3"
extern AttributeId ATTRIB_PIECE4; ///< Marshaling attribute "piece4"
extern AttributeId ATTRIB_PIECE5; ///< Marshaling attribute "piece5"
extern AttributeId ATTRIB_PIECE6; ///< Marshaling attribute "piece6"
extern AttributeId ATTRIB_PIECE7; ///< Marshaling attribute "piece7"
extern AttributeId ATTRIB_PIECE8; ///< Marshaling attribute "piece8"
extern AttributeId ATTRIB_PIECE9; ///< Marshaling attribute "piece9"
/// \brief A region where processor data is stored
///
/// An AddrSpace (Address Space) is an arbitrary sequence of
@ -108,10 +123,11 @@ protected:
void setFlags(uint4 fl); ///< Set a cached attribute
void clearFlags(uint4 fl); ///< Clear a cached attribute
void saveBasicAttributes(ostream &s) const; ///< Write the XML attributes of this space
void decodeBasicAttributes(Decoder &decoder); ///< Read attributes for \b this space from an open XML element
void truncateSpace(uint4 newsize);
public:
AddrSpace(AddrSpaceManager *m,const Translate *t,spacetype tp,const string &nm,uint4 size,uint4 ws,int4 ind,uint4 fl,int4 dl);
AddrSpace(AddrSpaceManager *m,const Translate *t,spacetype tp); ///< For use with restoreXml
AddrSpace(AddrSpaceManager *m,const Translate *t,spacetype tp); ///< For use with decode
virtual ~AddrSpace(void) {} ///< The address space destructor
const string &getName(void) const; ///< Get the name
AddrSpaceManager *getManager(void) const; ///< Get the space manager
@ -145,13 +161,13 @@ public:
virtual const VarnodeData &getSpacebaseFull(int4 i) const; ///< Return original spacebase register before truncation
virtual bool stackGrowsNegative(void) const; ///< Return \b true if a stack in this space grows negative
virtual AddrSpace *getContain(void) const; ///< Return this space's containing space (if any)
virtual void saveXmlAttributes(ostream &s,uintb offset) const; ///< Save an address as XML
virtual void saveXmlAttributes(ostream &s,uintb offset,int4 size) const; ///< Save an address and size as XML
virtual uintb restoreXmlAttributes(const Element *el,uint4 &size) const; ///< Recover an offset and size
virtual void encodeAttributes(Encoder &encoder,uintb offset) const; ///< Encode address attributes to a stream
virtual void encodeAttributes(Encoder &encoder,uintb offset,int4 size) const; ///< Encode an address and size attributes to a stream
virtual uintb decodeAttributes(Decoder &decoder,uint4 &size) const; ///< Recover an offset and size
virtual void printRaw(ostream &s,uintb offset) const; ///< Write an address in this space to a stream
virtual uintb read(const string &s,int4 &size) const; ///< Read in an address (and possible size) from a string
virtual void saveXml(ostream &s) const; ///< Write the details of this space as XML
virtual void restoreXml(const Element *el); ///< Recover the details of this space from XML
virtual void decode(Decoder &decoder); ///< Recover the details of this space from XML
static uintb addressToByte(uintb val,uint4 ws); ///< Scale from addressable units to byte units
static uintb byteToAddress(uintb val,uint4 ws); ///< Scale from byte units to addressable units
@ -177,7 +193,7 @@ public:
ConstantSpace(AddrSpaceManager *m,const Translate *t); ///< Only constructor
virtual void printRaw(ostream &s,uintb offset) const;
virtual void saveXml(ostream &s) const;
virtual void restoreXml(const Element *el);
virtual void decode(Decoder &decoder);
static const string NAME; ///< Reserved name for the address space
static const int4 INDEX; ///< Reserved index for constant space
};
@ -186,7 +202,7 @@ public:
class OtherSpace : public AddrSpace {
public:
OtherSpace(AddrSpaceManager *m, const Translate *t, int4 ind); ///< Constructor
OtherSpace(AddrSpaceManager *m, const Translate *t); ///< For use with restoreXml
OtherSpace(AddrSpaceManager *m, const Translate *t); ///< For use with decode
virtual void printRaw(ostream &s, uintb offset) const;
virtual void saveXml(ostream &s) const;
static const string NAME; ///< Reserved name for the address space
@ -205,7 +221,7 @@ public:
class UniqueSpace : public AddrSpace {
public:
UniqueSpace(AddrSpaceManager *m,const Translate *t,int4 ind,uint4 fl); ///< Constructor
UniqueSpace(AddrSpaceManager *m,const Translate *t); ///< For use with restoreXml
UniqueSpace(AddrSpaceManager *m,const Translate *t); ///< For use with decode
virtual void saveXml(ostream &s) const;
static const string NAME; ///< Reserved name for the unique space
static const uint4 SIZE; ///< Fixed size (in bytes) for unique space offsets
@ -222,13 +238,13 @@ public:
class JoinSpace : public AddrSpace {
public:
JoinSpace(AddrSpaceManager *m,const Translate *t,int4 ind);
virtual void saveXmlAttributes(ostream &s,uintb offset) const;
virtual void saveXmlAttributes(ostream &s,uintb offset,int4 size) const;
virtual uintb restoreXmlAttributes(const Element *el,uint4 &size) const;
virtual void encodeAttributes(Encoder &encoder,uintb offset) const;
virtual void encodeAttributes(Encoder &encoder,uintb offset,int4 size) const;
virtual uintb decodeAttributes(Decoder &decoder,uint4 &size) const;
virtual void printRaw(ostream &s,uintb offset) const;
virtual uintb read(const string &s,int4 &size) const;
virtual void saveXml(ostream &s) const;
virtual void restoreXml(const Element *el);
virtual void decode(Decoder &decoder);
static const string NAME; ///< Reserved name for the join space
};
@ -246,7 +262,7 @@ public:
OverlaySpace(AddrSpaceManager *m,const Translate *t); ///< Constructor
virtual AddrSpace *getContain(void) const { return baseSpace; }
virtual void saveXml(ostream &s) const;
virtual void restoreXml(const Element *el);
virtual void decode(Decoder &decoder);
};
/// An internal method for derived classes to set space attributes