Class DWARFNameInfo
- java.lang.Object
-
- ghidra.app.util.bin.format.dwarf4.next.DWARFNameInfo
-
public class DWARFNameInfo extends java.lang.ObjectA immutable hierarchical path based name implementation that can be viewed as eithernamespacesorcategorypaths.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CategoryPathasCategoryPath()Converts this object into an equivCategoryPath.DataTypePathasDataTypePath()Converts this object into an equivDataTypePath.NamespaceasNamespace(Program program)Converts this object into an equiv GhidraNamespace, omitting the organizational category path (which only applies to DataTypes).DWARFNameInfocreateChild(java.lang.String childOriginalName, java.lang.String childName, SymbolType childType)Creates aDWARFNameInfoinstance, which has a name that is contained with this instance's namespace, using the specified name and symbol type.static DWARFNameInfocreateRoot(CategoryPath rootCategory)Create a root name entry that will serve as the parent for all children.booleanequals(java.lang.Object obj)static DWARFNameInfofromDataType(DataType dataType)Create aDWARFNameInfoinstance using the specifiedDataType's name.static DWARFNameInfofromList(DWARFNameInfo parent, java.util.List<java.lang.String> names)Create a childDWARFNameInfoinstance of the specified parent.java.lang.StringgetName()Returns the name of this entry.NamespacePathgetNamespacePath()Returns the NamespacePath of this instance.CategoryPathgetOrganizationalCategoryPath()Returns the organizational category path.java.lang.StringgetOriginalName()Returns the original name (unmodified by Ghidra-isms) of this entry.DWARFNameInfogetParent()Returns the parent nameCategoryPathgetParentCP()Returns the parent's CategoryPath.NamespacegetParentNamespace(Program program)Returns the GhidraNamespacethat represents this entry's parent.SymbolTypegetType()Returns the SymbolType of this name.inthashCode()booleanisAnon()Returns true if the original name of this entry was blank.booleanisNameModified()booleanisRoot()Returns true if this instance has no parent and is considered the root.DWARFNameInforeplaceName(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.DWARFNameInforeplaceType(SymbolType newType)Creates a new DWARFNameInfo instance, using this instance as the template, replacing the SymbolType with a new value.java.lang.StringtoString()
-
-
-
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-CategoryPathin the data type manager that will contain any sub-categories that represent namespaces- Returns:
- a new
DWARFNameInfoinstance
-
fromDataType
public static DWARFNameInfo fromDataType(DataType dataType)
Create aDWARFNameInfoinstance using the specifiedDataType's name.- Parameters:
dataType-DataType- Returns:
- new
DWARFNameInfousing the same name / CategoryPath as the data type
-
fromList
public static DWARFNameInfo fromList(DWARFNameInfo parent, java.util.List<java.lang.String> names)
Create a childDWARFNameInfoinstance of the specified parent.Example:
fromList(parent, List.of("name1", "name2")) → parent_name/name1/name2- Parameters:
parent-DWARFNameInfoparentnames- list of names- Returns:
- new
DWARFNameInfoinstance 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:
NamespacePathof 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 instancenewOriginalName- 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:
SymbolTypeof this entry
-
asCategoryPath
public CategoryPath asCategoryPath()
Converts this object into an equivCategoryPath.- Returns:
CategoryPath: "/organizational_cat_path/namespace1/namespace2/obj_name"
-
asDataTypePath
public DataTypePath asDataTypePath()
Converts this object into an equivDataTypePath.- Returns:
DataTypePath: { "/organizational_cat_path/namespace1/namespace2", "obj_name" }
-
getParentNamespace
public Namespace getParentNamespace(Program program)
Returns the GhidraNamespacethat represents this entry's parent.- Parameters:
program- the Ghidra program that contains the namespace- Returns:
Namespacerepresenting this entry's parent
-
asNamespace
public Namespace asNamespace(Program program)
Converts this object into an equiv GhidraNamespace, omitting the organizational category path (which only applies to DataTypes).
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.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:
- 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 aDWARFNameInfoinstance, which has a name that is contained with this instance's namespace, using the specified name and symbol type.- Parameters:
childOriginalName- the unmodified namechildName- the ghidra-ized name of the type/symbol/namespace/etcchildType- the type of the object being named- Returns:
- new DWARFNameInfo instance
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-