Package ghidra.program.util
Class ListingDiff
java.lang.Object
ghidra.program.util.ListingDiff
Determines where instructions couldn't be matched and where they differ between sets of 
 addresses as provided by a ListingAddressCorrelation. Initially this will be byte 
 differences and instruction operand differences for any instructions that were determined 
 to be matched.
 
Important: This class is not intended to be used for an entire program. Instead it is for comparing smaller portions such as functions. If the correlation handed to this class associates two large address sets, then the address sets, such as byte differences, that are created by this class could potentially consume large amounts of memory.
Important: This class is not intended to be used for an entire program. Instead it is for comparing smaller portions such as functions. If the correlation handed to this class associates two large address sets, then the address sets, such as byte differences, that are created by this class could potentially consume large amounts of memory.
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a ListingDiff to determine where instructions couldn't be matched and where they differ between sets of addresses as provided by a ListingAddressCorrelation.
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdds the indicated listener to those that get notified when the ListingDiff's set of differences and unmatched addresses changes.booleandoesEntireOperandSetDiffer(CodeUnit codeUnit1, CodeUnit codeUnit2) Determines if the entire set of operands should indicate that it differs.getByteDiffs(Duo.Side side) Gets the addresses in the first listing where byte differences were found based on the current difference settings.getCodeUnitDiffs(Duo.Side side) Gets the addresses in the first listing where code unit (mnemonic and/or operand) differences were found based on the current difference settings.Gets the addresses in the first listing where differences were found based on the current difference settings.getMatchingAddress(Address address, boolean isListing1) Gets the matching address from the other listing for the specified address from one of the two listings whose differences this class determines.getMatchingCodeUnit(CodeUnit codeUnit, Duo.Side side) Gets the matching code unit from the other side listing given a code unit from a given side of the two listings whose differences this class determines.int[]getOperandsThatDiffer(CodeUnit codeUnit1, CodeUnit codeUnit2) Gets an array containing the operand indices where the two indicated code units differ.getUnmatchedCode(Duo.Side side) Gets the address set for unmatched code for the given side second listing.booleanDetermines if this ListingDiff currently has an address correlation to use.booleanGets the setting indicating if byte differences are currently being ignored.booleanGets the setting indicating if values of operand constants that differ are currently being ignored when determining code unit differences.booleanGets the setting indicating if operand registers that differ other than in size are currently being ignored when determining code unit differences.voidOutputs an information message, primarily for debugging, that indicates where code was unmatched with the other listing and where various differences, such as bytes and code units, were found.voidRemoves the indicated listener from those that get notified when the ListingDiff's set of differences and unmatched addresses changes.voidsetCorrelation(ListingAddressCorrelation correlation) Sets the address correlation that is used to determine matching addresses between the two listings.voidsetIgnoreByteDiffs(boolean ignore) Changes the setting indicating whether or not byte differences should be ignored.voidsetIgnoreConstants(boolean ignore) Changes the setting indicating if values of operand constants that differ should be ignored when determining code unit differences.voidsetIgnoreRegisters(boolean ignore) Changes the setting indicating if operand registers that differ other than in size should be ignored when determining code unit differences.
- 
Constructor Details- 
ListingDiffpublic ListingDiff()Creates a ListingDiff to determine where instructions couldn't be matched and where they differ between sets of addresses as provided by a ListingAddressCorrelation.
 
- 
- 
Method Details- 
setCorrelationSets the address correlation that is used to determine matching addresses between the two listings. Differences can then be determined where a matching address is found.
 Important: This class is not intended to be used for an entire program. Instead it is for comparing smaller portions such as functions. If the correlation handed to this class associates two large address sets, then the address sets, such as byte differences, that are created by this class could potentially consume large amounts of memory.- Parameters:
- correlation- the address correlation. Otherwise, null to clear the correlation.
- Throws:
- MemoryAccessException- if memory can't be read.
 
- 
hasCorrelationpublic boolean hasCorrelation()Determines if this ListingDiff currently has an address correlation to use.- Returns:
- true if it has an address correlation currently.
 
- 
getOperandsThatDifferGets an array containing the operand indices where the two indicated code units differ. These differences are determined based on whether constants and registers are being ignored.- Parameters:
- codeUnit1- the first code unit
- codeUnit2- the second code unit
- Returns:
- an array of operand indices where the operands differ between the two code units based on the current settings that indicate what differences can be ignored.
 
- 
doesEntireOperandSetDifferDetermines if the entire set of operands should indicate that it differs. If the code units aren't the same type then the entire set of operands is considered different. Also if the number of operands differs then as far as we're concerned the entire set differs.- Parameters:
- codeUnit1- the first code unit
- codeUnit2- the second code unit
- Returns:
- true if we should indicate that all operands differ.
 
- 
getUnmatchedCodeGets the address set for unmatched code for the given side second listing.- Parameters:
- side- the LEFT or RIGHT side
- Returns:
- the addresses of the unmatched code in the first listing.
 
- 
getDiffsGets the addresses in the first listing where differences were found based on the current difference settings.- Parameters:
- side- the side (LEFT or RIGHT) to get the listing diffs for
- Returns:
- the addresses with differences in the first listing.
 
- 
getCodeUnitDiffsGets the addresses in the first listing where code unit (mnemonic and/or operand) differences were found based on the current difference settings.- Parameters:
- side- the side (LEFT or RIGHT) to get the code unit diffs for
- Returns:
- the addresses with code unit differences in the first listing.
 
- 
getByteDiffsGets the addresses in the first listing where byte differences were found based on the current difference settings.- Parameters:
- side- the side (LEFT or RIGHT) to get the byte diffs for
- Returns:
- the addresses with byte differences in the first listing.
 
- 
getMatchingAddressGets the matching address from the other listing for the specified address from one of the two listings whose differences this class determines.- Parameters:
- address- the address whose matching address this determines.
- isListing1- true indicates the address is from the first listing. false indicates it is from the second listing.
- Returns:
- the matching address or null
 
- 
printFunctionComparisonDiffspublic void printFunctionComparisonDiffs()Outputs an information message, primarily for debugging, that indicates where code was unmatched with the other listing and where various differences, such as bytes and code units, were found.
- 
isIgnoringByteDiffspublic boolean isIgnoringByteDiffs()Gets the setting indicating if byte differences are currently being ignored.- Returns:
- true if byte differences are being ignored.
 
- 
setIgnoreByteDiffspublic void setIgnoreByteDiffs(boolean ignore) Changes the setting indicating whether or not byte differences should be ignored.- Parameters:
- ignore- true indicates to ignore byte differences
 
- 
isIgnoringConstantspublic boolean isIgnoringConstants()Gets the setting indicating if values of operand constants that differ are currently being ignored when determining code unit differences.- Returns:
- true if code unit differences are ignoring differences in values of operand constants.
 
- 
setIgnoreConstantspublic void setIgnoreConstants(boolean ignore) Changes the setting indicating if values of operand constants that differ should be ignored when determining code unit differences.- Parameters:
- ignore- true means code unit differences should ignore differences in values of operand constants.
 
- 
isIgnoringRegisterspublic boolean isIgnoringRegisters()Gets the setting indicating if operand registers that differ other than in size are currently being ignored when determining code unit differences.- Returns:
- true if code unit differences are ignoring operand register differences other than in size.
 
- 
setIgnoreRegisterspublic void setIgnoreRegisters(boolean ignore) Changes the setting indicating if operand registers that differ other than in size should be ignored when determining code unit differences.- Parameters:
- ignore- true means code unit differences should ignore operand register differences other than in size.
 
- 
addListingDiffChangeListenerAdds the indicated listener to those that get notified when the ListingDiff's set of differences and unmatched addresses changes.- Parameters:
- listener- the listener to be notified
 
- 
removeListingDiffChangeListenerRemoves the indicated listener from those that get notified when the ListingDiff's set of differences and unmatched addresses changes.- Parameters:
- listener- the listener to be removed
 
- 
getMatchingCodeUnitGets the matching code unit from the other side listing given a code unit from a given side of the two listings whose differences this class determines.- Parameters:
- codeUnit- the code unit whose match this determines.
- side- the side the code unit came from
- Returns:
- the matching code unit or null
 
 
-