Package ghidra.program.model
Class FunctionManagerTestDouble
- java.lang.Object
-
- ghidra.program.model.FunctionManagerTestDouble
-
- All Implemented Interfaces:
FunctionManager
public class FunctionManagerTestDouble extends java.lang.Object implements FunctionManager
-
-
Constructor Summary
Constructors Constructor Description FunctionManagerTestDouble()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Function
createFunction(java.lang.String name, Address entryPoint, AddressSetView body, SourceType source)
Create a function with the given body at entry point within the global namespace.Function
createFunction(java.lang.String name, Namespace nameSpace, Address entryPoint, AddressSetView body, SourceType source)
Create a function with the given body at entry point.Function
createThunkFunction(java.lang.String name, Namespace nameSpace, Address entryPoint, AddressSetView body, Function thunkedFunction, SourceType source)
Create a thunk function with the given body at entry point.void
deleteAddressRange(Address startAddr, Address endAddr, TaskMonitor monitor)
PrototypeModel
getCallingConvention(java.lang.String name)
Gets the prototype model of the calling convention with the specified name in this program.java.util.List<java.lang.String>
getCallingConventionNames()
Gets the names associated with each of the current calling conventions associated with this program.PrototypeModel[]
getCallingConventions()
Gets all the calling convention prototype models in this program that have names.PrototypeModel
getDefaultCallingConvention()
Gets the default calling convention's prototype model in this program.FunctionIterator
getExternalFunctions()
Get an iterator over all external functions.Function
getFunction(long key)
Get a Function object by its keyFunction
getFunctionAt(Address entryPoint)
Get the function at entryPoint.Function
getFunctionContaining(Address addr)
Get a function containing an address.int
getFunctionCount()
Returns the total number of functions in the program including external functions.FunctionIterator
getFunctions(boolean forward)
Returns an iterator over all non-external functions in address (entry point) order.FunctionIterator
getFunctions(Address start, boolean foward)
Get an iterator over non-external functions starting at an address and ordered by entry address.FunctionIterator
getFunctions(AddressSetView asv, boolean forward)
Get an iterator over functions with entry points in the specified address set.FunctionIterator
getFunctionsNoStubs(boolean forward)
Returns an iterator over all REAL functions in address (entry point) order (real functions have instructions, and aren't stubs).FunctionIterator
getFunctionsNoStubs(Address start, boolean foward)
Get an iterator over REAL functions starting at an address and ordered by entry address (real functions have instructions, and aren't stubs).FunctionIterator
getFunctionsNoStubs(AddressSetView asv, boolean forward)
Get an iterator over REAL functions with entry points in the specified address set (real functions have instructions, and aren't stubs).java.util.Iterator<Function>
getFunctionsOverlapping(AddressSetView set)
Return an iterator over functions that overlap the given address set.ProgramDB
getProgram()
Function
getReferencedFunction(Address address)
Get the function which resides at the specified address or is referenced from the specified address.Variable
getReferencedVariable(Address instrAddr, Address storageAddr, int size, boolean isRead)
Attempts to determine which if any of the local functions variables are referenced by the specified reference.void
invalidateCache(boolean all)
boolean
isInFunction(Address addr)
Check if this address contains a function.void
moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor)
void
programReady(int openMode, int currentRevision, TaskMonitor monitor)
boolean
removeFunction(Address entryPoint)
Remove a function defined at entryPoint.void
setProgram(ProgramDB program)
-
-
-
Method Detail
-
getProgram
public ProgramDB getProgram()
- Specified by:
getProgram
in interfaceFunctionManager
-
getCallingConventionNames
public java.util.List<java.lang.String> getCallingConventionNames()
Description copied from interface:FunctionManager
Gets the names associated with each of the current calling conventions associated with this program. Within the exception of "unknown", all of these calling convention names should have a PrototypeModel.- Specified by:
getCallingConventionNames
in interfaceFunctionManager
- Returns:
- the calling convention names.
-
getDefaultCallingConvention
public PrototypeModel getDefaultCallingConvention()
Description copied from interface:FunctionManager
Gets the default calling convention's prototype model in this program.- Specified by:
getDefaultCallingConvention
in interfaceFunctionManager
- Returns:
- the default calling convention prototype model or null.
-
getCallingConvention
public PrototypeModel getCallingConvention(java.lang.String name)
Description copied from interface:FunctionManager
Gets the prototype model of the calling convention with the specified name in this program.- Specified by:
getCallingConvention
in interfaceFunctionManager
- Returns:
- the named function calling convention prototype model or null.
-
getCallingConventions
public PrototypeModel[] getCallingConventions()
Description copied from interface:FunctionManager
Gets all the calling convention prototype models in this program that have names.- Specified by:
getCallingConventions
in interfaceFunctionManager
- Returns:
- the function calling convention prototype models.
-
createFunction
public Function createFunction(java.lang.String name, Address entryPoint, AddressSetView body, SourceType source) throws InvalidInputException, OverlappingFunctionException
Description copied from interface:FunctionManager
Create a function with the given body at entry point within the global namespace.- Specified by:
createFunction
in interfaceFunctionManager
- Parameters:
name
- the name of the new function or null for default nameentryPoint
- entry point of functionbody
- addresses contained in the function bodysource
- the source of this function- Returns:
- new function or null if one or more functions overlap the specified body address set.
- Throws:
InvalidInputException
- if the name has invalid charactersOverlappingFunctionException
- if the address set of the body overlaps an existing function
-
createFunction
public Function createFunction(java.lang.String name, Namespace nameSpace, Address entryPoint, AddressSetView body, SourceType source) throws InvalidInputException, OverlappingFunctionException
Description copied from interface:FunctionManager
Create a function with the given body at entry point.- Specified by:
createFunction
in interfaceFunctionManager
- Parameters:
name
- the name of the new function or null for default namenameSpace
- the nameSpace in which to create the functionentryPoint
- entry point of functionbody
- addresses contained in the function bodysource
- the source of this function- Returns:
- new function or null if one or more functions overlap the specified body address set.
- Throws:
InvalidInputException
- if the name has invalid charactersOverlappingFunctionException
- if the address set of the body overlaps an existing function
-
createThunkFunction
public Function createThunkFunction(java.lang.String name, Namespace nameSpace, Address entryPoint, AddressSetView body, Function thunkedFunction, SourceType source) throws DuplicateNameException, OverlappingFunctionException
Description copied from interface:FunctionManager
Create a thunk function with the given body at entry point.- Specified by:
createThunkFunction
in interfaceFunctionManager
- Parameters:
name
- the name of the new function or null for default namenameSpace
- the nameSpace in which to create the functionentryPoint
- entry point of functionbody
- addresses contained in the function bodythunkedFunction
- referenced function (required is creating a thunk function)source
- the source of this function- Returns:
- new function or null if one or more functions overlap the specified body address set.
- Throws:
DuplicateNameException
- if a function with the same thunk name already existsOverlappingFunctionException
- if the address set of the body overlaps an existing function
-
getFunctionCount
public int getFunctionCount()
Description copied from interface:FunctionManager
Returns the total number of functions in the program including external functions.- Specified by:
getFunctionCount
in interfaceFunctionManager
-
removeFunction
public boolean removeFunction(Address entryPoint)
Description copied from interface:FunctionManager
Remove a function defined at entryPoint.- Specified by:
removeFunction
in interfaceFunctionManager
-
getFunctionAt
public Function getFunctionAt(Address entryPoint)
Description copied from interface:FunctionManager
Get the function at entryPoint.- Specified by:
getFunctionAt
in interfaceFunctionManager
- Returns:
- null if there is no function at entryPoint.
-
getFunctionContaining
public Function getFunctionContaining(Address addr)
Description copied from interface:FunctionManager
Get a function containing an address.- Specified by:
getFunctionContaining
in interfaceFunctionManager
- Parameters:
addr
- address within the function- Returns:
- function containing this address, null otherwise
-
getFunctions
public FunctionIterator getFunctions(boolean forward)
Description copied from interface:FunctionManager
Returns an iterator over all non-external functions in address (entry point) order.- Specified by:
getFunctions
in interfaceFunctionManager
- Parameters:
forward
- true means to iterate in ascending address order
-
getFunctions
public FunctionIterator getFunctions(Address start, boolean foward)
Description copied from interface:FunctionManager
Get an iterator over non-external functions starting at an address and ordered by entry address.- Specified by:
getFunctions
in interfaceFunctionManager
- Parameters:
start
- starting address- Returns:
- an iterator over functions.
-
getFunctions
public FunctionIterator getFunctions(AddressSetView asv, boolean forward)
Description copied from interface:FunctionManager
Get an iterator over functions with entry points in the specified address set. Function are ordered based upon entry address.- Specified by:
getFunctions
in interfaceFunctionManager
- Parameters:
asv
- address set to iterate overforward
- true means to iterate in ascending address order- Returns:
- an iterator over functions.
-
getFunctionsNoStubs
public FunctionIterator getFunctionsNoStubs(boolean forward)
Description copied from interface:FunctionManager
Returns an iterator over all REAL functions in address (entry point) order (real functions have instructions, and aren't stubs).- Specified by:
getFunctionsNoStubs
in interfaceFunctionManager
- Parameters:
forward
- true means to iterate in ascending address order
-
getFunctionsNoStubs
public FunctionIterator getFunctionsNoStubs(Address start, boolean foward)
Description copied from interface:FunctionManager
Get an iterator over REAL functions starting at an address and ordered by entry address (real functions have instructions, and aren't stubs).- Specified by:
getFunctionsNoStubs
in interfaceFunctionManager
- Parameters:
start
- starting address- Returns:
- an iterator over functions.
-
getFunctionsNoStubs
public FunctionIterator getFunctionsNoStubs(AddressSetView asv, boolean forward)
Description copied from interface:FunctionManager
Get an iterator over REAL functions with entry points in the specified address set (real functions have instructions, and aren't stubs). Functions are ordered based upon entry address.- Specified by:
getFunctionsNoStubs
in interfaceFunctionManager
- Parameters:
asv
- address set to iterate overforward
- true means to iterate in ascending address order- Returns:
- an iterator over functions.
-
getExternalFunctions
public FunctionIterator getExternalFunctions()
Description copied from interface:FunctionManager
Get an iterator over all external functions. Functions returned have no particular order.- Specified by:
getExternalFunctions
in interfaceFunctionManager
- Returns:
- an iterator over external functions
-
isInFunction
public boolean isInFunction(Address addr)
Description copied from interface:FunctionManager
Check if this address contains a function.- Specified by:
isInFunction
in interfaceFunctionManager
- Parameters:
addr
- address to check- Returns:
- true if this address is contained in a function.
-
moveAddressRange
public void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) throws CancelledException
- Specified by:
moveAddressRange
in interfaceFunctionManager
- Throws:
CancelledException
- See Also:
ManagerDB.moveAddressRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address, long, ghidra.util.task.TaskMonitor)
-
deleteAddressRange
public void deleteAddressRange(Address startAddr, Address endAddr, TaskMonitor monitor) throws CancelledException
- Specified by:
deleteAddressRange
in interfaceFunctionManager
- Throws:
CancelledException
- See Also:
ManagerDB.deleteAddressRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address, ghidra.util.task.TaskMonitor)
-
setProgram
public void setProgram(ProgramDB program)
- Specified by:
setProgram
in interfaceFunctionManager
- See Also:
ManagerDB.setProgram(ghidra.program.database.ProgramDB)
-
programReady
public void programReady(int openMode, int currentRevision, TaskMonitor monitor) throws java.io.IOException, CancelledException
- Specified by:
programReady
in interfaceFunctionManager
currentRevision
- TODO- Throws:
java.io.IOException
CancelledException
- See Also:
ManagerDB.programReady(int, int, ghidra.util.task.TaskMonitor)
-
invalidateCache
public void invalidateCache(boolean all)
- Specified by:
invalidateCache
in interfaceFunctionManager
-
getFunctionsOverlapping
public java.util.Iterator<Function> getFunctionsOverlapping(AddressSetView set)
Description copied from interface:FunctionManager
Return an iterator over functions that overlap the given address set.- Specified by:
getFunctionsOverlapping
in interfaceFunctionManager
- Parameters:
set
- address set of interest- Returns:
- iterator over Functions
-
getReferencedVariable
public Variable getReferencedVariable(Address instrAddr, Address storageAddr, int size, boolean isRead)
Description copied from interface:FunctionManager
Attempts to determine which if any of the local functions variables are referenced by the specified reference. In utilizing the firstUseOffset scoping model, negative offsets (relative to the functions entry) are shifted beyond the maximum positive offset within the function. While this does not account for the actual instruction flow, it is hopefully accurate enough for most situations.- Specified by:
getReferencedVariable
in interfaceFunctionManager
size
- varnode size in bytes (1 is assumed if value <= 0)- Returns:
- referenced variable or null if one not found
-
getFunction
public Function getFunction(long key)
Description copied from interface:FunctionManager
Get a Function object by its key- Specified by:
getFunction
in interfaceFunctionManager
- Parameters:
key
- function symbol key- Returns:
- function object or null if not found
-
getReferencedFunction
public Function getReferencedFunction(Address address)
Description copied from interface:FunctionManager
Get the function which resides at the specified address or is referenced from the specified address.- Specified by:
getReferencedFunction
in interfaceFunctionManager
- Parameters:
address
- function address or address of pointer to a function.- Returns:
- referenced function or null
-
-