Package ghidra.program.model.lang
Class PrototypeModel
- java.lang.Object
-
- ghidra.program.model.lang.PrototypeModel
-
- Direct Known Subclasses:
PrototypeModelError
,PrototypeModelMerged
public class PrototypeModel extends java.lang.Object
A function calling convention model. Formal specification of how a compiler passes arguments between functions.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
isExtension
protected java.lang.String
name
static int
UNKNOWN_EXTRAPOP
-
Constructor Summary
Constructors Constructor Description PrototypeModel()
PrototypeModel(java.lang.String name, PrototypeModel model)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
VariableStorage
getArgLocation(int argIndex, Parameter[] params, DataType dataType, Program program)
Get the preferred parameter location for a specified index, which will be added/inserted within the set of existing function params.int
getExtrapop()
GenericCallingConvention
getGenericCallingConvention()
protected java.lang.String
getInjectName()
InputListType
getInputListType()
Varnode[]
getKilledByCallList()
Varnode[]
getLikelyTrash()
java.lang.String
getName()
VariableStorage
getNextArgLocation(Parameter[] params, DataType dataType, Program program)
Get the preferred parameter location for a new parameter which will appended to the end of an existing set of params.VariableStorage[]
getPotentialInputRegisterStorage(Program prog)
Varnode[]
getReturnAddress()
VariableStorage
getReturnLocation(DataType dataType, Program program)
Deprecated.Get the preferred return location given the specified dataType.int
getStackParameterAlignment()
java.lang.Long
getStackParameterOffset()
int
getStackshift()
VariableStorage[]
getStorageLocations(Program program, DataType[] dataTypes, boolean addAutoParams)
Compute the variable storage for a given function and set of return/parameter datatypes defined by an array of data types.Varnode[]
getUnaffectedList()
int
hashCode()
boolean
hasInjection()
boolean
hasThisPointer()
boolean
isConstructor()
boolean
isErrorPlaceholder()
If a PrototypeModel fails to parse (from XML) a substitute model may be provided, in which case this method returns true.boolean
isMerged()
boolean
isProgramExtension()
boolean
possibleInputParamWithSlot(Address loc, int size, ParamList.WithSlotRec res)
boolean
possibleOutputParamWithSlot(Address loc, int size, ParamList.WithSlotRec res)
void
restoreXml(XmlPullParser parser, CompilerSpec cspec)
void
saveXml(java.lang.StringBuilder buffer, PcodeInjectLibrary injectLibrary)
java.lang.String
toString()
-
-
-
Field Detail
-
UNKNOWN_EXTRAPOP
public static final int UNKNOWN_EXTRAPOP
- See Also:
- Constant Field Values
-
name
protected java.lang.String name
-
isExtension
protected boolean isExtension
-
-
Constructor Detail
-
PrototypeModel
public PrototypeModel(java.lang.String name, PrototypeModel model)
-
PrototypeModel
public PrototypeModel()
-
-
Method Detail
-
getGenericCallingConvention
public GenericCallingConvention getGenericCallingConvention()
-
getUnaffectedList
public Varnode[] getUnaffectedList()
- Returns:
- list of registers unaffected by called functions
-
getKilledByCallList
public Varnode[] getKilledByCallList()
- Returns:
- list of registers definitely affected by called functions
-
getLikelyTrash
public Varnode[] getLikelyTrash()
- Returns:
- list of registers whose input value is likely meaningless
-
getReturnAddress
public Varnode[] getReturnAddress()
- Returns:
- list of registers/memory used to store the return address
-
isMerged
public boolean isMerged()
-
isProgramExtension
public boolean isProgramExtension()
- Returns:
- true if this model is a Program specific extension to the CompilerSpec
-
getName
public java.lang.String getName()
-
getExtrapop
public int getExtrapop()
-
getStackshift
public int getStackshift()
-
hasThisPointer
public boolean hasThisPointer()
-
isConstructor
public boolean isConstructor()
-
getInputListType
public InputListType getInputListType()
-
hasInjection
public boolean hasInjection()
-
getReturnLocation
@Deprecated public VariableStorage getReturnLocation(DataType dataType, Program program)
Deprecated.Get the preferred return location given the specified dataType. In truth, there is no one location. The routines that use this method tend to want the default storage location for integer or pointer return values.- Parameters:
dataType
- first parameter dataType or null for an undefined type.program
- is the Program- Returns:
- return location or
VariableStorage.UNASSIGNED_STORAGE
if unable to determine suitable location
-
getNextArgLocation
public VariableStorage getNextArgLocation(Parameter[] params, DataType dataType, Program program)
Get the preferred parameter location for a new parameter which will appended to the end of an existing set of params. If existing parameters use custom storage, this method should not be used.- Parameters:
params
- existing set parameters to which the next parameter will be appended. (may be null)dataType
- dataType associated with next parameter location or null for a default undefined type.program
- is the Program- Returns:
- next parameter location or
VariableStorage.UNASSIGNED_STORAGE
if unable to determine suitable location
-
getArgLocation
public VariableStorage getArgLocation(int argIndex, Parameter[] params, DataType dataType, Program program)
Get the preferred parameter location for a specified index, which will be added/inserted within the set of existing function params. If existing parameters use custom storage, this method should not be used.- Parameters:
argIndex
- is the indexparams
- existing set parameters to which the parameter specified by argIndex will be added/inserted be appended (may be null).dataType
- dataType associated with next parameter location or null for a default undefined type.program
- is the Program- Returns:
- parameter location or
VariableStorage.UNASSIGNED_STORAGE
if unable to determine suitable location
-
getStorageLocations
public VariableStorage[] getStorageLocations(Program program, DataType[] dataTypes, boolean addAutoParams)
Compute the variable storage for a given function and set of return/parameter datatypes defined by an array of data types.- Parameters:
program
- is the ProgramdataTypes
- return/parameter datatypes (first element is always the return datatype, i.e., minimum array length is 1)addAutoParams
- TODO- Returns:
- dynamic storage locations orders by ordinal where first element corresponds to return storage. The returned array may also include additional auto-parameter storage locations.
-
isErrorPlaceholder
public boolean isErrorPlaceholder()
If a PrototypeModel fails to parse (from XML) a substitute model may be provided, in which case this method returns true. In all other cases this method returns false;- Returns:
- true if this object is a substitute for a model that didn't parse
-
saveXml
public void saveXml(java.lang.StringBuilder buffer, PcodeInjectLibrary injectLibrary)
-
getInjectName
protected java.lang.String getInjectName()
-
restoreXml
public void restoreXml(XmlPullParser parser, CompilerSpec cspec) throws XmlParseException
- Throws:
XmlParseException
-
possibleInputParamWithSlot
public boolean possibleInputParamWithSlot(Address loc, int size, ParamList.WithSlotRec res)
-
possibleOutputParamWithSlot
public boolean possibleOutputParamWithSlot(Address loc, int size, ParamList.WithSlotRec res)
-
getStackParameterAlignment
public int getStackParameterAlignment()
-
getStackParameterOffset
public java.lang.Long getStackParameterOffset()
-
getPotentialInputRegisterStorage
public VariableStorage[] getPotentialInputRegisterStorage(Program prog)
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-