Package ghidra.app.util.bin.format.dwarf4.next

# Class DWARFDataTypeConflictHandler

java.lang.Object
ghidra.program.model.data.DataTypeConflictHandler
ghidra.app.util.bin.format.dwarf4.next.DWARFDataTypeConflictHandler

public class DWARFDataTypeConflictHandler extends DataTypeConflictHandler
This `conflict handler` attempts to match conflicting `composite data types` (structure or union) when they have compatible data layouts. (Data types that are exactly equiv will not be subjected to conflict handling and will never reach here)

A default/empty sized structure, or structures with the same size are candidates for matching.

Structures that have a subset of the other's field definition are candidates for matching.

When a candidate data type is matched with an existing data type, this conflict handler will specify that the new data type is:

- discarded and replaced by the existing data type (`DataTypeConflictHandler.ConflictResult.USE_EXISTING`)
- used to overwrite the existing data type (`DataTypeConflictHandler.ConflictResult.REPLACE_EXISTING`)

or the candidate data type was NOT matched with an existing data type, and the new data type is:

- kept, but renamed with a .conflictNNNN suffix to make it unique (`DataTypeConflictHandler.ConflictResult.RENAME_AND_ADD`)

NOTE: structures with alignment (instead of being statically laid out) are not treated specially and will not match other aligned or non-aligned structures.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class ghidra.program.model.data.DataTypeConflictHandler

  `DataTypeConflictHandler.ConflictResolutionPolicy, DataTypeConflictHandler.ConflictResult`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final DWARFDataTypeConflictHandler`
  `INSTANCE`

  ### Fields inherited from class ghidra.program.model.data.DataTypeConflictHandler

  `DEFAULT_HANDLER, KEEP_HANDLER, REPLACE_EMPTY_STRUCTS_OR_RENAME_AND_ADD_HANDLER, REPLACE_HANDLER`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `DataTypeConflictHandler`
  `getSubsequentHandler()`
  Returns the appropriate handler for recursive resolve calls.
  `DataTypeConflictHandler.ConflictResult`
  `resolveConflict(DataType addedDataType, DataType existingDataType)`
  Callback to handle conflicts in a datatype manager when new datatypes are added that have the same name as an existing datatype.
  `boolean`
  `shouldUpdate(DataType sourceDataType, DataType localDataType)`
  Callback invoked when an associated dataType is being resolved and its local version of the dataType is different from the source archive's dataType.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### INSTANCE

    public static final DWARFDataTypeConflictHandler INSTANCE

- ## Method Details

  - ### resolveConflict

    public DataTypeConflictHandler.ConflictResult resolveConflict(DataType addedDataType, DataType existingDataType)
    Description copied from class: `DataTypeConflictHandler`
    Callback to handle conflicts in a datatype manager when new datatypes are added that have the same name as an existing datatype. The implementer of this interface should do one of the following: return the addedDataType - which means to replace the existingDataType with the addedDataType (may throw exception if the datatypes are not compatible) return the existingDataType the addedDataType will be ignored and the existing dataType will be used. return a new DataType with a new name/category
    Specified by:
      `resolveConflict` in class `DataTypeConflictHandler`
    Parameters:
      `addedDataType` - the datatype being added.
      `existingDataType` - the datatype that exists with the same name/category as the one added
    Returns:
      an enum specify how to handle the conflict

  - ### shouldUpdate

    public boolean shouldUpdate(DataType sourceDataType, DataType localDataType)
    Description copied from class: `DataTypeConflictHandler`
    Callback invoked when an associated dataType is being resolved and its local version of the dataType is different from the source archive's dataType. This method returns true if the local version should be updated to the archive's version of the dataType. Otherwise, the local dataType will be used (without updating) in the resolve operation.
    Specified by:
      `shouldUpdate` in class `DataTypeConflictHandler`
    Returns:
      true if the localDataType should be updated to be equivalent to the sourceDataType.

  - ### getSubsequentHandler

    public DataTypeConflictHandler getSubsequentHandler()
    Description copied from class: `DataTypeConflictHandler`
    Returns the appropriate handler for recursive resolve calls.
    Specified by:
      `getSubsequentHandler` in class `DataTypeConflictHandler`