Package ghidra.app.cmd.function
Class CallDepthChangeInfo
- java.lang.Object
-
- ghidra.app.cmd.function.CallDepthChangeInfo
-
public class CallDepthChangeInfo extends java.lang.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 function, AddressSetView restrictSet, Register frameReg, TaskMonitor monitor)
Construct a new CallDepthChangeInfo object.CallDepthChangeInfo(Function func, TaskMonitor monitor)
Construct a new CallDepthChangeInfo object.CallDepthChangeInfo(Program program, Address addr, AddressSetView restrictSet, Register frameReg, TaskMonitor monitor)
Construct a new CallDepthChangeInfo object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods 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)
java.lang.String
getRegValueRepresentation(Address addr, Register reg)
int
getSPDepth(Address addr)
static java.lang.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.int
smoothDepth(Program program1, Function func, TaskMonitor monitor)
Do a better job of tracking the stack by attempting to follow the data flow of the stack pointer as it moves in and out of other variables.
-
-
-
Constructor Detail
-
CallDepthChangeInfo
public CallDepthChangeInfo(Function func)
Construct a new CallDepthChangeInfo object.- Parameters:
func
- function to examine
-
CallDepthChangeInfo
public CallDepthChangeInfo(Function func, TaskMonitor monitor) throws CancelledException
Construct a new CallDepthChangeInfo object.- Parameters:
func
- function to examinemonitor
- 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.- Parameters:
function
- function to examinerestrictSet
- set of addresses to restrict flow flowing to.frameReg
- register that is to have it's depth(value) change trackedmonitor
- monitor used to cancel the operation- Throws:
CancelledException
- if the operation was canceled
-
CallDepthChangeInfo
public CallDepthChangeInfo(Program program, Address addr, AddressSetView restrictSet, Register frameReg, TaskMonitor monitor) throws CancelledException
Construct a new CallDepthChangeInfo object.- Parameters:
program
- program containing the function to examimeaddr
- address within the function to examinerestrictSet
- set of addresses to restrict flow flowing to.frameReg
- register that is to have it's depth(value) change trackedmonitor
- monitor used to cancel the operation- Throws:
CancelledException
- if the operation was canceled
-
-
Method Detail
-
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 java.lang.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 checkedaddress
- 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 setaddress
- the program addressstackDepthChange
- 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 removedaddress
- 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 checkedaddressSet
- 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
-
smoothDepth
public int smoothDepth(Program program1, Function func, TaskMonitor monitor)
Do a better job of tracking the stack by attempting to follow the data flow of the stack pointer as it moves in and out of other variables.- Parameters:
program1
- - program containing the function to analyzefunc
- - function to analyze stack pointer references
-
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)
- 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.
-
-