Class DWARFDataTypeManager
-
Constructor Summary
ConstructorDescriptionDWARFDataTypeManager
(DWARFProgram prog, DataTypeManager dataTypeManager) Creates a newDWARFDataTypeManager
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDataType
(long offset, DataType dataType, DWARFSourceInfo dsi) doGetDataType
(DIEAggregate diea) Iterate allDataType
s that match the CategoryPath / name given in theDataTypePath
parameter, including "conflict" datatypes that have a ".CONFLICTxx" suffix.getBaseType
(String name) Returns a DWARF base data type based on its name, or null if it does not exist.getBaseType
(String name, int dwarfSize, int dwarfEncoding, boolean isBigEndian, boolean isExplictSize) Returns a Ghidradatatype
that corresponds to the DWARF named type.getDataType
(long dieOffset, DataType defaultValue) Returns a GhidraDataType
corresponding to the specified DIE (based on its offset), or the specified defaultValue if the DIE does not map to a defined datatype (registered withaddDataType(long, DataType, DWARFSourceInfo)
).getDataType
(DIEAggregate diea, DataType defaultValue) Returns a GhidraDataType
corresponding to the specifiedDIEAggregate
, or the specified defaultValue if the DIEA param is null or does not map to an already defined datatype (registered withaddDataType(long, DataType, DWARFSourceInfo)
).Construct a temporary 'impl'FunctionDefinition
DataType using the information found in the specifiedDIEAggregate
.getOffsetType
(int size) Returns a Ghidradatatype
that corresponds to a type that can be used to represent an offset.Returns a pointer to the specified data type.getSourceInfo
(DataType dataType) <T extends DataType>
TgetSpecificDataType
(DIEAggregate diea, Class<T> dataTypeClazz) Returns the void type.void
importAllDataTypes
(TaskMonitor monitor) Does the actual import work.
-
Constructor Details
-
DWARFDataTypeManager
Creates a newDWARFDataTypeManager
instance.- Parameters:
prog
-DWARFProgram
that holds the GhidraProgram
being imported.dataTypeManager
-DataTypeManager
of the Ghidra Program.
-
-
Method Details
-
doGetDataType
Creates aDataType
from the DWARFDIEA
, or returns a pre-existingDataType
created by the specified DIEA previously.Creating a new DataType happens in two stages, where the DataType is created as an 'impl' DataType first (possibly representing a large graph of referred-to datatypes), and then it is submitted to the
DataTypeManager
to be added to the database and converted to a 'db' object.Mapping from the DIEA's offset to the resultant 'db' DataType object is a two step process.
A
DataTypeGraphComparator
is used to walk the 'impl' DataType object graph in lock-step with the resultant 'db' DataType object graph, and the mapping between the 'impl' object and its creator DIEA (held inDWARFDataTypeImporter.DWARFDataType
) is used to create a mapping to the resultant 'db' DataType's path.- Parameters:
diea
- DWARFDIEAggregate
with datatype information that needs to be converted to a Ghidra DataType.- Returns:
DataType
that is ready to use.- Throws:
IOException
- if problemDWARFExpressionException
- if problem
-
addDataType
-
getImportedTypes
-
getSourceInfo
-
getDataType
Returns a GhidraDataType
corresponding to the specifiedDIEAggregate
, or the specified defaultValue if the DIEA param is null or does not map to an already defined datatype (registered withaddDataType(long, DataType, DWARFSourceInfo)
).- Parameters:
diea
-DIEAggregate
that defines a data typedefaultValue
- GhidraDataType
to return if the specified DIEA is null or not already defined.- Returns:
- Ghidra
DataType
-
getDataType
Returns a GhidraDataType
corresponding to the specified DIE (based on its offset), or the specified defaultValue if the DIE does not map to a defined datatype (registered withaddDataType(long, DataType, DWARFSourceInfo)
). -
getSpecificDataType
-
getDataTypeForVariable
-
getPtrTo
Returns a pointer to the specified data type. -
getPtrTo
-
forAllConflicts
Iterate allDataType
s that match the CategoryPath / name given in theDataTypePath
parameter, including "conflict" datatypes that have a ".CONFLICTxx" suffix.- Parameters:
dtp
-- Returns:
-
getOffsetType
Returns a Ghidradatatype
that corresponds to a type that can be used to represent an offset.- Parameters:
size
-- Returns:
-
getVoidType
Returns the void type.- Returns:
- void
DataType
-
getBaseType
Returns a DWARF base data type based on its name, or null if it does not exist.- Parameters:
name
- base type name- Returns:
DataType
or null if base type does not exist
-
getBaseType
public DataType getBaseType(String name, int dwarfSize, int dwarfEncoding, boolean isBigEndian, boolean isExplictSize) Returns a Ghidradatatype
that corresponds to the DWARF named type.If there is no direct matching named Ghidra type, generic types of matching size will be returned for integer and floating numeric dwarf encoding types, boolean, and character types. Failing that, generic storage types of matching size (word, dword, etc) will be returned, and failing that, an array of the correct size will be returned.
If the returned data type is not a direct named match, the returned data type will be wrapped in a Ghidra typedef using the dwarf type's name.
Any newly created Ghidra data types will be cached and the same instance will be returned if the same DWARF named base type is requested again.
- Parameters:
name
-dwarfSize
-dwarfEncoding
-isBigEndian
-isExplictSize
- boolean flag, if true the returned data type will not be linked to the dataOrganization's compiler specified data types (eg. if type is something like int32_t, the returned type should never change size, even if the dataOrg changes). If false, the returned type will be linked to the dataOrg's compiler specified data types if possible, except for data types that have a name that include a bitsize in the name, such as "int64_t".- Returns:
-
importAllDataTypes
public void importAllDataTypes(TaskMonitor monitor) throws IOException, DWARFException, CancelledException Does the actual import work. Updates thesummary
object with information about the types imported and errors encountered.- Parameters:
monitor
- to watch for cancel- Throws:
IOException
- if errors are encountered reading dataDWARFException
- if errors are encountered processingCancelledException
- if theTaskMonitor
is canceled by the user.
-
getFunctionSignature
Construct a temporary 'impl'FunctionDefinition
DataType using the information found in the specifiedDIEAggregate
.- Parameters:
diea
-DIEAggregate
of a subprogram, callsite, etc.- Returns:
FunctionDefinition
impl (not saved to the DB) or null if not a valid DIEA.
-