Package ghidra.program.model.pcode
Class PcodeSyntaxTree
- java.lang.Object
-
- ghidra.program.model.pcode.PcodeSyntaxTree
-
- All Implemented Interfaces:
PcodeFactory
- Direct Known Subclasses:
HighFunction
,HighParamID
public class PcodeSyntaxTree extends java.lang.Object implements PcodeFactory
Varnodes and PcodeOps in a coherent graph structure
-
-
Constructor Summary
Constructors Constructor Description PcodeSyntaxTree(AddressFactory afact, PcodeDataTypeManager dtmanage)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description VariableStorage
buildStorage(Varnode vn)
void
clear()
Varnode
createFromStorage(Address addr, VariableStorage storage, int logicalSize)
void
delete(PcodeOp op)
Varnode
findInputVarnode(int sz, Address addr)
return Varnode of given size and starting Address, which is also an inputVarnode
findVarnode(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 AddressVarnode
findVarnode(int sz, Address addr, SequenceNumber sq)
return Varnode of given size and starting Address defined by a PcodeOp with a given SequenceNumberAddressFactory
getAddressFactory()
java.util.ArrayList<PcodeBlockBasic>
getBasicBlocks()
PcodeDataTypeManager
getDataTypeManager()
int
getNumVarnodes()
PcodeOp
getOpRef(int id)
PcodeOp
getPcodeOp(SequenceNumber sq)
java.util.Iterator<PcodeOpAST>
getPcodeOps()
return all PcodeOps (alive or dead) ordered by SequenceNumberjava.util.Iterator<PcodeOpAST>
getPcodeOps(Address addr)
return all PcodeOps associated with a particular instruction AddressVarnode
getRef(int id)
HighSymbol
getSymbol(int symbolId)
java.util.Iterator<VarnodeAST>
getVarnodes(int sz, Address addr)
return all Varnodes of a given size that start at a given Addressjava.util.Iterator<VarnodeAST>
getVarnodes(Address addr)
return all Varnodes that start at a given Addressjava.util.Iterator<VarnodeAST>
getVarnodes(AddressSpace spc)
return Iterator to all Varnodes in the indicated AddressSpaceVarnodeBank
getVbank()
Deprecated.void
insertAfter(PcodeOp newop, PcodeOp prev)
void
insertBefore(PcodeOp newop, PcodeOp follow)
java.util.Iterator<VarnodeAST>
locRange()
Returns an iterator for all Varnodes in the tree ordered by AddressPcodeOp
newOp(SequenceNumber sq, int opc, java.util.ArrayList<Varnode> inputs, Varnode output)
Varnode
newVarnode(int sz, Address addr)
Create a new Varnode with the given size an locationVarnode
newVarnode(int sz, Address addr, int id)
void
readXML(XmlPullParser parser)
VariableStorage
readXMLVarnodePieces(XmlElement el, Address addr)
Read an XML join address with "piece" attributesvoid
setAddrTied(Varnode vn, boolean val)
void
setDataType(Varnode vn, DataType type)
void
setInput(PcodeOp op, Varnode vn, int slot)
Varnode
setInput(Varnode vn, boolean val)
void
setMergeGroup(Varnode vn, short val)
void
setOpcode(PcodeOp op, int opc)
void
setOutput(PcodeOp op, Varnode vn)
void
setPersistant(Varnode vn, boolean val)
void
setUnaffected(Varnode vn, boolean val)
void
unInsert(PcodeOp op)
void
unlink(PcodeOpAST op)
void
unSetInput(PcodeOp op, int slot)
void
unSetOutput(PcodeOp op)
-
-
-
Constructor Detail
-
PcodeSyntaxTree
public PcodeSyntaxTree(AddressFactory afact, PcodeDataTypeManager dtmanage)
-
-
Method Detail
-
clear
public void clear()
-
readXMLVarnodePieces
public VariableStorage readXMLVarnodePieces(XmlElement el, Address addr) throws PcodeXMLException, InvalidInputException
Read an XML join address with "piece" attributes- Specified by:
readXMLVarnodePieces
in interfacePcodeFactory
- Parameters:
el
- SAX parse tree elementaddr
- join address associated with pieces- Returns:
- the VariableStorage associated with xml
- Throws:
PcodeXMLException
InvalidInputException
-
buildStorage
public VariableStorage buildStorage(Varnode vn) throws InvalidInputException
- Specified by:
buildStorage
in interfacePcodeFactory
- Throws:
InvalidInputException
-
locRange
public java.util.Iterator<VarnodeAST> locRange()
Returns an iterator for all Varnodes in the tree ordered by Address
-
getVarnodes
public java.util.Iterator<VarnodeAST> getVarnodes(AddressSpace spc)
return Iterator to all Varnodes in the indicated AddressSpace- Parameters:
spc
- -- AddressSpace to restrict Iterator to- Returns:
- -- Iterator to Varnodes
-
getVarnodes
public java.util.Iterator<VarnodeAST> getVarnodes(Address addr)
return all Varnodes that start at a given Address- Parameters:
addr
- -- Address of Varnodes- Returns:
- -- Iterator to Varnodes
-
getVarnodes
public java.util.Iterator<VarnodeAST> getVarnodes(int sz, Address addr)
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
public Varnode findVarnode(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 Address- Parameters:
sz
- -- size of Varnodeaddr
- -- starting Address of Varnodepc
- -- Address of instruction writing to Varnode- Returns:
- -- the Varnode
-
findVarnode
public Varnode findVarnode(int sz, Address addr, SequenceNumber sq)
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
public Varnode findInputVarnode(int sz, Address addr)
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
public java.util.Iterator<PcodeOpAST> getPcodeOps()
return all PcodeOps (alive or dead) ordered by SequenceNumber- Returns:
- -- Iterator to PcodeOps
-
getPcodeOps
public java.util.Iterator<PcodeOpAST> getPcodeOps(Address addr)
return all PcodeOps associated with a particular instruction Address- Parameters:
addr
- -- Address of instruction generating PcodeOps- Returns:
- -- Iterator to PcodeOps
-
getPcodeOp
public PcodeOp getPcodeOp(SequenceNumber sq)
-
getVbank
@Deprecated public VarnodeBank getVbank()
Deprecated.- Returns:
- the varnode bank for this syntax tree
-
getBasicBlocks
public java.util.ArrayList<PcodeBlockBasic> getBasicBlocks()
-
getAddressFactory
public AddressFactory getAddressFactory()
- Specified by:
getAddressFactory
in interfacePcodeFactory
- Returns:
- Address factory
-
getDataTypeManager
public PcodeDataTypeManager getDataTypeManager()
- Specified by:
getDataTypeManager
in interfacePcodeFactory
- Returns:
- pcode data type manager used to convert strings to Ghidra data types
-
newVarnode
public Varnode newVarnode(int sz, Address addr)
Description copied from interface:PcodeFactory
Create a new Varnode with the given size an location- Specified by:
newVarnode
in interfacePcodeFactory
- Parameters:
sz
- size of varnodeaddr
- location of varnode- Returns:
- a new varnode
-
newVarnode
public Varnode newVarnode(int sz, Address addr, int id)
- Specified by:
newVarnode
in interfacePcodeFactory
-
createFromStorage
public Varnode createFromStorage(Address addr, VariableStorage storage, int logicalSize)
- Specified by:
createFromStorage
in interfacePcodeFactory
-
setInput
public Varnode setInput(Varnode vn, boolean val)
- Specified by:
setInput
in interfacePcodeFactory
-
getRef
public Varnode getRef(int id)
- Specified by:
getRef
in interfacePcodeFactory
-
getSymbol
public HighSymbol getSymbol(int symbolId)
- Specified by:
getSymbol
in interfacePcodeFactory
-
setDataType
public void setDataType(Varnode vn, DataType type)
- Specified by:
setDataType
in interfacePcodeFactory
-
setAddrTied
public void setAddrTied(Varnode vn, boolean val)
- Specified by:
setAddrTied
in interfacePcodeFactory
-
setPersistant
public void setPersistant(Varnode vn, boolean val)
- Specified by:
setPersistant
in interfacePcodeFactory
-
setUnaffected
public void setUnaffected(Varnode vn, boolean val)
- Specified by:
setUnaffected
in interfacePcodeFactory
-
setMergeGroup
public void setMergeGroup(Varnode vn, short val)
- Specified by:
setMergeGroup
in interfacePcodeFactory
-
getOpRef
public PcodeOp getOpRef(int id)
- Specified by:
getOpRef
in interfacePcodeFactory
-
setOpcode
public void setOpcode(PcodeOp op, int opc)
-
unSetOutput
public void unSetOutput(PcodeOp op)
-
unSetInput
public void unSetInput(PcodeOp op, int slot)
-
unInsert
public void unInsert(PcodeOp op)
-
delete
public void delete(PcodeOp op)
-
unlink
public void unlink(PcodeOpAST op)
-
newOp
public PcodeOp newOp(SequenceNumber sq, int opc, java.util.ArrayList<Varnode> inputs, Varnode output) throws UnknownInstructionException
- Specified by:
newOp
in interfacePcodeFactory
- Throws:
UnknownInstructionException
-
readXML
public void readXML(XmlPullParser parser) throws PcodeXMLException
- Throws:
PcodeXMLException
-
-