mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-01-10 14:38:02 -05:00
Merge branch 'GP-5111_dev747368_dtm_pointer_filter--SQUASHED'
This commit is contained in:
@@ -134,16 +134,23 @@ public class DtFilterState {
|
||||
return true;
|
||||
}
|
||||
|
||||
DataType baseDt = DataTypeUtils.getBaseDataType(dt);
|
||||
|
||||
if (dt instanceof Array) {
|
||||
return passes(arraysFilter, dt);
|
||||
}
|
||||
|
||||
if (dt instanceof Pointer) {
|
||||
if (dt instanceof Pointer ptrDt) {
|
||||
if (ptrDt.getDataType() == null) {
|
||||
// special check for a pointer data type that is equivalent to the
|
||||
// built-in base "pointer" data type ("pointer" does not have a target type).
|
||||
// Returning 'true' here allows this data type to bypass the filter just like
|
||||
// builtin int/float types will at the bottom of this method.
|
||||
return true;
|
||||
}
|
||||
return passes(pointersFilter, dt);
|
||||
}
|
||||
|
||||
DataType baseDt = DataTypeUtils.getBaseDataType(dt);
|
||||
|
||||
if (baseDt instanceof Enum) {
|
||||
return passes(enumsFilter, dt);
|
||||
}
|
||||
|
||||
@@ -147,15 +147,17 @@ public class DataTypeDropDownSelectionDataModel implements DropDownTextFieldData
|
||||
// another dtm. In the second step, duplicate data types will be omitted from the
|
||||
// final results, in favor of the data type that is already in the preferred dtm.
|
||||
Set<UniversalID> preferredUids = new HashSet<>();
|
||||
Set<Class<?>> preferredBuiltins = new HashSet<>();
|
||||
Set<String> preferredBuiltinNames = new HashSet<>();
|
||||
for (DataType dt : dtList) {
|
||||
DataType baseDt = DataTypeUtilities.getBaseDataType(dt);
|
||||
// only look at data types that are already in the preferred DTM
|
||||
DataType baseDt = Objects.requireNonNullElse(DataTypeUtilities.getBaseDataType(dt), dt);
|
||||
if (!isFromPreferredDtm(baseDt)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (baseDt instanceof BuiltInDataType) {
|
||||
preferredBuiltins.add(baseDt.getClass());
|
||||
if (isBuiltinDataType(baseDt)) {
|
||||
// add any builtin data types that are already in the pref DTM to this exclude list
|
||||
preferredBuiltinNames.add(baseDt.getName());
|
||||
}
|
||||
else if (baseDt.getUniversalID() != null) {
|
||||
preferredUids.add(baseDt.getUniversalID());
|
||||
@@ -167,14 +169,14 @@ public class DataTypeDropDownSelectionDataModel implements DropDownTextFieldData
|
||||
if (dt instanceof Array) {
|
||||
continue;
|
||||
}
|
||||
DataType baseDt = DataTypeUtilities.getBaseDataType(dt);
|
||||
DataType baseDt =
|
||||
Objects.requireNonNullElse(DataTypeUtilities.getBaseDataType(dt), dt);
|
||||
if (baseDt == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preferredDtm != null && !isFromPreferredDtm(baseDt)) {
|
||||
if (baseDt instanceof BuiltInDataType &&
|
||||
preferredBuiltins.contains(baseDt.getClass())) {
|
||||
if (isBuiltinDataType(baseDt) && preferredBuiltinNames.contains(baseDt.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (baseDt.getUniversalID() != null &&
|
||||
@@ -204,6 +206,14 @@ public class DataTypeDropDownSelectionDataModel implements DropDownTextFieldData
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isBuiltinDataType(DataType dt) {
|
||||
// check for normal builtin data types, as well as any pointer (which will probably be a
|
||||
// DataTypeDB that does not derive from Builtin) that does not point to anything.
|
||||
// This ptr data type is equiv to the "pointer" built-in data type.
|
||||
return dt instanceof BuiltInDataType ||
|
||||
(dt instanceof Pointer ptrDT && ptrDT.getDataType() == null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndexOfFirstMatchingEntry(List<DataType> data, String text) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user