Package ghidra.app.cmd.function

# Class CallDepthChangeInfo

java.lang.Object
ghidra.app.cmd.function.CallDepthChangeInfo

public class CallDepthChangeInfo extends Object
Given a function in a program or the start of a function, record information about the change to a stack pointer from a subroutine call. The routine getCallChange() can be called with the address of a call instruction. If the stack could be tracked, the call instruction will return the change in the stack pointer that would result from a call to the function. The computation is based on a set of equations that are generated and solved. Each equation represents the stack change for a given basic flow block or call instruction within the function.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CallDepthChangeInfo(Function func)`
  Construct a new CallDepthChangeInfo object.
  `CallDepthChangeInfo(Function func, boolean storeDepthAtEachInstuction)`
  Construct a new CallDepthChangeInfo object.
  `CallDepthChangeInfo(Function function, AddressSetView restrictSet, Register frameReg, TaskMonitor monitor)`
  Construct a new CallDepthChangeInfo object.
  `CallDepthChangeInfo(Function func, TaskMonitor monitor)`
  Construct a new CallDepthChangeInfo object.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getCallChange(Address addr)`
  `int`
  `getDepth(Address addr)`
  `int`
  `getInstructionStackDepthChange(Instruction instr)`
  Inspect the instruction and return how it affects the stack depth.
  `int`
  `getRegDepth(Address addr, Register reg)`
  Get the stack register depth at address.
  `String`
  `getRegValueRepresentation(Address addr, Register reg)`
  Get the stack register value as a printable string.
  `int`
  `getSPDepth(Address addr)`
  `static Integer`
  `getStackDepthChange(Program program, Address address)`
  Gets the stack depth change value that has been set at the indicated address.
  `static AddressIterator`
  `getStackDepthChanges(Program program, AddressSetView addressSet)`
  Gets an iterator indicating all the addresses that have a stack depth change value specified within a program's indicated address set.
  `int`
  `getStackOffset(Instruction cu, int opIndex)`
  `int`
  `getStackPurge()`
  `static boolean`
  `removeStackDepthChange(Program program, Address address)`
  Removes the value for the stack depth change at the indicated address.
  `static void`
  `setStackDepthChange(Program program, Address address, int stackDepthChange)`
  Sets a new value for the stack depth change at the indicated address.

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

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

- ## Constructor Details

  - ### CallDepthChangeInfo

    public CallDepthChangeInfo(Function func)
    Construct a new CallDepthChangeInfo object. Using this constructor will NOT track the stack depth at the start/end of each instruction.
    Parameters:
      `func` - function to examine

  - ### CallDepthChangeInfo

    public CallDepthChangeInfo(Function func, boolean storeDepthAtEachInstuction)
    Construct a new CallDepthChangeInfo object. Allows calls to getRegDepth() and getRegValueRepresentation()
    Parameters:
      `func` - function to examine
      `storeDepthAtEachInstuction` - true to track stack at start/end of each instruction. allowing a call to

  - ### CallDepthChangeInfo

    public CallDepthChangeInfo(Function func, TaskMonitor monitor) throws CancelledException
    Construct a new CallDepthChangeInfo object.
    Parameters:
      `func` - function to examine
      `monitor` - used to cancel the operation
    Throws:
      `CancelledException` - if the operation was canceled

  - ### CallDepthChangeInfo

    public CallDepthChangeInfo(Function function, AddressSetView restrictSet, Register frameReg, TaskMonitor monitor) throws CancelledException
    Construct a new CallDepthChangeInfo object. Using this constructor will track the stack depth at the start/end of each instruction.
    Parameters:
      `function` - function to examine
      `restrictSet` - set of addresses to restrict flow flowing to.
      `frameReg` - register that is to have it's depth(value) change tracked
      `monitor` - monitor used to cancel the operation
    Throws:
      `CancelledException` - if the operation was canceled

- ## Method Details

  - ### getCallChange

    public int getCallChange(Address addr)

  - ### getDepth

    public int getDepth(Address addr)

  - ### getInstructionStackDepthChange

    public int getInstructionStackDepthChange(Instruction instr)
    Inspect the instruction and return how it affects the stack depth. If the depth cannot be determined, then return that the stack depth change is unknown.
    Parameters:
      `instr` - instruction to analyze
    Returns:
      int change to stack depth if it can be determined, Function.UNKNOWN_STACK_DEPTH_CHANGE otherwise.

  - ### getStackDepthChange

    public static Integer getStackDepthChange(Program program, Address address)
    Gets the stack depth change value that has been set at the indicated address.
    Parameters:
      `program` - the program to be checked
      `address` - the program address
    Returns:
      the stack depth change value or null if value has not been set

  - ### setStackDepthChange

    public static void setStackDepthChange(Program program, Address address, int stackDepthChange) throws DuplicateNameException
    Sets a new value for the stack depth change at the indicated address.
    Parameters:
      `program` - the program where the value will be set
      `address` - the program address
      `stackDepthChange` - the new stack depth change value
    Throws:
      `DuplicateNameException` - if the property name for stack depth changes conflicted with another property tha has the same name.

  - ### removeStackDepthChange

    public static boolean removeStackDepthChange(Program program, Address address)
    Removes the value for the stack depth change at the indicated address.
    Parameters:
      `program` - the program where the value will be removed
      `address` - the program address
    Returns:
      true if a stack depth change existed at the indicated at the address and it was removed.

  - ### getStackDepthChanges

    public static AddressIterator getStackDepthChanges(Program program, AddressSetView addressSet)
    Gets an iterator indicating all the addresses that have a stack depth change value specified within a program's indicated address set.
    Parameters:
      `program` - the program to be checked
      `addressSet` - the set of addresses to check for a stack depth change value
    Returns:
      the address iterator indicating where stack depth change values have been set

  - ### getStackPurge

    public int getStackPurge()

  - ### getStackOffset

    public int getStackOffset(Instruction cu, int opIndex)

  - ### getSPDepth

    public int getSPDepth(Address addr)
    Parameters:
      `addr` - the address to get the stack pointer depth at.
    Returns:
      the stack pointer depth at the address.

  - ### getRegDepth

    public int getRegDepth(Address addr, Register reg)
    Get the stack register depth at address. To have a valid value, the class must be constructed to storeDepthAtEachInstuction
    Parameters:
      `addr` - the address to get the register depth at.
      `reg` - the register to get the depth of.
    Returns:
      the depth of the register at the address.

  - ### getRegValueRepresentation

    public String getRegValueRepresentation(Address addr, Register reg)
    Get the stack register value as a printable string. This can be an equation of register+value. To have a valid value, the class must be constructed to storeDepthAtEachInstuction
    Parameters:
      `addr` - the address of the register value to get the representation of.
      `reg` - the register to get the representation of.
    Returns:
      the string representation of the register value.