diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingTask.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingTask.java index 4aa0437ee0..3bba2d3522 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingTask.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingTask.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -235,7 +235,6 @@ public class AutoVersionTrackingTask extends Task { monitor.doIncrementProgress(); } - // This is the first of the "speculative" post-correlator match algorithm. The correlator // returns all duplicate function instruction matches so there will always be more // than one possible match for each function. The compare mechanism used by the @@ -255,7 +254,7 @@ public class AutoVersionTrackingTask extends Task { // if Auto VT min function length for dupe matches is different than current // exact instruction match setting temporarily change it for auto VT run int dupFunctionMinLen = - toolOptions.getInt(VTOptionDefines.DUPE_FUNCTION_CORRELATOR_MIN_LEN_OPTION, 10); + toolOptions.getInt(VTOptionDefines.DUPE_FUNCTION_CORRELATOR_MIN_LEN_OPTION, 25); vtOptions.setInt( ExactMatchInstructionsProgramCorrelatorFactory.FUNCTION_MINIMUM_SIZE, @@ -279,9 +278,10 @@ public class AutoVersionTrackingTask extends Task { toolOptions.getBoolean(VTOptionDefines.RUN_REF_CORRELATORS_OPTION, true); if (runRefCorrelators) { - double minScore = toolOptions.getDouble(VTOptionDefines.REF_CORRELATOR_MIN_SCORE_OPTION, 0.95); - double minConf = toolOptions.getDouble(VTOptionDefines.REF_CORRELATOR_MIN_CONF_OPTION, 10.0); - + double minScore = + toolOptions.getDouble(VTOptionDefines.REF_CORRELATOR_MIN_SCORE_OPTION, 0.95); + double minConf = + toolOptions.getDouble(VTOptionDefines.REF_CORRELATOR_MIN_CONF_OPTION, 10.0); // Get the number of data and function matches int numDataMatches = getNumberOfDataMatches(monitor); @@ -497,32 +497,31 @@ public class AutoVersionTrackingTask extends Task { int minVoteCountNeeded, int maxConflictsAllowed, TaskMonitor monitor) throws CancelledException { - Set goodImpliedMatches = new HashSet<>(); for (VTMatch match : matchesToProcess) { - monitor.checkCancelled(); + monitor.checkCancelled(); - VTAssociation association = match.getAssociation(); + VTAssociation association = match.getAssociation(); - // skip if already accepted or blocked match - if (association.getStatus() != VTAssociationStatus.AVAILABLE) { - continue; - } + // skip if already accepted or blocked match + if (association.getStatus() != VTAssociationStatus.AVAILABLE) { + continue; + } - // skip if there are any conflicting associations - int numConflicts = association.getRelatedAssociations().size() - 1; - if (numConflicts > maxConflictsAllowed) { - continue; - } + // skip if there are any conflicting associations + int numConflicts = association.getRelatedAssociations().size() - 1; + if (numConflicts > maxConflictsAllowed) { + continue; + } - int voteCount = association.getVoteCount(); + int voteCount = association.getVoteCount(); - if (voteCount >= minVoteCountNeeded) { - goodImpliedMatches.add(match); - } + if (voteCount >= minVoteCountNeeded) { + goodImpliedMatches.add(match); + } - monitor.incrementProgress(); + monitor.incrementProgress(); } return goodImpliedMatches; @@ -893,7 +892,6 @@ public class AutoVersionTrackingTask extends Task { return null; } - /** * From the given related association, ie a group of src/dest pairs of functions with identical * instructions, use operand information to find any unique matches in the set. @@ -907,7 +905,6 @@ public class AutoVersionTrackingTask extends Task { Collection relatedAssociations, TaskMonitor monitor) throws CancelledException { - // create function to operand map maps for each source and destination function // in the given related associations (src/dst function pairs) Map>> sourceFunctionsMap = @@ -916,7 +913,6 @@ public class AutoVersionTrackingTask extends Task { Map>> destFunctionsMap = createFunctionsMap(relatedAssociations, false, monitor); - // only functions with scalar or address operands are mapped so the lists could be // empty if there are functions with no operand info to be mapped if (sourceFunctionsMap.isEmpty() || destFunctionsMap.isEmpty()) { @@ -1032,7 +1028,6 @@ public class AutoVersionTrackingTask extends Task { return functionsMap; } - /** * Using the given source function's map and a list of destination function maps, and a list * of destination functions to omit because they already have found matches, try to find a @@ -1214,7 +1209,6 @@ public class AutoVersionTrackingTask extends Task { */ private boolean hasAnyAssociations(Address source, Address dest) { - Collection sourceAssociations = session.getAssociationManager() .getRelatedAssociationsBySourceAddress(source); @@ -1261,7 +1255,6 @@ public class AutoVersionTrackingTask extends Task { throws CancelledException { Map> offsetToOperandsMap = new HashMap<>(); - Program program = function.getProgram(); @@ -1278,7 +1271,7 @@ public class AutoVersionTrackingTask extends Task { if (map.keySet().isEmpty()) { continue; } - + // get offset from top of function to use in function to operandMap map // can be positive or negative offset (positive means instruction address is after // the entry address, negative means instruction address is before entry address) diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/matchtable/VTMatchTableProvider.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/matchtable/VTMatchTableProvider.java index 9f51e72e06..a2b4ddc083 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/matchtable/VTMatchTableProvider.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/provider/matchtable/VTMatchTableProvider.java @@ -848,7 +848,7 @@ public class VTMatchTableProvider extends ComponentProviderAdapter .setOptionsHelpLocation( new HelpLocation(VTPlugin.HELP_TOPIC_NAME, "Auto_Version_Tracking_Options")); - vtOptions.registerOption(DUPE_FUNCTION_CORRELATOR_MIN_LEN_OPTION, 10, null, + vtOptions.registerOption(DUPE_FUNCTION_CORRELATOR_MIN_LEN_OPTION, 25, null, "Minimum Function Length of Auto Version Tracking Duplicate Function Correlator"); vtOptions.getOptions(DUPE_FUNCTION_CORRELATOR_MIN_LEN_OPTION) .setOptionsHelpLocation( diff --git a/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTAutoVersionTrackingTest.java b/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTAutoVersionTrackingTest.java index 6102c1a337..b4c43d8730 100644 --- a/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTAutoVersionTrackingTest.java +++ b/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTAutoVersionTrackingTest.java @@ -90,6 +90,8 @@ public class VTAutoVersionTrackingTest extends AbstractGhidraHeadedIntegrationTe vtOptions.setDouble(VTOptionDefines.REF_CORRELATOR_MIN_SCORE_OPTION, 0.999999999); vtOptions.setDouble(VTOptionDefines.REF_CORRELATOR_MIN_CONF_OPTION, 10.0); + //min was 10 when tests first written but have changed since so now need to set it manually + vtOptions.setInt(VTOptionDefines.DUPE_FUNCTION_CORRELATOR_MIN_LEN_OPTION, 10); runAutoVTCommand(vtOptions); @@ -155,6 +157,8 @@ public class VTAutoVersionTrackingTest extends AbstractGhidraHeadedIntegrationTe vtOptions.setDouble(VTOptionDefines.REF_CORRELATOR_MIN_SCORE_OPTION, 0.5); vtOptions.setDouble(VTOptionDefines.REF_CORRELATOR_MIN_CONF_OPTION, 1.0); + //min was 10 when tests first written but have changed since so now need to set it manually + vtOptions.setInt(VTOptionDefines.DUPE_FUNCTION_CORRELATOR_MIN_LEN_OPTION, 10); runAutoVTCommand(vtOptions); @@ -279,6 +283,8 @@ public class VTAutoVersionTrackingTest extends AbstractGhidraHeadedIntegrationTe vtOptions.setDouble(VTOptionDefines.REF_CORRELATOR_MIN_SCORE_OPTION, 1.0); vtOptions.setDouble(VTOptionDefines.REF_CORRELATOR_MIN_CONF_OPTION, 10.0); + //min was 10 when tests first written but have changed since so now need to set it manually + vtOptions.setInt(VTOptionDefines.DUPE_FUNCTION_CORRELATOR_MIN_LEN_OPTION, 10); runAutoVTCommand(vtOptions); @@ -329,6 +335,8 @@ public class VTAutoVersionTrackingTest extends AbstractGhidraHeadedIntegrationTe vtOptions.setDouble(VTOptionDefines.REF_CORRELATOR_MIN_SCORE_OPTION, 1.0); vtOptions.setDouble(VTOptionDefines.REF_CORRELATOR_MIN_CONF_OPTION, 10.0); + //min was 10 when tests first written but have changed since so now need to set it manually + vtOptions.setInt(VTOptionDefines.DUPE_FUNCTION_CORRELATOR_MIN_LEN_OPTION, 10); runAutoVTCommand(vtOptions); @@ -369,6 +377,8 @@ public class VTAutoVersionTrackingTest extends AbstractGhidraHeadedIntegrationTe vtOptions.setDouble(VTOptionDefines.REF_CORRELATOR_MIN_SCORE_OPTION, 1.0); vtOptions.setDouble(VTOptionDefines.REF_CORRELATOR_MIN_CONF_OPTION, 10.0); + //min was 10 when tests first written but have changed since so now need to set it manually + vtOptions.setInt(VTOptionDefines.DUPE_FUNCTION_CORRELATOR_MIN_LEN_OPTION, 10); runAutoVTCommand(vtOptions); @@ -442,6 +452,8 @@ public class VTAutoVersionTrackingTest extends AbstractGhidraHeadedIntegrationTe vtOptions.setDouble(VTOptionDefines.REF_CORRELATOR_MIN_SCORE_OPTION, 1.0); vtOptions.setDouble(VTOptionDefines.REF_CORRELATOR_MIN_CONF_OPTION, 10.0); + //min was 10 when tests first written but have changed since so now need to set it manually + vtOptions.setInt(VTOptionDefines.DUPE_FUNCTION_CORRELATOR_MIN_LEN_OPTION, 10); runAutoVTCommand(vtOptions); @@ -600,6 +612,8 @@ public class VTAutoVersionTrackingTest extends AbstractGhidraHeadedIntegrationTe vtOptions.setDouble(VTOptionDefines.REF_CORRELATOR_MIN_SCORE_OPTION, 1.0); vtOptions.setDouble(VTOptionDefines.REF_CORRELATOR_MIN_CONF_OPTION, 10.0); + //min was 10 when tests first written but have changed since so now need to set it manually + vtOptions.setInt(VTOptionDefines.DUPE_FUNCTION_CORRELATOR_MIN_LEN_OPTION, 10); runAutoVTCommand(vtOptions);