Package ghidra.program.model.pcode
Class PackedDecode
java.lang.Object
ghidra.program.model.pcode.PackedDecode
- All Implemented Interfaces:
ByteIngest,Decoder
- Direct Known Subclasses:
PackedDecodeOverlay
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intprotected AddressSpace[]static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear any previous cached bytes.voidcloseElement(int id) Close the current element The data for the current element is considered fully processed.voidcloseElementSkipping(int id) Close the current element, skipping any child elements that have not yet been parsed.voidFormal indicator that ingesting of bytes is complete and processing can beginintgetIndexedAttributeId(AttributeId attribId) Get the id for the (current) attribute, assuming it is indexed.intGet the next attribute id for the current element Attributes are automatically set up for traversal using this method, when the element is opened.voidingestStream(InputStream stream) Ingest bytes from the stream up to (and including) the first 0 byte.booleanisEmpty()voidOpen the ingester for receiving bytes.intOpen (traverse into) the next child element of the current parent.intopenElement(ElementId elemId) Open (traverse into) the next child element, which must be of a specific type The child becomes the current parent, and its attributes are initialized for use with getNextAttributeId.intPeek at the next child element of the current parent, without traversing in (opening) it.booleanreadBool()Parse the current attribute as a boolean value The last attribute, as returned by getNextAttributeId, is treated as a boolean, and its value is returned.booleanreadBool(AttributeId attribId) Find and parse a specific attribute in the current element as a boolean value The set of attributes for the current element is searched for a match to the given attribute id.longParse the current attribute as a signed integer value The last attribute, as returned by getNextAttributeId, is treated as a signed integer, and its value is returned.longreadSignedInteger(AttributeId attribId) Find and parse a specific attribute in the current element as a signed integer The set of attributes for the current element is searched for a match to the given attribute id.longreadSignedIntegerExpectString(AttributeId attribId, String expect, long expectval) Find and parse a specific attribute in the current element as either a signed integer or a string.longreadSignedIntegerExpectString(String expect, long expectval) Parse the current attribute as either a signed integer value or a string.Parse the current attribute as an address space The last attribute, as returned by getNextAttributeId, is returned as an address space.readSpace(AttributeId attribId) Find the specific attribute in the current element and return it as an address space Search attributes from the current element for a match to the given attribute id.Parse the current attribute as a string The last attribute, as returned by getNextAttributeId, is returned as a string.readString(AttributeId attribId) Find the specific attribute in the current element and return it as a string The set of attributes for the current element is searched for a match to the given attribute id.longParse the current attribute as an unsigned integer value The last attribute, as returned by getNextAttributeId, is treated as an unsigned integer, and its value is returned.longreadUnsignedInteger(AttributeId attribId) Find and parse a specific attribute in the current element as an unsigned integer The set of attributes for the current element is searched for a match to the given attribute id.voidReset attribute traversal for the current element Attributes for a single element can be traversed more than once using the getNextAttributeId method.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ghidra.program.model.pcode.Decoder
skipElement
-
Field Details
-
HEADER_MASK
public static final int HEADER_MASK- See Also:
-
ELEMENT_START
public static final int ELEMENT_START- See Also:
-
ELEMENT_END
public static final int ELEMENT_END- See Also:
-
ATTRIBUTE
public static final int ATTRIBUTE- See Also:
-
HEADEREXTEND_MASK
public static final int HEADEREXTEND_MASK- See Also:
-
ELEMENTID_MASK
public static final int ELEMENTID_MASK- See Also:
-
RAWDATA_MASK
public static final int RAWDATA_MASK- See Also:
-
RAWDATA_BITSPERBYTE
public static final int RAWDATA_BITSPERBYTE- See Also:
-
RAWDATA_MARKER
public static final int RAWDATA_MARKER- See Also:
-
TYPECODE_SHIFT
public static final int TYPECODE_SHIFT- See Also:
-
LENGTHCODE_MASK
public static final int LENGTHCODE_MASK- See Also:
-
TYPECODE_BOOLEAN
public static final int TYPECODE_BOOLEAN- See Also:
-
TYPECODE_SIGNEDINT_POSITIVE
public static final int TYPECODE_SIGNEDINT_POSITIVE- See Also:
-
TYPECODE_SIGNEDINT_NEGATIVE
public static final int TYPECODE_SIGNEDINT_NEGATIVE- See Also:
-
TYPECODE_UNSIGNEDINT
public static final int TYPECODE_UNSIGNEDINT- See Also:
-
TYPECODE_ADDRESSSPACE
public static final int TYPECODE_ADDRESSSPACE- See Also:
-
TYPECODE_SPECIALSPACE
public static final int TYPECODE_SPECIALSPACE- See Also:
-
TYPECODE_STRING
public static final int TYPECODE_STRING- See Also:
-
SPECIALSPACE_STACK
public static final int SPECIALSPACE_STACK- See Also:
-
SPECIALSPACE_JOIN
public static final int SPECIALSPACE_JOIN- See Also:
-
SPECIALSPACE_FSPEC
public static final int SPECIALSPACE_FSPEC- See Also:
-
SPECIALSPACE_IOP
public static final int SPECIALSPACE_IOP- See Also:
-
SPECIALSPACE_SPACEBASE
public static final int SPECIALSPACE_SPACEBASE- See Also:
-
spaces
-
-
Constructor Details
-
PackedDecode
-
-
Method Details
-
getAddressFactory
- Specified by:
getAddressFactoryin interfaceDecoder
-
clear
public void clear()Description copied from interface:ByteIngestClear any previous cached bytes.- Specified by:
clearin interfaceByteIngest
-
open
Description copied from interface:ByteIngestOpen the ingester for receiving bytes. This establishes the description of the source of the bytes and maximum number of bytes that can be read- Specified by:
openin interfaceByteIngest- Parameters:
max- is the maximum number of bytes that can be readsource- is the description of the byte source
-
ingestStream
Description copied from interface:ByteIngestIngest bytes from the stream up to (and including) the first 0 byte. This can be called multiple times to read in bytes in different chunks. An absolute limit is set on the number of bytes that can be ingested via the max parameter to a previous call to open(), otherwise an exception is thrown.- Specified by:
ingestStreamin interfaceByteIngest- Parameters:
stream- is the input stream to read from- Throws:
IOException- for errors reading from the stream
-
endIngest
public void endIngest()Description copied from interface:ByteIngestFormal indicator that ingesting of bytes is complete and processing can begin- Specified by:
endIngestin interfaceByteIngest
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceByteIngest- Returns:
- true if no bytes have yet been ingested via ingestStream()
-
peekElement
Description copied from interface:DecoderPeek at the next child element of the current parent, without traversing in (opening) it. The element id is returned, which can be compared to ElementId labels. If there are no remaining child elements to traverse, 0 is returned.- Specified by:
peekElementin interfaceDecoder- Returns:
- the element id or 0
- Throws:
DecoderException- for an unexpected end of stream
-
openElement
Description copied from interface:DecoderOpen (traverse into) the next child element of the current parent. The child becomes the current parent. The list of attributes is initialized for use with getNextAttributeId.- Specified by:
openElementin interfaceDecoder- Returns:
- the id of the child element or 0 if there are no additional children
- Throws:
DecoderException- for an unexpected end of stream
-
openElement
Description copied from interface:DecoderOpen (traverse into) the next child element, which must be of a specific type The child becomes the current parent, and its attributes are initialized for use with getNextAttributeId. The child must match the given element id or an exception is thrown.- Specified by:
openElementin interfaceDecoder- Parameters:
elemId- is the given element id to match- Returns:
- the id of the child element
- Throws:
DecoderException- if the expected element is not the next element
-
closeElement
Description copied from interface:DecoderClose the current element The data for the current element is considered fully processed. If the element has additional children, an exception is thrown. The stream must indicate the end of the element in some way.- Specified by:
closeElementin interfaceDecoder- Parameters:
id- is the id of the element to close (which must be the current element)- Throws:
DecoderException- if not at end of expected element
-
closeElementSkipping
Description copied from interface:DecoderClose the current element, skipping any child elements that have not yet been parsed. This closes the given element, which must be current. If there are child elements that have not been parsed, this is not considered an error, and they are skipped over in the parse.- Specified by:
closeElementSkippingin interfaceDecoder- Parameters:
id- is the id of the element to close (which must be the current element)- Throws:
DecoderException- if the indicated element is not the current element
-
getNextAttributeId
Description copied from interface:DecoderGet the next attribute id for the current element Attributes are automatically set up for traversal using this method, when the element is opened. If all attributes have been traversed (or there are no attributes), 0 is returned.- Specified by:
getNextAttributeIdin interfaceDecoder- Returns:
- the id of the next attribute or 0
- Throws:
DecoderException- for unexpected end of stream
-
getIndexedAttributeId
Description copied from interface:DecoderGet the id for the (current) attribute, assuming it is indexed. Assuming the previous call to getNextAttributeId() returned the id of ATTRIB_UNKNOWN, reinterpret the attribute as being an indexed form of the given attribute. If the attribute matches, return this indexed id, otherwise return ATTRIB_UNKNOWN.- Specified by:
getIndexedAttributeIdin interfaceDecoder- Parameters:
attribId- is the attribute being indexed- Returns:
- the indexed id or ATTRIB_UNKNOWN
- Throws:
DecoderException- for unexpected end of stream
-
rewindAttributes
public void rewindAttributes()Description copied from interface:DecoderReset attribute traversal for the current element Attributes for a single element can be traversed more than once using the getNextAttributeId method.- Specified by:
rewindAttributesin interfaceDecoder
-
readBool
Description copied from interface:DecoderParse the current attribute as a boolean value The last attribute, as returned by getNextAttributeId, is treated as a boolean, and its value is returned.- Specified by:
readBoolin interfaceDecoder- Returns:
- the boolean value associated with the current attribute.
- Throws:
DecoderException- if the expected value is not present
-
readBool
Description copied from interface:DecoderFind and parse a specific attribute in the current element as a boolean value The set of attributes for the current element is searched for a match to the given attribute id. This attribute is then parsed as a boolean and its value returned. If there is no attribute matching the id, an exception is thrown. Parsing via getNextAttributeId is reset.- Specified by:
readBoolin interfaceDecoder- Parameters:
attribId- is the specific attribute id to match- Returns:
- the boolean value
- Throws:
DecoderException- if the expected value is not present
-
readSignedInteger
Description copied from interface:DecoderParse the current attribute as a signed integer value The last attribute, as returned by getNextAttributeId, is treated as a signed integer, and its value is returned.- Specified by:
readSignedIntegerin interfaceDecoder- Returns:
- the signed integer value associated with the current attribute.
- Throws:
DecoderException- if the expected value is not present
-
readSignedInteger
Description copied from interface:DecoderFind and parse a specific attribute in the current element as a signed integer The set of attributes for the current element is searched for a match to the given attribute id. This attribute is then parsed as a signed integer and its value returned. If there is no attribute matching the id, an exception is thrown. Parsing via getNextAttributeId is reset.- Specified by:
readSignedIntegerin interfaceDecoder- Parameters:
attribId- is the specific attribute id to match- Returns:
- the signed integer value
- Throws:
DecoderException- if the expected value is not present
-
readSignedIntegerExpectString
Description copied from interface:DecoderParse the current attribute as either a signed integer value or a string. If the attribute is an integer, its value is returned. If the attribute is a string, it must match an expected string passed to the method, and a predetermined integer value associated with the string is returned. If the attribute string does not match, or the attribute is encoded as anything other than a string or signed integer, an exception is thrown.- Specified by:
readSignedIntegerExpectStringin interfaceDecoder- Parameters:
expect- is the string value to expect if the attribute is encoded as a stringexpectval- is the integer value to return if the attribute matches the expected string- Returns:
- the encoded integer or the integer value associated with the expected string
- Throws:
DecoderException- is an integer value or expected string cannot be parsed
-
readSignedIntegerExpectString
public long readSignedIntegerExpectString(AttributeId attribId, String expect, long expectval) throws DecoderException Description copied from interface:DecoderFind and parse a specific attribute in the current element as either a signed integer or a string. If the attribute is an integer, its value is returned. If the attribute is encoded as a string, it must match an expected string passed to this method. In this case, a predetermined integer value is passed back, indicating a matching string was parsed. If the attribute string does not match, or the attribute is encoded as anything other than a string or signed integer, an exception is thrown.- Specified by:
readSignedIntegerExpectStringin interfaceDecoder- Parameters:
attribId- is the specific attribute id to matchexpect- is the string to expect, if the attribute is not encoded as an integerexpectval- is the integer value to return if the attribute matches the expected string- Returns:
- the encoded integer or the integer value associated with the expected string
- Throws:
DecoderException- if an integer value or expected string cannot be parsed
-
readUnsignedInteger
Description copied from interface:DecoderParse the current attribute as an unsigned integer value The last attribute, as returned by getNextAttributeId, is treated as an unsigned integer, and its value is returned.- Specified by:
readUnsignedIntegerin interfaceDecoder- Returns:
- the unsigned integer value associated with the current attribute.
- Throws:
DecoderException- if the expected value is not present
-
readUnsignedInteger
Description copied from interface:DecoderFind and parse a specific attribute in the current element as an unsigned integer The set of attributes for the current element is searched for a match to the given attribute id. This attribute is then parsed as an unsigned integer and its value returned. If there is no attribute matching the id, an exception is thrown. Parsing via getNextAttributeId is reset.- Specified by:
readUnsignedIntegerin interfaceDecoder- Parameters:
attribId- is the specific attribute id to match- Returns:
- the unsigned integer value
- Throws:
DecoderException- if the expected value is not present
-
readString
Description copied from interface:DecoderParse the current attribute as a string The last attribute, as returned by getNextAttributeId, is returned as a string.- Specified by:
readStringin interfaceDecoder- Returns:
- the string associated with the current attribute.
- Throws:
DecoderException- if the expected value is not present
-
readString
Description copied from interface:DecoderFind the specific attribute in the current element and return it as a string The set of attributes for the current element is searched for a match to the given attribute id. This attribute is then returned as a string. If there is no attribute matching the id, and exception is thrown. Parse via getNextAttributeId is reset.- Specified by:
readStringin interfaceDecoder- Parameters:
attribId- is the specific attribute id to match- Returns:
- the string associated with the attribute
- Throws:
DecoderException- if the expected value is not present
-
readSpace
Description copied from interface:DecoderParse the current attribute as an address space The last attribute, as returned by getNextAttributeId, is returned as an address space.- Specified by:
readSpacein interfaceDecoder- Returns:
- the address space associated with the current attribute.
- Throws:
DecoderException- if the expected value is not present
-
readSpace
Description copied from interface:DecoderFind the specific attribute in the current element and return it as an address space Search attributes from the current element for a match to the given attribute id. Return this attribute as an address space. If there is no attribute matching the id, an exception is thrown. Parse via getNextAttributeId is reset.- Specified by:
readSpacein interfaceDecoder- Parameters:
attribId- is the specific attribute id to match- Returns:
- the address space associated with the attribute
- Throws:
DecoderException- if the expected value is not present
-