Class DWARFUtil
- java.lang.Object
- 
- ghidra.app.util.bin.format.dwarf4.DWARFUtil
 
- 
 public class DWARFUtil extends java.lang.Object
- 
- 
Constructor SummaryConstructors Constructor Description DWARFUtil()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static voidappendDescription(DataTypeComponent dtc, java.lang.String description, java.lang.String sep)Append a string to a description of a field in a structure.static voidappendDescription(DataType dt, java.lang.String description, java.lang.String sep)Append a string to aDataType's description.static java.util.List<java.lang.String>findLinkageNameInChildren(DebugInfoEntry die)Try to find gnu mangled name nesting info in a DIE's children's linkage strings.static java.lang.StringgetAnonNameForMeFromParentContext(DIEAggregate diea)Creates a name for anon types based on their position in their parent's childList.static java.lang.StringgetAnonNameForMeFromParentContext2(DIEAggregate diea)Creates a name for anon types based on the names of sibling entries that are using the anon type.static java.lang.StringgetContainerTypeName(DIEAggregate diea)Returns a string that describes what kind of object is specified by theDIEAggregate.static java.lang.StringgetLexicalBlockName(DIEAggregate diea)Create a name for a lexical block, with "_" separated numbers indicating nesting information of the lexical block.static intgetMyPositionInParent(DebugInfoEntry die)Returns the ordinal position of thisDebugInfoEntryin it's parent.static DIEAggregategetReferringTypedef(DIEAggregate diea)Returns theDIEAggregateof a typedef that points to the specified datatype.static java.lang.reflect.FieldgetStaticFinalFieldWithValue(java.lang.Class<?> clazz, long value)Searches a Class for a final static variable that has a specific numeric value.static SymbolTypegetSymbolTypeFromDIE(DIEAggregate diea)Returns theSymbolTypethat corresponds to the specifiedDIEAggregate.static java.lang.StringgetTemplateBaseName(java.lang.String name)Determines if a name is a C++ style templated name.static booleanisThisParam(DIEAggregate paramDIEA)static java.util.List<java.lang.String>parseMangledNestings(java.lang.String s)A lightweight attempt to get nesting (ie.static java.lang.NumberreadAddress(BinaryReader reader, byte pointerSize)Read the value of an address.static longreadAddressAsLong(BinaryReader reader, byte pointerSize)Reads a variable-sized unsigned 'address' value from aBinaryReaderand returns it as a 64 bit java long.static longreadOffsetByDWARFformat(BinaryReader reader, int dwarfFormat)Read an offset value who's size depends on the DWARF format: 32 vs 64.static intreadVarSizedUInt(BinaryReader reader, int size)Read a variable-sized unsigned integer and return it as a java signed int.static longreadVarSizedULong(BinaryReader reader, int pointerSize)Read a variable-sized unsigned integer and return it as a java signed long.static java.lang.StringtoString(java.lang.Class<?> clazz, int value)Converts a integer value to its corresponding symbolic name from the set of "public static final" member variables in a class.static java.lang.StringtoString(java.lang.Class<?> clazz, long value)Returns the field name of a final static variable in classclazzwhich holds a specific value.
 
- 
- 
- 
Method Detail- 
toStringpublic static java.lang.String toString(java.lang.Class<?> clazz, int value)Converts a integer value to its corresponding symbolic name from the set of "public static final" member variables in a class.This is a bit of a hack and probably originated from pre-java Enum days. - Parameters:
- clazz- The- Classto search for the matching static value.
- value- the integer value to search for
- Returns:
- the String name of the matching field.
 
 - 
toStringpublic static java.lang.String toString(java.lang.Class<?> clazz, long value)Returns the field name of a final static variable in classclazzwhich holds a specific value.Can be thought of as an enum numeric value to to name lookup. - Parameters:
- clazz-
- value-
- Returns:
 
 - 
getStaticFinalFieldWithValuepublic static java.lang.reflect.Field getStaticFinalFieldWithValue(java.lang.Class<?> clazz, long value)Searches a Class for a final static variable that has a specific numeric value.- Parameters:
- clazz- Class to search.
- value- numeric value to search for
- Returns:
- Java reflection Fieldthat has the specified value or null
 
 - 
getContainerTypeNamepublic static java.lang.String getContainerTypeName(DIEAggregate diea) Returns a string that describes what kind of object is specified by theDIEAggregate.Used to create a name for anonymous types. - Parameters:
- diea-- DIEAggregate
- Returns:
- String describing the type of the DIEA.
 
 - 
getSymbolTypeFromDIEpublic static SymbolType getSymbolTypeFromDIE(DIEAggregate diea) Returns theSymbolTypethat corresponds to the specifiedDIEAggregate.The mapping between DIE type and SymbolType is not exact. There is no matching SymbolType for a DWARF static variable, so "LOCAL_VAR" is used currently. This mainly is used in constructing a NamespacePath, and the only critical usage there is Namespace vs. Class vs. everything else. - Parameters:
- diea-- DIEAggregateto query
- Returns:
- SymbolType
 
 - 
parseMangledNestingspublic static java.util.List<java.lang.String> parseMangledNestings(java.lang.String s) A lightweight attempt to get nesting (ie. namespaces and such) information from gnu mangled name strings.For example, "_ZN19class1_inline_funcs3fooEv" -> [19 chars]'class1_inline_funcs', [3 chars]'foo' - Parameters:
- s-
- Returns:
 
 - 
findLinkageNameInChildrenpublic static java.util.List<java.lang.String> findLinkageNameInChildren(DebugInfoEntry die) Try to find gnu mangled name nesting info in a DIE's children's linkage strings.- Parameters:
- die-
- Returns:
- a list of string of nesting names, ending with what should be the DIE parameter's name.
 
 - 
getTemplateBaseNamepublic static java.lang.String getTemplateBaseName(java.lang.String name) Determines if a name is a C++ style templated name. If so, returns just the base portion of the name. The name must have a start and end angle bracket: '<' and '>'.operator<() and operator<<() are handled so their angle brackets don't trigger the template start/end angle bracket incorrectly. - Parameters:
- name- symbol name with C++ template portions
- Returns:
- base portion of the symbol name without template portion
 
 - 
getAnonNameForMeFromParentContextpublic static java.lang.String getAnonNameForMeFromParentContext(DIEAggregate diea) Creates a name for anon types based on their position in their parent's childList.- Parameters:
- die-
- Returns:
 
 - 
getAnonNameForMeFromParentContext2public static java.lang.String getAnonNameForMeFromParentContext2(DIEAggregate diea) Creates a name for anon types based on the names of sibling entries that are using the anon type.Example: "anon_struct_for_field1_field2" Falls back to #getAnonNameForMeFromParentContext(DebugInfoEntry)if no siblings found.- Parameters:
- die-
- Returns:
 
 - 
getLexicalBlockNamepublic static java.lang.String getLexicalBlockName(DIEAggregate diea) Create a name for a lexical block, with "_" separated numbers indicating nesting information of the lexical block.- Parameters:
- diea-- DIEAggregatepointing to a lexical block entry.
- Returns:
- string, ie. "lexical_block_1_2_3"
 
 - 
getMyPositionInParentpublic static int getMyPositionInParent(DebugInfoEntry die) Returns the ordinal position of thisDebugInfoEntryin it's parent.- Parameters:
- die-- DebugInfoEntry
- Returns:
- int index of ourself in our parent, or -1 if not found in parent.
 
 - 
appendDescriptionpublic static void appendDescription(DataType dt, java.lang.String description, java.lang.String sep) Append a string to aDataType's description.- Parameters:
- dt-- DataType
- description- string to append, if null or empty nothing happens.
- sep- characters to place after previous description to separate it from the new portion.
 
 - 
appendDescriptionpublic static void appendDescription(DataTypeComponent dtc, java.lang.String description, java.lang.String sep) Append a string to a description of a field in a structure.- Parameters:
- dtc- the- fieldin a struct
- description- string to append, if null or empty nothing happens.
- sep- characters to place after previous description to separate it from the new portion.
 
 - 
readOffsetByDWARFformatpublic static long readOffsetByDWARFformat(BinaryReader reader, int dwarfFormat) throws java.io.IOException Read an offset value who's size depends on the DWARF format: 32 vs 64.- Parameters:
- reader- BinaryReader pointing to the value to read
- dwarfFormat- - See- DWARFCompilationUnit.DWARF_32and- DWARFCompilationUnit.DWARF_64.
- Returns:
- the offset value
- Throws:
- java.io.IOException- if an I/O error occurs or bad dwarfFormat value
 
 - 
readVarSizedULongpublic static long readVarSizedULong(BinaryReader reader, int pointerSize) throws java.io.IOException Read a variable-sized unsigned integer and return it as a java signed long.- Parameters:
- reader-- BinaryReaderto read the data from
- pointerSize- number of bytes the value is stored in, must be 1, 2, 4, or 8.
- Returns:
- unsigned long integer value.
- Throws:
- java.io.IOException- if error
 
 - 
readVarSizedUIntpublic static int readVarSizedUInt(BinaryReader reader, int size) throws java.io.IOException Read a variable-sized unsigned integer and return it as a java signed int.Unsigned 32 bit int values larger than java's signed Integer.MAX_VALUE are not supported and will throw an IOException. - Parameters:
- reader-- BinaryReaderto read the data from
- size- number of bytes the integer value is stored in, must be 1, 2 or 4.
- Returns:
- unsigned integer value.
- Throws:
- java.io.IOException- if error
 
 - 
readAddresspublic static java.lang.Number readAddress(BinaryReader reader, byte pointerSize) throws java.io.IOException Read the value of an address.- Parameters:
- reader- BinaryReader pointing to the value to read
- pointerSize- the size of a pointer
- Returns:
- the address value
- Throws:
- java.io.IOException- if an I/O error occurs
- java.lang.IllegalArgumentException- if an unknown pointer size is given
 
 - 
readAddressAsLongpublic static long readAddressAsLong(BinaryReader reader, byte pointerSize) throws java.io.IOException Reads a variable-sized unsigned 'address' value from aBinaryReaderand returns it as a 64 bit java long.The valid pointerSizes are 1, 2, 4, and 8. - Parameters:
- reader-- BinaryReaderto read the data from
- pointerSize- number of bytes the value is stored in, must be 1, 2, 4, or 8.
- Returns:
- unsigned long value.
- Throws:
- java.io.IOException- if error
 
 - 
isThisParampublic static boolean isThisParam(DIEAggregate paramDIEA) 
 - 
getReferringTypedefpublic static DIEAggregate getReferringTypedef(DIEAggregate diea) Returns theDIEAggregateof a typedef that points to the specified datatype.Returns null if there is no typedef pointing to the specified DIEA or if there are multiple. - Parameters:
- diea-- DIEAggregateof a data type that might be the target of typedefs.
- Returns:
- DIEAggregateof the singular typedef that points to the arg, otherwise null if none or multiple found.
 
 
- 
 
-