Package ghidra.app.util.demangler
Class DemangledObject
- java.lang.Object
- 
- ghidra.app.util.demangler.DemangledObject
 
- 
- All Implemented Interfaces:
- Demangled
 - Direct Known Subclasses:
- DemangledAddressTable,- DemangledFunction,- DemangledString,- DemangledThunk,- DemangledUnknown,- DemangledVariable
 
 public abstract class DemangledObject extends java.lang.Object implements Demangled A class to represent a demangled object.
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.lang.StringbasedNameprotected static java.lang.StringEMPTY_STRINGprotected booleanisRestrictprotected booleanisStaticprotected booleanisThunkprotected booleanisUnalignedprotected booleanisVirtualprotected java.lang.Stringmangledprotected java.lang.StringmemberScopeprotected Demanglednamespaceprotected static java.lang.StringNAMESPACE_SEPARATORprotected java.lang.StringoriginalDemangledprotected static java.lang.StringSPACEprotected static java.util.regex.PatternSPACE_PATTERNprotected java.lang.StringspecialPrefixprotected java.lang.StringstorageClassprotected java.lang.Stringvisibility
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected SymbolapplyDemangledName(Address addr, boolean setPrimary, boolean functionNamespacePermitted, Program prog)protected SymbolapplyDemangledName(java.lang.String symbolName, Address addr, boolean setPrimary, boolean functionNamespacePermitted, Program prog)booleanapplyPlateCommentOnly(Program program, Address address)booleanapplyTo(Program program, Address address, DemanglerOptions options, TaskMonitor monitor)static NamespacecreateNamespace(Program program, Demangled typeNamespace, Namespace parentNamespace, boolean functionPermitted)Get or create the specified typeNamespace.booleandemangledNameSuccessfully()Returns the success state of converting a mangled String into a demangled Stringprotected static java.lang.StringensureNameLength(java.lang.String name)Ensure name does not pass the limit defined by Ghidraprotected java.lang.StringgeneratePlateComment()Creates descriptive text that is intended to be used as documentation.java.lang.StringgetBasedName()java.lang.StringgetDemangledName()Returns the unmodified demangled name of this object.java.lang.StringgetMangledString()Returns the original mangled stringjava.lang.StringgetMemberScope()java.lang.StringgetName()Returns the demangled name of this object.DemangledgetNamespace()Returns the namespace containing this demangled objectjava.lang.StringgetNamespaceName()Returns this object's namespace name without the fully-qualified parent path.java.lang.StringgetNamespaceString()Returns a representation of this object as fully-qualified namespace.java.lang.StringgetOriginalDemangled()Returns the original demangled string returned by the demangling servicejava.lang.StringgetSignature()Generates a complete representation of this object to include all know attributes of this objectabstract java.lang.StringgetSignature(boolean format)Returns a complete signature for the demangled symbol.java.lang.StringgetSpecialPrefix()java.lang.StringgetStorageClass()java.lang.StringgetVisibility()protected booleanisAlreadyDemangled(Program program, Address address)Determine if the symbol at address has already been demangled.booleanisConst()booleanisPointer64()booleanisRestrict()booleanisStatic()booleanisThunk()booleanisUnaligned()booleanisVirtual()booleanisVolatile()voidsetBackupPlateComment(java.lang.String plateComment)Sets the plate comment to be used if thegetOriginalDemangled()string is not availablevoidsetBasedName(java.lang.String basedName)voidsetConst(boolean isConst)voidsetMemberScope(java.lang.String memberScope)voidsetName(java.lang.String name)Sets the name of the demangled objectvoidsetNamespace(Demangled namespace)Sets the namespace of this demangled objectvoidsetPointer64(boolean isPointer64)voidsetRestrict()voidsetSpecialPrefix(java.lang.String special)voidsetStatic(boolean isStatic)voidsetStorageClass(java.lang.String storageClass)voidsetThunk(boolean isThunk)voidsetUnaligned()voidsetVirtual(boolean isVirtual)voidsetVisibilty(java.lang.String visibility)voidsetVolatile(boolean isVolatile)java.lang.StringtoString()
 
- 
- 
- 
Field Detail- 
SPACEprotected static final java.lang.String SPACE - See Also:
- Constant Field Values
 
 - 
SPACE_PATTERNprotected static final java.util.regex.Pattern SPACE_PATTERN 
 - 
NAMESPACE_SEPARATORprotected static final java.lang.String NAMESPACE_SEPARATOR - See Also:
- Constant Field Values
 
 - 
EMPTY_STRINGprotected static final java.lang.String EMPTY_STRING - See Also:
- Constant Field Values
 
 - 
mangledprotected final java.lang.String mangled 
 - 
originalDemangledprotected final java.lang.String originalDemangled 
 - 
specialPrefixprotected java.lang.String specialPrefix 
 - 
namespaceprotected Demangled namespace 
 - 
visibilityprotected java.lang.String visibility 
 - 
storageClassprotected java.lang.String storageClass 
 - 
isStaticprotected boolean isStatic 
 - 
isVirtualprotected boolean isVirtual 
 - 
isThunkprotected boolean isThunk 
 - 
isUnalignedprotected boolean isUnaligned 
 - 
isRestrictprotected boolean isRestrict 
 - 
basedNameprotected java.lang.String basedName 
 - 
memberScopeprotected java.lang.String memberScope 
 
- 
 - 
Method Detail- 
getDemangledNamepublic java.lang.String getDemangledName() Description copied from interface:DemangledReturns the unmodified demangled name of this object. This name may contain whitespace and other characters not supported for symbol or data type creation. SeeDemangled.getName()for the same name modified for use within Ghidra.- Specified by:
- getDemangledNamein interface- Demangled
- Returns:
- name of this DemangledObject
 
 - 
getNamepublic java.lang.String getName() Description copied from interface:DemangledReturns the demangled name of this object. NOTE: unsupported symbol characters, like whitespace, will be converted to an underscore.- Specified by:
- getNamein interface- Demangled
- Returns:
- name of this DemangledObject with unsupported characters converted to underscore
- See Also:
- Demangled.getDemangledName()
 
 - 
isConstpublic boolean isConst() 
 - 
setConstpublic void setConst(boolean isConst) 
 - 
isVolatilepublic boolean isVolatile() 
 - 
setVolatilepublic void setVolatile(boolean isVolatile) 
 - 
isPointer64public boolean isPointer64() 
 - 
setPointer64public void setPointer64(boolean isPointer64) 
 - 
isStaticpublic boolean isStatic() 
 - 
setStaticpublic void setStatic(boolean isStatic) 
 - 
isVirtualpublic boolean isVirtual() 
 - 
setVirtualpublic void setVirtual(boolean isVirtual) 
 - 
isThunkpublic boolean isThunk() 
 - 
setThunkpublic void setThunk(boolean isThunk) 
 - 
setUnalignedpublic void setUnaligned() 
 - 
isUnalignedpublic boolean isUnaligned() 
 - 
setRestrictpublic void setRestrict() 
 - 
isRestrictpublic boolean isRestrict() 
 - 
getBasedNamepublic java.lang.String getBasedName() 
 - 
setBasedNamepublic void setBasedName(java.lang.String basedName) 
 - 
getMemberScopepublic java.lang.String getMemberScope() 
 - 
setMemberScopepublic void setMemberScope(java.lang.String memberScope) 
 - 
setNamepublic void setName(java.lang.String name) Sets the name of the demangled object
 - 
demangledNameSuccessfullypublic boolean demangledNameSuccessfully() Returns the success state of converting a mangled String into a demangled String- Returns:
- true succeeded creating demangled String
 
 - 
getMangledStringpublic java.lang.String getMangledString() Description copied from interface:DemangledReturns the original mangled string- Specified by:
- getMangledStringin interface- Demangled
- Returns:
- the string
 
 - 
getOriginalDemangledpublic java.lang.String getOriginalDemangled() Description copied from interface:DemangledReturns the original demangled string returned by the demangling service- Specified by:
- getOriginalDemangledin interface- Demangled
- Returns:
- the original demangled string
 
 - 
getNamespacepublic Demangled getNamespace() Description copied from interface:DemangledReturns the namespace containing this demangled object- Specified by:
- getNamespacein interface- Demangled
- Returns:
- the namespace containing this demangled object
 
 - 
setNamespacepublic void setNamespace(Demangled namespace) Description copied from interface:DemangledSets the namespace of this demangled object- Specified by:
- setNamespacein interface- Demangled
- Parameters:
- namespace- the namespace
 
 - 
getVisibilitypublic java.lang.String getVisibility() 
 - 
setVisibiltypublic void setVisibilty(java.lang.String visibility) 
 - 
getStorageClasspublic java.lang.String getStorageClass() 
 - 
setStorageClasspublic void setStorageClass(java.lang.String storageClass) 
 - 
getSpecialPrefixpublic java.lang.String getSpecialPrefix() 
 - 
setSpecialPrefixpublic void setSpecialPrefix(java.lang.String special) 
 - 
getSignaturepublic abstract java.lang.String getSignature(boolean format) Returns 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.- Parameters:
- format- true if signature should be pretty printed
- Returns:
- a complete signature for the demangled symbol
 
 - 
getSignaturepublic final java.lang.String getSignature() Description copied from interface:DemangledGenerates a complete representation of this object to include all know attributes of this object- Specified by:
- getSignaturein interface- Demangled
- Returns:
- the signature
 
 - 
getNamespaceNamepublic java.lang.String 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 interface- Demangled
- Returns:
- the name
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
getNamespaceStringpublic java.lang.String getNamespaceString() Description copied from interface:DemangledReturns a representation of this object as fully-qualified namespace. The value returned here may have had some special characters replaced, such as ' ' replaced with '_' and '::' replaced with '--'.- Specified by:
- getNamespaceStringin interface- Demangled
- Returns:
- the full namespace
 
 - 
isAlreadyDemangledprotected boolean isAlreadyDemangled(Program program, Address address) Determine 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.- Parameters:
- program- the program being modified
- address- address of demangled symbol
- Returns:
- true if symbol at address has already been demangled
 
 - 
applyTopublic boolean applyTo(Program program, Address address, DemanglerOptions options, TaskMonitor monitor) throws java.lang.Exception - Throws:
- java.lang.Exception
 
 - 
applyPlateCommentOnlypublic boolean applyPlateCommentOnly(Program program, Address address) throws java.lang.Exception - Parameters:
- program- The program for which to apply the comment
- address- The address for the comment
- Returns:
- trueif a comment was applied
- Throws:
- java.lang.Exception- if the symbol could not be demangled or if the address is invalid
 
 - 
setBackupPlateCommentpublic void setBackupPlateComment(java.lang.String plateComment) Sets the plate comment to be used if thegetOriginalDemangled()string is not available- Parameters:
- plateComment- the plate comment text
 
 - 
generatePlateCommentprotected java.lang.String generatePlateComment() Creates descriptive text that is intended to be used as documentation. The text defaults to the original demangled text. If that is not available, then any text set bysetBackupPlateComment(String)will be used. The last choice for this text is the signature generated bygetSignature(boolean).- Returns:
- the text
 
 - 
applyDemangledNameprotected Symbol applyDemangledName(Address addr, boolean setPrimary, boolean functionNamespacePermitted, Program prog) throws InvalidInputException - Throws:
- InvalidInputException
 
 - 
applyDemangledNameprotected Symbol applyDemangledName(java.lang.String symbolName, Address addr, boolean setPrimary, boolean functionNamespacePermitted, Program prog) throws InvalidInputException - Throws:
- InvalidInputException
 
 - 
createNamespacepublic static Namespace createNamespace(Program program, Demangled typeNamespace, Namespace parentNamespace, boolean functionPermitted) Get or create the specified typeNamespace. The returned namespace may only be a partial namespace if errors occurred. The caller should check the returned namespace and adjust any symbol creation accordingly.- Parameters:
- program- the program
- typeNamespace- demangled namespace
- parentNamespace- root namespace to be used (e.g., library, global, etc.)
- functionPermitted- if true an existing function may be used as a namespace
- Returns:
- namespace or partial namespace if error occurs
 
 - 
ensureNameLengthprotected static java.lang.String ensureNameLength(java.lang.String name) Ensure name does not pass the limit defined by Ghidra- Parameters:
- name- the name whose length to restrict
- Returns:
- the name, updated as needed
 
 
- 
 
-