Package ghidra.program.model.pcode
Class PcodeSyntaxTree
java.lang.Object
ghidra.program.model.pcode.PcodeSyntaxTree
- All Implemented Interfaces:
PcodeFactory
- Direct Known Subclasses:
HighFunction
,HighParamID
Varnodes and PcodeOps in a coherent graph structure
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuildStorage
(Varnode vn) Build a storage object for a particular Varnodevoid
clear()
void
void
findInputVarnode
(int sz, Address addr) return Varnode of given size and starting Address, which is also an inputfindVarnode
(int sz, Address addr, Address pc) return first instance of a Varnode with given size, starting Address, and bound to an instruction at the given AddressfindVarnode
(int sz, Address addr, SequenceNumber sq) return Varnode of given size and starting Address defined by a PcodeOp with a given SequenceNumbergetJoinAddress
(VariableStorage storage) Get the address (in the "join" space) corresponding to the given multi-piece storage.getJoinStorage
(Varnode[] pieces) Create a storage object representing a value split across multiple physical locations.int
getOpRef
(int id) Get a PcodeOp given a reference id.return all PcodeOps (alive or dead) ordered by SequenceNumbergetPcodeOps
(Address addr) return all PcodeOps associated with a particular instruction AddressgetRef
(int id) Return a Varnode given its reference id, or null if the id is not registered.getSymbol
(long symbolId) Get the high symbol matching the given id that has been registered with this objectgetVarnodes
(int sz, Address addr) return all Varnodes of a given size that start at a given AddressgetVarnodes
(Address addr) return all Varnodes that start at a given AddressgetVarnodes
(AddressSpace spc) return Iterator to all Varnodes in the indicated AddressSpacevoid
insertAfter
(PcodeOp newop, PcodeOp prev) void
insertBefore
(PcodeOp newop, PcodeOp follow) locRange()
newOp
(SequenceNumber sq, int opc, ArrayList<Varnode> inputs, Varnode output) Create a new PcodeOp given its opcode, sequence number, and input and output VarnodesnewVarnode
(int sz, Address addr) Create a new Varnode with the given size and locationnewVarnode
(int sz, Address addr, int id) Create a new Varnode with the given size and location.void
setAddrTied
(Varnode vn, boolean val) Mark (or unmark) the given Varnode with the "address tied" propertyvoid
setDataType
(Varnode vn, DataType type) Attach a data-type to the given Varnodevoid
Mark (or unmark) the given Varnode as an input (to its function)void
setMergeGroup
(Varnode vn, short val) Associate a specific merge group with the given Varnodevoid
void
void
setPersistent
(Varnode vn, boolean val) Mark (or unmark) the given Varnode with the "persistent" propertyvoid
setUnaffected
(Varnode vn, boolean val) Mark (or unmark) the given Varnode with the "unaffected" propertyvoid
setVolatile
(Varnode vn, boolean val) Mark (or unmark) the given Varnode with the "volatile" propertyvoid
void
unlink
(PcodeOpAST op) void
unSetInput
(PcodeOp op, int slot) void
unSetOutput
(PcodeOp op)
-
Constructor Details
-
PcodeSyntaxTree
-
-
Method Details
-
clear
public void clear() -
getJoinAddress
Description copied from interface:PcodeFactory
Get the address (in the "join" space) corresponding to the given multi-piece storage. The storage must have been previously registered by a previous call to getJoinStorage(). If the storage is not multi-piece or was not registered, null is returned.- Specified by:
getJoinAddress
in interfacePcodeFactory
- Parameters:
storage
- is the multi-piece storage- Returns:
- the corresponding "join" address
-
getJoinStorage
Description copied from interface:PcodeFactory
Create a storage object representing a value split across multiple physical locations. The sequence of physical locations are passed in as an array of Varnodes and the storage object is returned. The storage is also assigned an Address in the join address space, which can be retrieved by calling the getJoinAddress() method. The join Address can be used to create a Varnode that represents the logical whole created by concatenating the Varnode pieces.- Specified by:
getJoinStorage
in interfacePcodeFactory
- Parameters:
pieces
- is the array of Varnode pieces to join- Returns:
- the VariableStorage representing the whole
- Throws:
InvalidInputException
- if a valid storage object cannot be created
-
buildStorage
Description copied from interface:PcodeFactory
Build a storage object for a particular Varnode- Specified by:
buildStorage
in interfacePcodeFactory
- Parameters:
vn
- is the Varnode- Returns:
- the storage object
- Throws:
InvalidInputException
- if valid storage cannot be created
-
locRange
- Returns:
- an iterator for all Varnodes in the tree ordered by Address
-
getVarnodes
return Iterator to all Varnodes in the indicated AddressSpace- Parameters:
spc
- -- AddressSpace to restrict Iterator to- Returns:
- -- Iterator to Varnodes
-
getVarnodes
return all Varnodes that start at a given Address- Parameters:
addr
- -- Address of Varnodes- Returns:
- -- Iterator to Varnodes
-
getVarnodes
return all Varnodes of a given size that start at a given Address- Parameters:
sz
- -- Size of Varnodesaddr
- -- Starting Address of Varnodes- Returns:
- -- Iterator to Varnodes
-
findVarnode
return first instance of a Varnode with given size, starting Address, and bound to an instruction at the given Address- Parameters:
sz
- -- size of Varnodeaddr
- -- starting Address of Varnodepc
- -- Address of instruction writing to Varnode- Returns:
- -- the Varnode
-
findVarnode
return Varnode of given size and starting Address defined by a PcodeOp with a given SequenceNumber- Parameters:
sz
- -- size of Varnodeaddr
- -- starting Address of Varnodesq
- -- SequenceNumber of PcodeOp defining the Varnode- Returns:
- -- the Varnode
-
findInputVarnode
return Varnode of given size and starting Address, which is also an input- Parameters:
sz
- -- size of Varnodeaddr
- -- starting Address of Varnode- Returns:
- -- the Varnode
-
getNumVarnodes
public int getNumVarnodes() -
getPcodeOps
return all PcodeOps (alive or dead) ordered by SequenceNumber- Returns:
- -- Iterator to PcodeOps
-
getPcodeOps
return all PcodeOps associated with a particular instruction Address- Parameters:
addr
- -- Address of instruction generating PcodeOps- Returns:
- -- Iterator to PcodeOps
-
getPcodeOp
-
getBasicBlocks
-
getAddressFactory
- Specified by:
getAddressFactory
in interfacePcodeFactory
- Returns:
- Address factory
-
getDataTypeManager
- Specified by:
getDataTypeManager
in interfacePcodeFactory
- Returns:
- pcode data type manager used to convert strings to Ghidra data types
-
newVarnode
Description copied from interface:PcodeFactory
Create a new Varnode with the given size and location- Specified by:
newVarnode
in interfacePcodeFactory
- Parameters:
sz
- size of the Varnodeaddr
- location of the Varnode- Returns:
- a new varnode
-
newVarnode
Description copied from interface:PcodeFactory
Create a new Varnode with the given size and location. Associate the Varnode with a specific reference id so that it can be retrieved, using just the id, via getRef();- Specified by:
newVarnode
in interfacePcodeFactory
- Parameters:
sz
- size of the Varnodeaddr
- location of the Varnodeid
- is the specific reference id- Returns:
- the new Varnode
-
setInput
Description copied from interface:PcodeFactory
Mark (or unmark) the given Varnode as an input (to its function)- Specified by:
setInput
in interfacePcodeFactory
- Parameters:
vn
- is the given Varnodeval
- is true if the Varnode should be marked- Returns:
- the altered Varnode, which may not be the same object passed in
-
getRef
Description copied from interface:PcodeFactory
Return a Varnode given its reference id, or null if the id is not registered. The id must have previously been registered via newVarnode().- Specified by:
getRef
in interfacePcodeFactory
- Parameters:
id
- is the reference id- Returns:
- the matching Varnode or null
-
getSymbol
Description copied from interface:PcodeFactory
Get the high symbol matching the given id that has been registered with this object- Specified by:
getSymbol
in interfacePcodeFactory
- Parameters:
symbolId
- is the given id- Returns:
- the matching HighSymbol or null
-
setDataType
Description copied from interface:PcodeFactory
Attach a data-type to the given Varnode- Specified by:
setDataType
in interfacePcodeFactory
- Parameters:
vn
- is the given Varnodetype
- is the data-type
-
setAddrTied
Description copied from interface:PcodeFactory
Mark (or unmark) the given Varnode with the "address tied" property- Specified by:
setAddrTied
in interfacePcodeFactory
- Parameters:
vn
- is the given Varnodeval
- is true if the Varnode should be marked
-
setPersistent
Description copied from interface:PcodeFactory
Mark (or unmark) the given Varnode with the "persistent" property- Specified by:
setPersistent
in interfacePcodeFactory
- Parameters:
vn
- is the given Varnodeval
- is true if the Varnode should be marked
-
setUnaffected
Description copied from interface:PcodeFactory
Mark (or unmark) the given Varnode with the "unaffected" property- Specified by:
setUnaffected
in interfacePcodeFactory
- Parameters:
vn
- is the given Varnodeval
- is true if the Varnode should be marked
-
setVolatile
Description copied from interface:PcodeFactory
Mark (or unmark) the given Varnode with the "volatile" property- Specified by:
setVolatile
in interfacePcodeFactory
- Parameters:
vn
- is the given Varnodeval
- is true if the Varnode should be marked volatile
-
setMergeGroup
Description copied from interface:PcodeFactory
Associate a specific merge group with the given Varnode- Specified by:
setMergeGroup
in interfacePcodeFactory
- Parameters:
vn
- is the given Varnodeval
- is the merge group
-
getOpRef
Description copied from interface:PcodeFactory
Get a PcodeOp given a reference id. The reference id corresponds to the op's SequenceNumber.getTime() field. Return null if no op matching the id has been registered via newOp().- Specified by:
getOpRef
in interfacePcodeFactory
- Parameters:
id
- is the reference id- Returns:
- the matching PcodeOp or null
-
insertBefore
-
insertAfter
-
setOpcode
-
setOutput
-
unSetOutput
-
setInput
-
unSetInput
-
unInsert
-
delete
-
unlink
-
newOp
Description copied from interface:PcodeFactory
Create a new PcodeOp given its opcode, sequence number, and input and output Varnodes- Specified by:
newOp
in interfacePcodeFactory
- Parameters:
sq
- is the sequence numberopc
- is the opcodeinputs
- is the array of input Varnodes, which may be emptyoutput
- is the output Varnode, which may be null- Returns:
- the new PcodeOp
-
decode
- Throws:
DecoderException
-