Class DemangledObject

    • Field Detail

      • 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
      • mangled

        protected final java.lang.String mangled
      • originalDemangled

        protected final java.lang.String originalDemangled
      • specialPrefix

        protected java.lang.String specialPrefix
      • 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()
        Description copied from interface: Demangled
        Returns the unmodified demangled name of this object. This name may contain whitespace and other characters not supported for symbol or data type creation. See Demangled.getName() for the same name modified for use within Ghidra.
        Specified by:
        getDemangledName in interface Demangled
        Returns:
        name of this DemangledObject
      • getName

        public java.lang.String getName()
        Description copied from interface: Demangled
        Returns the demangled name of this object. NOTE: unsupported symbol characters, like whitespace, will be converted to an underscore.
        Specified by:
        getName in interface Demangled
        Returns:
        name of this DemangledObject with unsupported characters converted to underscore
        See Also:
        Demangled.getDemangledName()
      • 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
        Specified by:
        setName in interface Demangled
        Parameters:
        name - the new name
      • demangledNameSuccessfully

        public boolean demangledNameSuccessfully()
        Returns the success state of converting a mangled String into a demangled String
        Returns:
        true succeeded creating demangled String
      • getMangledString

        public java.lang.String getMangledString()
        Description copied from interface: Demangled
        Returns the original mangled string
        Specified by:
        getMangledString in interface Demangled
        Returns:
        the string
      • getOriginalDemangled

        public java.lang.String getOriginalDemangled()
        Description copied from interface: Demangled
        Returns the original demangled string returned by the demangling service
        Specified by:
        getOriginalDemangled in interface Demangled
        Returns:
        the original demangled string
      • getNamespace

        public Demangled getNamespace()
        Description copied from interface: Demangled
        Returns the namespace containing this demangled object
        Specified by:
        getNamespace in interface Demangled
        Returns:
        the namespace containing this demangled object
      • setNamespace

        public void setNamespace​(Demangled namespace)
        Description copied from interface: Demangled
        Sets the namespace of this demangled object
        Specified by:
        setNamespace in interface Demangled
        Parameters:
        namespace - the 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)
      • 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
      • getSignature

        public final java.lang.String getSignature()
        Description copied from interface: Demangled
        Generates a complete representation of this object to include all know attributes of this object
        Specified by:
        getSignature in interface Demangled
        Returns:
        the signature
      • getNamespaceName

        public java.lang.String getNamespaceName()
        Description copied from interface: Demangled
        Returns 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:
        getNamespaceName in interface Demangled
        Returns:
        the name
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getNamespaceString

        public java.lang.String getNamespaceString()
        Description copied from interface: Demangled
        Returns 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:
        getNamespaceString in interface Demangled
        Returns:
        the full namespace
      • 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 modified
        address - address of demangled symbol
        Returns:
        true if symbol at address has already been demangled
      • applyPlateCommentOnly

        public 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:
        true if a comment was applied
        Throws:
        java.lang.Exception - if the symbol could not be demangled or if the address is invalid
      • setBackupPlateComment

        public void setBackupPlateComment​(java.lang.String plateComment)
        Sets the plate comment to be used if the getOriginalDemangled() string is not available
        Parameters:
        plateComment - the plate comment text
      • generatePlateComment

        protected 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 by setBackupPlateComment(String) will be used. The last choice for this text is the signature generated by getSignature(boolean).
        Returns:
        the text
      • createNamespace

        public 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
      • 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