Package ghidra.app.util.demangler
Class DemangledObject
- java.lang.Object
-
- ghidra.app.util.demangler.DemangledObject
-
- Direct Known Subclasses:
DemangledAddressTable
,DemangledFunction
,DemangledString
,DemangledThunk
,DemangledUnknown
,DemangledVariable
public abstract class DemangledObject extends java.lang.Object
A class to represent a demangled object.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
basedName
protected static java.lang.String
EMPTY_STRING
protected boolean
isRestrict
protected boolean
isStatic
protected boolean
isThunk
protected boolean
isUnaligned
protected boolean
isVirtual
protected java.lang.String
memberScope
protected DemangledType
namespace
protected static java.lang.String
NAMESPACE_SEPARATOR
protected java.lang.String
originalMangled
protected static java.lang.String
SPACE
protected static java.util.regex.Pattern
SPACE_PATTERN
protected java.lang.String
specialMidfix
protected java.lang.String
specialPrefix
protected java.lang.String
specialSuffix
protected java.lang.String
storageClass
protected java.lang.String
utilDemangled
protected java.lang.String
visibility
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Symbol
applyDemangledName(Address addr, boolean setPrimary, boolean functionNamespacePermitted, Program prog)
protected Symbol
applyDemangledName(java.lang.String symbolName, Address addr, boolean setPrimary, boolean functionNamespacePermitted, Program prog)
boolean
applyTo(Program program, Address address, DemanglerOptions options, TaskMonitor monitor)
protected Structure
createClassStructure(Program prog, Function func)
static Namespace
createNamespace(Program program, DemangledType typeNamespace, Namespace parentNamespace, boolean functionPermitted)
Get or create the specified typeNamespace.protected static java.lang.String
ensureNameLength(java.lang.String name)
Ensure name does not pass the limit defined by Ghidraprotected java.lang.String
generatePlateComment()
java.lang.String
getBasedName()
java.lang.String
getDemangledName()
Returns the unmodified demangled name of this object.java.lang.String
getMemberScope()
java.lang.String
getName()
Returns the demangled name of this object.DemangledType
getNamespace()
Returns the namespace containing this demangled object.abstract java.lang.String
getSignature(boolean format)
Returns a complete signature for the demangled symbol.java.lang.String
getSpecialMidfix()
java.lang.String
getSpecialPrefix()
java.lang.String
getSpecialSuffix()
java.lang.String
getStorageClass()
java.lang.String
getUtilDemangled()
Gets the demangled output from a supplemental utility.java.lang.String
getVisibility()
protected boolean
isAlreadyDemangled(Program program, Address address)
Determine if the symbol at address has already been demangled.boolean
isConst()
boolean
isPointer64()
boolean
isRestrict()
boolean
isStatic()
boolean
isThunk()
boolean
isUnaligned()
boolean
isVirtual()
boolean
isVolatile()
protected java.lang.String
pad(int len)
void
setBasedName(java.lang.String basedName)
void
setConst(boolean isConst)
void
setMemberScope(java.lang.String memberScope)
void
setName(java.lang.String name)
Sets the name of the demangled objectvoid
setNamespace(DemangledType namespace)
void
setOriginalMangled(java.lang.String mangled)
Sets the original mangled namevoid
setPointer64(boolean isPointer64)
void
setRestrict()
void
setSignature(java.lang.String signature)
Sets the signature.void
setSpecialMidfix(java.lang.String chargeType)
void
setSpecialPrefix(java.lang.String special)
void
setSpecialSuffix(java.lang.String specialSuffix)
void
setStatic(boolean isStatic)
void
setStorageClass(java.lang.String storageClass)
void
setThunk(boolean isThunk)
void
setUnaligned()
void
setUtilDemangled(java.lang.String utilDemangled)
Sets the demangled output from a supplemental utility.void
setVirtual(boolean isVirtual)
void
setVisibilty(java.lang.String visibility)
void
setVolatile(boolean isVolatile)
java.lang.String
toString()
-
-
-
Field Detail
-
SPACE
protected static final java.lang.String SPACE
- See Also:
- Constant Field Values
-
SPACE_PATTERN
protected static final java.util.regex.Pattern SPACE_PATTERN
-
NAMESPACE_SEPARATOR
protected static final java.lang.String NAMESPACE_SEPARATOR
- See Also:
- Constant Field Values
-
EMPTY_STRING
protected static final java.lang.String EMPTY_STRING
- See Also:
- Constant Field Values
-
originalMangled
protected java.lang.String originalMangled
-
utilDemangled
protected java.lang.String utilDemangled
-
specialPrefix
protected java.lang.String specialPrefix
-
specialMidfix
protected java.lang.String specialMidfix
-
specialSuffix
protected java.lang.String specialSuffix
-
namespace
protected DemangledType namespace
-
visibility
protected java.lang.String visibility
-
storageClass
protected java.lang.String storageClass
-
isStatic
protected boolean isStatic
-
isVirtual
protected boolean isVirtual
-
isThunk
protected boolean isThunk
-
isUnaligned
protected boolean isUnaligned
-
isRestrict
protected boolean isRestrict
-
basedName
protected java.lang.String basedName
-
memberScope
protected java.lang.String memberScope
-
-
Method Detail
-
getDemangledName
public java.lang.String getDemangledName()
Returns the unmodified demangled name of this object. This name may contain whitespace and other characters not supported for symbol or data type creation. SeegetName()
for the same name modified for use within Ghidra.- Returns:
- name of this DemangledObject
-
getName
public java.lang.String getName()
Returns the demangled name of this object. NOTE: unsupported symbol characters, like whitespace, will be converted to an underscore.- Returns:
- name of this DemangledObject with unsupported characters converted to underscore
-
isConst
public boolean isConst()
-
setConst
public void setConst(boolean isConst)
-
isVolatile
public boolean isVolatile()
-
setVolatile
public void setVolatile(boolean isVolatile)
-
isPointer64
public boolean isPointer64()
-
setPointer64
public void setPointer64(boolean isPointer64)
-
isStatic
public boolean isStatic()
-
setStatic
public void setStatic(boolean isStatic)
-
isVirtual
public boolean isVirtual()
-
setVirtual
public void setVirtual(boolean isVirtual)
-
isThunk
public boolean isThunk()
-
setThunk
public void setThunk(boolean isThunk)
-
setUnaligned
public void setUnaligned()
-
isUnaligned
public boolean isUnaligned()
-
setRestrict
public void setRestrict()
-
isRestrict
public boolean isRestrict()
-
getBasedName
public java.lang.String getBasedName()
-
setBasedName
public void setBasedName(java.lang.String basedName)
-
getMemberScope
public java.lang.String getMemberScope()
-
setMemberScope
public void setMemberScope(java.lang.String memberScope)
-
setName
public void setName(java.lang.String name)
Sets the name of the demangled object- Parameters:
name
- the new name
-
setOriginalMangled
public void setOriginalMangled(java.lang.String mangled)
Sets the original mangled name- Parameters:
mangled
- the original mangled name
-
setUtilDemangled
public void setUtilDemangled(java.lang.String utilDemangled)
Sets the demangled output from a supplemental utility.- Parameters:
utilDemangled
- the demangled string
-
getUtilDemangled
public java.lang.String getUtilDemangled()
Gets the demangled output from a supplemental utility.- Returns:
- the demangled String created for this object.
-
getNamespace
public DemangledType getNamespace()
Returns the namespace containing this demangled object.- Returns:
- the namespace containing this demangled object
-
setNamespace
public void setNamespace(DemangledType namespace)
-
getVisibility
public java.lang.String getVisibility()
-
setVisibilty
public void setVisibilty(java.lang.String visibility)
-
getStorageClass
public java.lang.String getStorageClass()
-
setStorageClass
public void setStorageClass(java.lang.String storageClass)
-
getSpecialPrefix
public java.lang.String getSpecialPrefix()
-
setSpecialPrefix
public void setSpecialPrefix(java.lang.String special)
-
getSpecialMidfix
public java.lang.String getSpecialMidfix()
-
setSpecialMidfix
public void setSpecialMidfix(java.lang.String chargeType)
-
getSpecialSuffix
public java.lang.String getSpecialSuffix()
-
setSpecialSuffix
public void setSpecialSuffix(java.lang.String specialSuffix)
-
getSignature
public 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
-
setSignature
public void setSignature(java.lang.String signature)
Sets the signature. Calling this method will override the auto-generated signature.- Parameters:
signature
- the signature
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isAlreadyDemangled
protected 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 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 java.lang.Exception
- Throws:
java.lang.Exception
-
generatePlateComment
protected java.lang.String generatePlateComment()
-
pad
protected java.lang.String pad(int len)
-
applyDemangledName
protected Symbol applyDemangledName(Address addr, boolean setPrimary, boolean functionNamespacePermitted, Program prog) throws InvalidInputException
- Throws:
InvalidInputException
-
applyDemangledName
protected Symbol applyDemangledName(java.lang.String symbolName, Address addr, boolean setPrimary, boolean functionNamespacePermitted, Program prog) throws InvalidInputException
- Throws:
InvalidInputException
-
createNamespace
public static Namespace createNamespace(Program program, DemangledType 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. Caller should use#getResidualNamespacePath(DemangledType, Namespace)
to handle the case where only a partial namespace has been returned.- Parameters:
program
-typeNamespace
- demangled namespaceparentNamespace
- 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
-
ensureNameLength
protected 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
-
-