Merge remote-tracking branch 'origin/GT-3025-dragonmacher-operand-field-typedef-exception'

This commit is contained in:
Ryan Kurtz 2019-07-24 11:50:56 -04:00
commit d361b76b92
2 changed files with 39 additions and 7 deletions

View file

@ -23,7 +23,7 @@ import ghidra.program.model.listing.Program;
/**
* A class to signal that the ProgramLocation is used for data types and is not really
* connected to the listing. This is a subclass specifically for {@link Composite} types and a
* particular field name.
* particular field name of the given composite.
*
* @see GenericCompositeDataTypeLocationDescriptor
*/

View file

@ -80,7 +80,7 @@ public final class ReferenceUtils {
* @param accumulator The Accumulator into which LocationReferences will be placed.
* @param location The location for which to find references
* @param monitor the task monitor used to track progress and cancel the work
* @throws CancelledException
* @throws CancelledException if the operation was cancelled
*/
public static void getReferences(Accumulator<LocationReference> accumulator,
ProgramLocation location, TaskMonitor monitor) throws CancelledException {
@ -104,7 +104,7 @@ public final class ReferenceUtils {
* @param location the location for which to find references
* @param monitor the task monitor used to track progress and cancel the work
* @return A set of addresses or an empty set if there are no references.
* @throws CancelledException
* @throws CancelledException if the operation was cancelled
*/
public static Set<Address> getReferenceAddresses(ProgramLocation location, TaskMonitor monitor)
throws CancelledException {
@ -122,7 +122,7 @@ public final class ReferenceUtils {
* @param accumulator the results accumulator
* @param location the location for which to find references
* @param monitor the task monitor used to track progress and cancel the work
* @throws CancelledException
* @throws CancelledException if the operation was cancelled
*/
private static void getReferenceAddresses(Accumulator<Address> accumulator,
ProgramLocation location, TaskMonitor monitor) throws CancelledException {
@ -319,7 +319,7 @@ public final class ReferenceUtils {
/**
* A recursive function to get the base highest level data type for the given data type. For
* example, if the give data type is an {@link Array}, then this
* method will be called again in its data type.
* method will be called again on its data type.
* <p>
* It is not always appropriate to find the base data type. This method contains the
* logic for determining when it is appropriate the seek out the
@ -348,6 +348,38 @@ public final class ReferenceUtils {
return dataType;
}
/**
* A recursive function to get the base highest level data type for the given data type. For
* example, if the give data type is an {@link Array}, then this
* method will be called again on its data type.
* <p>
* It is not always appropriate to find the base data type. This method contains the
* logic for determining when it is appropriate the seek out the
* base data type, as in the case of an Array object.
*
* @param dataType The data type for which to find the highest level data type
* @param includeTypedefs if true, then Typedef data types will be replaced with their base
* data type
* @return The highest level data type for the given data type
* @see #getBaseDataType(DataType)
*/
public static DataType getBaseDataType(DataType dataType, boolean includeTypedefs) {
if (dataType instanceof Array) {
return getBaseDataType(((Array) dataType).getDataType());
}
else if (dataType instanceof Pointer) {
DataType baseDataType = ((Pointer) dataType).getDataType();
if (baseDataType != null) {
return getBaseDataType(baseDataType);
}
}
else if (dataType instanceof TypeDef) {
DataType baseDataType = ((TypeDef) dataType).getBaseDataType();
return getBaseDataType(baseDataType);
}
return dataType;
}
/**
* Gets all variables for the given function including all parameters and local variables.
* @param function The function from which to get the variables
@ -800,7 +832,7 @@ public final class ReferenceUtils {
*/
private static DataType findLeafDataType(DataType parent, Stack<String> path) {
DataType baseParent = getBaseDataType(parent);
DataType baseParent = getBaseDataType(parent, true);
if (path.isEmpty()) {
return baseParent; // this must be the one
}
@ -949,7 +981,7 @@ public final class ReferenceUtils {
* @param dataMatcher the predicate that determines a successful match
* @param fieldName the optional field name for which to search
* @param monitor the task monitor used to track progress and cancel the work
* @throws CancelledException
* @throws CancelledException if the operation was cancelled
*/
public static void findDataTypeMatchesInDefinedData(Accumulator<LocationReference> accumulator,
Program program, Predicate<Data> dataMatcher, String fieldName, TaskMonitor monitor)