Package ghidra.app.util.demangler
Class DemangledFunction
java.lang.Object
ghidra.app.util.demangler.DemangledObject
ghidra.app.util.demangler.DemangledFunction
- All Implemented Interfaces:
Demangled
- Direct Known Subclasses:
DemangledLambda
A class to represent a demangled function.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringstatic final Stringprotected booleanprotected List<DemangledParameter> static final Stringstatic final Stringprotected DemangledDataTypeprotected SourceTypeprotected DemangledTemplateprotected booleanstatic final Stringstatic final StringFields inherited from class ghidra.app.util.demangler.DemangledObject
basedName, EMPTY_STRING, isRestrict, isStatic, isThunk, isUnaligned, isVirtual, mangled, mangledContext, memberScope, namespace, NAMESPACE_SEPARATOR, originalDemangled, rawDemangled, SPACE, SPACE_PATTERN, specialPrefix, storageClass, visibility -
Constructor Summary
ConstructorsConstructorDescriptionDemangledFunction(String mangled, String originalDemangled, String name) Create aDemangledFunctioninstance which is marked with a signatureSourceTypeofSourceType.ANALYSISwhich will be used when function signatures are applied to a program. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddParameter(DemangledParameter parameter) protected voidaddParameters(StringBuilder buffer, boolean format) voidaddParameters(List<DemangledParameter> params) booleanapplyTo(Program program, Address address, DemanglerOptions options, TaskMonitor monitor) Apply this demangled object detail to the specified program.protected FunctioncreateFunction(Program prog, Address addr, boolean doDisassembly, TaskMonitor monitor) Returns the calling convention or null, if unspecified.Returns this object's namespace name without the fully-qualified parent path.Returns the return type or null, if unspecified.getSignature(boolean format) Returns a complete signature for the demangled symbol.Get the signature source type which is used when applying the function signature to a program.protected booleanisAlreadyDemangled(Program program, Address address) Determine if the symbol at address has already been demangled.protected booleancheck if the return/param data types were defined by better than analysis (user, import)booleanbooleanbooleanbooleanbooleanbooleanprotected StructuremaybeCreateClassStructure(Program program, Function function, String convention) voidsetCallingConvention(String callingConvention) Sets the function calling convention.voidsetOverloadedOperator(boolean isOverloadedOperator) Sets whether this demangled function represents an overloaded operator.voidsetReturnType(DemangledDataType returnType) Sets the function return type.voidsetSignatureSourceType(SourceType signatureSourceType) Set signatureSourceTypeofSourceType.ANALYSISwhich will be used when function signatures are applied to a program.voidsetTemplate(DemangledTemplate template) voidSpecial constructor where it has a templated type before the parameter listvoidsetThrowAttribute(String throwAttribute) voidvoidvoidvoidvoidvoidMethods inherited from class ghidra.app.util.demangler.DemangledObject
applyDemangledName, applyDemangledName, applyPlateCommentOnly, applyUsingContext, createNamespace, demangledNameSuccessfully, ensureNameLength, generatePlateComment, getBasedName, getDemangledName, getErrorMessage, getMangledContext, getMangledString, getMemberScope, getName, getNamespace, getNamespaceString, getOriginalDemangled, getRawDemangled, getSignature, getSpecialPrefix, getStorageClass, getVisibility, isConst, isPointer64, isRestrict, isStatic, isThunk, isUnaligned, isVirtual, isVolatile, setBackupPlateComment, setBasedName, setConst, setErrorMessage, setMangledContext, setMemberScope, setName, setNamespace, setOriginalDemangled, setPointer64, setRawDemangledString, setRestrict, setSpecialPrefix, setStatic, setStorageClass, setThunk, setUnaligned, setVirtual, setVisibilty, setVolatile, toString
-
Field Details
-
VOLATILE
- See Also:
-
CONST
- See Also:
-
PTR64
- See Also:
-
UNALIGNED
- See Also:
-
RESTRICT
- See Also:
-
returnType
-
callingConvention
-
thisPassedOnStack
protected boolean thisPassedOnStack -
parameters
-
template
-
isOverloadedOperator
protected boolean isOverloadedOperator -
signatureSourceType
-
-
Constructor Details
-
DemangledFunction
Create aDemangledFunctioninstance which is marked with a signatureSourceTypeofSourceType.ANALYSISwhich will be used when function signatures are applied to a program. This source type may be changed if needed usingsetSignatureSourceType(SourceType). The function name and namespace is always applied using a symbol source ofSourceType.ANALYSIS.- Parameters:
mangled- original mangled symbol nameoriginalDemangled- demangled function signature generally used when generating commentsname- demangled function name
-
-
Method Details
-
setSignatureSourceType
Set signatureSourceTypeofSourceType.ANALYSISwhich will be used when function signatures are applied to a program. SpecifyingSourceType.DEFAULTwill prevent function return and parameters from being applied but will still apply calling convention name if specified.- Parameters:
signatureSourceType- signature source type
-
getSignatureSourceType
Get the signature source type which is used when applying the function signature to a program. A value ofSourceType.DEFAULTindicates that function return and parameters should not be applied.- Returns:
- signature source type
-
setReturnType
Sets the function return type.- Parameters:
returnType- the function return type
-
setCallingConvention
Sets the function calling convention. For example, "__cdecl".- Parameters:
callingConvention- the function calling convention
-
setTemplate
-
getTemplate
-
setOverloadedOperator
public void setOverloadedOperator(boolean isOverloadedOperator) Sets whether this demangled function represents an overloaded operator. For example, "operator+()".- Parameters:
isOverloadedOperator- true if overloaded operator
-
addParameter
-
addParameters
-
getParameters
-
getReturnType
Returns the return type or null, if unspecified.- Returns:
- the return type or null, if unspecified
-
getCallingConvention
Returns the calling convention or null, if unspecified.- Returns:
- the calling convention or null, if unspecified
-
setTemplatedConstructorType
Special constructor where it has a templated type before the parameter list- Parameters:
type- the type
-
isTrailingConst
public boolean isTrailingConst() -
setTrailingConst
public void setTrailingConst() -
isTrailingVolatile
public boolean isTrailingVolatile() -
setTrailingVolatile
public void setTrailingVolatile() -
isTrailingPointer64
public boolean isTrailingPointer64() -
setTrailingPointer64
public void setTrailingPointer64() -
isTrailingUnaligned
public boolean isTrailingUnaligned() -
setTrailingUnaligned
public void setTrailingUnaligned() -
isTrailingRestrict
public boolean isTrailingRestrict() -
setTrailingRestrict
public void setTrailingRestrict() -
isTypeCast
public boolean isTypeCast() -
setTypeCast
public void setTypeCast() -
setThrowAttribute
-
getSignature
Description copied from class:DemangledObjectReturns a complete signature for the demangled symbol.
For example: "unsigned long foo" "unsigned char * ClassA::getFoo(float, short *)" "void * getBar(int **, MyStruct &)"
Note: based on the underlying mangling scheme, the return type may or may not be specified in the signature.- Specified by:
getSignaturein classDemangledObject- Parameters:
format- true if signature should be pretty printed- Returns:
- a complete signature for the demangled symbol
-
addParameters
-
getNamespaceName
Description copied from interface:DemangledReturns this object's namespace name without the fully-qualified parent path. The value returned here may have had some special characters replaced, such as ' ' replaced with '_' and '::' replaced with '--'.- Specified by:
getNamespaceNamein interfaceDemangled- Overrides:
getNamespaceNamein classDemangledObject- Returns:
- the name
-
getParameterString
-
isAlreadyDemangled
Description copied from class:DemangledObjectDetermine if the symbol at address has already been demangled. While memory symbols check for presence of demangledName, external symbols simply check if demangled/alternate name has already been assigned.- Overrides:
isAlreadyDemangledin classDemangledObject- Parameters:
program- the program being modifiedaddress- address of demangled symbol- Returns:
- true if symbol at address has already been demangled
-
applyTo
public boolean applyTo(Program program, Address address, DemanglerOptions options, TaskMonitor monitor) throws Exception Description copied from class:DemangledObjectApply this demangled object detail to the specified program.
NOTE: An open Program transaction must be established prior to invoking this method.- Overrides:
applyToin classDemangledObject- Parameters:
program- program to which demangled data should be applied.address- address which corresponds to this demangled objectoptions- options which control how demangled data is appliedmonitor- task monitor- Returns:
- true if successfully applied, else false
- Throws:
Exception- if an error occurs during the apply operation
-
isDefinedFunctionDataTypes
check if the return/param data types were defined by better than analysis (user, import)- Parameters:
func- the function to check- Returns:
- true if the parameters are not undefined, or are of a higher source type.
-
maybeCreateClassStructure
-
createFunction
protected Function createFunction(Program prog, Address addr, boolean doDisassembly, TaskMonitor monitor) throws DemangledException - Throws:
DemangledException
-