Class DWARFNameInfo


  • public class DWARFNameInfo
    extends java.lang.Object
    A immutable hierarchical path based name implementation that can be viewed as either namespaces or categorypaths.

    • Method Detail

      • createRoot

        public static DWARFNameInfo createRoot​(CategoryPath rootCategory)
        Create a root name entry that will serve as the parent for all children.
        Parameters:
        rootCategory - CategoryPath in the data type manager that will contain any sub-categories that represent namespaces
        Returns:
        a new DWARFNameInfo instance
      • fromList

        public static DWARFNameInfo fromList​(DWARFNameInfo parent,
                                             java.util.List<java.lang.String> names)
        Create a child DWARFNameInfo instance of the specified parent.

        Example:

        fromList(parent, List.of("name1", "name2")) → parent_name/name1/name2
        Parameters:
        parent - DWARFNameInfo parent
        names - list of names
        Returns:
        new DWARFNameInfo instance that is a child of the parent
      • getParent

        public DWARFNameInfo getParent()
        Returns the parent name
        Returns:
        parent
      • isRoot

        public boolean isRoot()
        Returns true if this instance has no parent and is considered the root.
        Returns:
        boolean true if root name, false if not root
      • getOrganizationalCategoryPath

        public CategoryPath getOrganizationalCategoryPath()
        Returns the organizational category path.
        Returns:
        organizational category path for dwarf names
      • getNamespacePath

        public NamespacePath getNamespacePath()
        Returns the NamespacePath of this instance.
        Returns:
        NamespacePath of this instance
      • getParentCP

        public CategoryPath getParentCP()
        Returns the parent's CategoryPath.
        Returns:
        parent name's CategoryPath
      • getName

        public java.lang.String getName()
        Returns the name of this entry.
        Returns:
        string name of this entry, safe to use to name a Ghidra object (datatype, namespace, etc)
      • replaceName

        public DWARFNameInfo replaceName​(java.lang.String newName,
                                         java.lang.String newOriginalName)
        Creates a new DWARFNameInfo instance, using this instance as the template, replacing the name with a new name.
        Parameters:
        newName - name for the new instance
        newOriginalName - originalName for the new instance
        Returns:
        new instance with new name
      • replaceType

        public DWARFNameInfo replaceType​(SymbolType newType)
        Creates a new DWARFNameInfo instance, using this instance as the template, replacing the SymbolType with a new value.
        Parameters:
        newType - new SymbolType value
        Returns:
        new instance with the specified SymbolType
      • getType

        public SymbolType getType()
        Returns the SymbolType of this name.
        Returns:
        SymbolType of this entry
      • asCategoryPath

        public CategoryPath asCategoryPath()
        Converts this object into an equiv CategoryPath.
        Returns:
        CategoryPath: "/organizational_cat_path/namespace1/namespace2/obj_name"
      • asDataTypePath

        public DataTypePath asDataTypePath()
        Converts this object into an equiv DataTypePath.
        Returns:
        DataTypePath: { "/organizational_cat_path/namespace1/namespace2", "obj_name" }
      • getParentNamespace

        public Namespace getParentNamespace​(Program program)
        Returns the Ghidra Namespace that represents this entry's parent.
        Parameters:
        program - the Ghidra program that contains the namespace
        Returns:
        Namespace representing this entry's parent
      • asNamespace

        public Namespace asNamespace​(Program program)
        Converts this object into an equiv Ghidra Namespace, omitting the organizational category path (which only applies to DataTypes).
        Parameters:
        program - Program where the namespace lives.
        Returns:
        Namespace: "ROOT::namespace1::namespace2::obj_name"
      • toString

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

        public boolean isAnon()
        Returns true if the original name of this entry was blank.
        Returns:
        boolean true if there was no original name
      • getOriginalName

        public java.lang.String getOriginalName()
        Returns the original name (unmodified by Ghidra-isms) of this entry.
        Returns:
        original name
      • isNameModified

        public boolean isNameModified()
        Returns true if this instance's name value is different than its original form.

        Returns:
        boolean true if the original name doesn't match the ghidra-ized name
      • createChild

        public DWARFNameInfo createChild​(java.lang.String childOriginalName,
                                         java.lang.String childName,
                                         SymbolType childType)
        Creates a DWARFNameInfo instance, which has a name that is contained with this instance's namespace, using the specified name and symbol type.
        Parameters:
        childOriginalName - the unmodified name
        childName - the ghidra-ized name of the type/symbol/namespace/etc
        childType - the type of the object being named
        Returns:
        new DWARFNameInfo instance
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object