Class DWARFNameInfo
- java.lang.Object
-
- ghidra.app.util.bin.format.dwarf4.next.DWARFNameInfo
-
public class DWARFNameInfo extends java.lang.Object
A immutable hierarchical path based name implementation that can be viewed as eithernamespaces
orcategorypaths
.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CategoryPath
asCategoryPath()
Converts this object into an equivCategoryPath
.DataTypePath
asDataTypePath()
Converts this object into an equivDataTypePath
.Namespace
asNamespace(Program program)
Converts this object into an equiv GhidraNamespace
, omitting the organizational category path (which only applies to DataTypes).DWARFNameInfo
createChild(java.lang.String childOriginalName, java.lang.String childName, SymbolType childType)
Creates aDWARFNameInfo
instance, which has a name that is contained with this instance's namespace, using the specified name and symbol type.static DWARFNameInfo
createRoot(CategoryPath rootCategory)
Create a root name entry that will serve as the parent for all children.boolean
equals(java.lang.Object obj)
static DWARFNameInfo
fromDataType(DataType dataType)
Create aDWARFNameInfo
instance using the specifiedDataType
's name.static DWARFNameInfo
fromList(DWARFNameInfo parent, java.util.List<java.lang.String> names)
Create a childDWARFNameInfo
instance of the specified parent.java.lang.String
getName()
Returns the name of this entry.NamespacePath
getNamespacePath()
Returns the NamespacePath of this instance.CategoryPath
getOrganizationalCategoryPath()
Returns the organizational category path.java.lang.String
getOriginalName()
Returns the original name (unmodified by Ghidra-isms) of this entry.DWARFNameInfo
getParent()
Returns the parent nameCategoryPath
getParentCP()
Returns the parent's CategoryPath.Namespace
getParentNamespace(Program program)
Returns the GhidraNamespace
that represents this entry's parent.SymbolType
getType()
Returns the SymbolType of this name.int
hashCode()
boolean
isAnon()
Returns true if the original name of this entry was blank.boolean
isNameModified()
boolean
isRoot()
Returns true if this instance has no parent and is considered the root.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.DWARFNameInfo
replaceType(SymbolType newType)
Creates a new DWARFNameInfo instance, using this instance as the template, replacing the SymbolType with a new value.java.lang.String
toString()
-
-
-
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
-
fromDataType
public static DWARFNameInfo fromDataType(DataType dataType)
Create aDWARFNameInfo
instance using the specifiedDataType
's name.- Parameters:
dataType
-DataType
- Returns:
- new
DWARFNameInfo
using the same name / CategoryPath as the data type
-
fromList
public static DWARFNameInfo fromList(DWARFNameInfo parent, java.util.List<java.lang.String> names)
Create a childDWARFNameInfo
instance of the specified parent.Example:
fromList(parent, List.of("name1", "name2")) → parent_name/name1/name2
- Parameters:
parent
-DWARFNameInfo
parentnames
- 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 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:
SymbolType
of 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 GhidraNamespace
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 GhidraNamespace
, omitting the organizational category path (which only applies to DataTypes).
-
toString
public java.lang.String toString()
- Overrides:
toString
in 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 aDWARFNameInfo
instance, 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:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-