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 Object implements PcodeFactory
Varnodes and PcodeOps in a coherent graph structure

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PcodeSyntaxTree(AddressFactory afact, PcodeDataTypeManager dtmanage)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `VariableStorage`
  `buildStorage(Varnode vn)`
  Build a storage object for a particular Varnode
  `void`
  `clear()`
  `void`
  `decode(Decoder decoder)`
  `void`
  `delete(PcodeOp op)`
  `Varnode`
  `findInputVarnode(int sz, Address addr)`
  return Varnode of given size and starting Address, which is also an input
  `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
  `Varnode`
  `findVarnode(int sz, Address addr, SequenceNumber sq)`
  return Varnode of given size and starting Address defined by a PcodeOp with a given SequenceNumber
  `AddressFactory`
  `getAddressFactory()`
  `ArrayList<PcodeBlockBasic>`
  `getBasicBlocks()`
  `PcodeDataTypeManager`
  `getDataTypeManager()`
  `Address`
  `getJoinAddress(VariableStorage storage)`
  Get the address (in the "join" space) corresponding to the given multi-piece storage.
  `VariableStorage`
  `getJoinStorage(Varnode[] pieces)`
  Create a storage object representing a value split across multiple physical locations.
  `int`
  `getNumVarnodes()`
  `PcodeOp`
  `getOpRef(int id)`
  Get a PcodeOp given a reference id.
  `PcodeOp`
  `getPcodeOp(SequenceNumber sq)`
  `Iterator<PcodeOpAST>`
  `getPcodeOps()`
  return all PcodeOps (alive or dead) ordered by SequenceNumber
  `Iterator<PcodeOpAST>`
  `getPcodeOps(Address addr)`
  return all PcodeOps associated with a particular instruction Address
  `Varnode`
  `getRef(int id)`
  Return a Varnode given its reference id, or null if the id is not registered.
  `HighSymbol`
  `getSymbol(long symbolId)`
  Get the high symbol matching the given id that has been registered with this object
  `Iterator<VarnodeAST>`
  `getVarnodes(int sz, Address addr)`
  return all Varnodes of a given size that start at a given Address
  `Iterator<VarnodeAST>`
  `getVarnodes(Address addr)`
  return all Varnodes that start at a given Address
  `Iterator<VarnodeAST>`
  `getVarnodes(AddressSpace spc)`
  return Iterator to all Varnodes in the indicated AddressSpace
  `void`
  `insertAfter(PcodeOp newop, PcodeOp prev)`
  `void`
  `insertBefore(PcodeOp newop, PcodeOp follow)`
  `Iterator<VarnodeAST>`
  `locRange()`
  `PcodeOp`
  `newOp(SequenceNumber sq, int opc, ArrayList<Varnode> inputs, Varnode output)`
  Create a new PcodeOp given its opcode, sequence number, and input and output Varnodes
  `Varnode`
  `newVarnode(int sz, Address addr)`
  Create a new Varnode with the given size and location
  `Varnode`
  `newVarnode(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" property
  `void`
  `setDataType(Varnode vn, DataType type)`
  Attach a data-type to the given Varnode
  `void`
  `setInput(PcodeOp op, Varnode vn, int slot)`
  `Varnode`
  `setInput(Varnode vn, boolean val)`
  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 Varnode
  `void`
  `setOpcode(PcodeOp op, int opc)`
  `void`
  `setOutput(PcodeOp op, Varnode vn)`
  `void`
  `setPersistent(Varnode vn, boolean val)`
  Mark (or unmark) the given Varnode with the "persistent" property
  `void`
  `setUnaffected(Varnode vn, boolean val)`
  Mark (or unmark) the given Varnode with the "unaffected" property
  `void`
  `setVolatile(Varnode vn, boolean val)`
  Mark (or unmark) the given Varnode with the "volatile" property
  `void`
  `unInsert(PcodeOp op)`
  `void`
  `unlink(PcodeOpAST op)`
  `void`
  `unSetInput(PcodeOp op, int slot)`
  `void`
  `unSetOutput(PcodeOp op)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### PcodeSyntaxTree

    public PcodeSyntaxTree(AddressFactory afact, PcodeDataTypeManager dtmanage)

- ## Method Details

  - ### clear

    public void clear()

  - ### getJoinAddress

    public Address getJoinAddress(VariableStorage storage)
    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 interface `PcodeFactory`
    Parameters:
      `storage` - is the multi-piece storage
    Returns:
      the corresponding "join" address

  - ### getJoinStorage

    public VariableStorage getJoinStorage(Varnode[] pieces) throws InvalidInputException
    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 interface `PcodeFactory`
    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

    public VariableStorage buildStorage(Varnode vn) throws InvalidInputException
    Description copied from interface: `PcodeFactory`
    Build a storage object for a particular Varnode
    Specified by:
      `buildStorage` in interface `PcodeFactory`
    Parameters:
      `vn` - is the Varnode
    Returns:
      the storage object
    Throws:
      `InvalidInputException` - if valid storage cannot be created

  - ### locRange

    public Iterator<VarnodeAST> locRange()
    Returns:
      an iterator for all Varnodes in the tree ordered by Address

  - ### getVarnodes

    public 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 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 Iterator<VarnodeAST> getVarnodes(int sz, Address addr)
    return all Varnodes of a given size that start at a given Address
    Parameters:
      `sz` - -- Size of Varnodes
      `addr` - -- 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 Varnode
      `addr` - -- starting Address of Varnode
      `pc` - -- 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 Varnode
      `addr` - -- starting Address of Varnode
      `sq` - -- 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 Varnode
      `addr` - -- starting Address of Varnode
    Returns:
      -- the Varnode

  - ### getNumVarnodes

    public int getNumVarnodes()

  - ### getPcodeOps

    public Iterator<PcodeOpAST> getPcodeOps()
    return all PcodeOps (alive or dead) ordered by SequenceNumber
    Returns:
      -- Iterator to PcodeOps

  - ### getPcodeOps

    public 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)

  - ### getBasicBlocks

    public ArrayList<PcodeBlockBasic> getBasicBlocks()

  - ### getAddressFactory

    public AddressFactory getAddressFactory()
    Specified by:
      `getAddressFactory` in interface `PcodeFactory`
    Returns:
      Address factory

  - ### getDataTypeManager

    public PcodeDataTypeManager getDataTypeManager()
    Specified by:
      `getDataTypeManager` in interface `PcodeFactory`
    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 and location
    Specified by:
      `newVarnode` in interface `PcodeFactory`
    Parameters:
      `sz` - size of the Varnode
      `addr` - location of the Varnode
    Returns:
      a new varnode

  - ### newVarnode

    public Varnode newVarnode(int sz, Address addr, int id)
    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 interface `PcodeFactory`
    Parameters:
      `sz` - size of the Varnode
      `addr` - location of the Varnode
      `id` - is the specific reference id
    Returns:
      the new Varnode

  - ### setInput

    public Varnode setInput(Varnode vn, boolean val)
    Description copied from interface: `PcodeFactory`
    Mark (or unmark) the given Varnode as an input (to its function)
    Specified by:
      `setInput` in interface `PcodeFactory`
    Parameters:
      `vn` - is the given Varnode
      `val` - is true if the Varnode should be marked
    Returns:
      the altered Varnode, which may not be the same object passed in

  - ### getRef

    public Varnode getRef(int id)
    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 interface `PcodeFactory`
    Parameters:
      `id` - is the reference id
    Returns:
      the matching Varnode or null

  - ### getSymbol

    public HighSymbol getSymbol(long symbolId)
    Description copied from interface: `PcodeFactory`
    Get the high symbol matching the given id that has been registered with this object
    Specified by:
      `getSymbol` in interface `PcodeFactory`
    Parameters:
      `symbolId` - is the given id
    Returns:
      the matching HighSymbol or null

  - ### setDataType

    public void setDataType(Varnode vn, DataType type)
    Description copied from interface: `PcodeFactory`
    Attach a data-type to the given Varnode
    Specified by:
      `setDataType` in interface `PcodeFactory`
    Parameters:
      `vn` - is the given Varnode
      `type` - is the data-type

  - ### setAddrTied

    public void setAddrTied(Varnode vn, boolean val)
    Description copied from interface: `PcodeFactory`
    Mark (or unmark) the given Varnode with the "address tied" property
    Specified by:
      `setAddrTied` in interface `PcodeFactory`
    Parameters:
      `vn` - is the given Varnode
      `val` - is true if the Varnode should be marked

  - ### setPersistent

    public void setPersistent(Varnode vn, boolean val)
    Description copied from interface: `PcodeFactory`
    Mark (or unmark) the given Varnode with the "persistent" property
    Specified by:
      `setPersistent` in interface `PcodeFactory`
    Parameters:
      `vn` - is the given Varnode
      `val` - is true if the Varnode should be marked

  - ### setUnaffected

    public void setUnaffected(Varnode vn, boolean val)
    Description copied from interface: `PcodeFactory`
    Mark (or unmark) the given Varnode with the "unaffected" property
    Specified by:
      `setUnaffected` in interface `PcodeFactory`
    Parameters:
      `vn` - is the given Varnode
      `val` - is true if the Varnode should be marked

  - ### setVolatile

    public void setVolatile(Varnode vn, boolean val)
    Description copied from interface: `PcodeFactory`
    Mark (or unmark) the given Varnode with the "volatile" property
    Specified by:
      `setVolatile` in interface `PcodeFactory`
    Parameters:
      `vn` - is the given Varnode
      `val` - is true if the Varnode should be marked volatile

  - ### setMergeGroup

    public void setMergeGroup(Varnode vn, short val)
    Description copied from interface: `PcodeFactory`
    Associate a specific merge group with the given Varnode
    Specified by:
      `setMergeGroup` in interface `PcodeFactory`
    Parameters:
      `vn` - is the given Varnode
      `val` - is the merge group

  - ### getOpRef

    public PcodeOp getOpRef(int id)
    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 interface `PcodeFactory`
    Parameters:
      `id` - is the reference id
    Returns:
      the matching PcodeOp or null

  - ### insertBefore

    public void insertBefore(PcodeOp newop, PcodeOp follow)

  - ### insertAfter

    public void insertAfter(PcodeOp newop, PcodeOp prev)

  - ### setOpcode

    public void setOpcode(PcodeOp op, int opc)

  - ### setOutput

    public void setOutput(PcodeOp op, Varnode vn)

  - ### unSetOutput

    public void unSetOutput(PcodeOp op)

  - ### setInput

    public void setInput(PcodeOp op, Varnode vn, int slot)

  - ### 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, ArrayList<Varnode> inputs, Varnode output)
    Description copied from interface: `PcodeFactory`
    Create a new PcodeOp given its opcode, sequence number, and input and output Varnodes
    Specified by:
      `newOp` in interface `PcodeFactory`
    Parameters:
      `sq` - is the sequence number
      `opc` - is the opcode
      `inputs` - is the array of input Varnodes, which may be empty
      `output` - is the output Varnode, which may be null
    Returns:
      the new PcodeOp

  - ### decode

    public void decode(Decoder decoder) throws DecoderException
    Throws:
      `DecoderException`