Ghidra is a software reverse engineering (SRE) framework
GT-2706 Fixed exceptions in Diff View
ghidra5e75c28afd679
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/program/util/DiffUtility.java b/Ghidra/Features/Base/src/main/java/ghidra/program/util/DiffUtility.javaindex 7b4d9cbf4d..8d8c87e32a 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/program/util/DiffUtility.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/program/util/DiffUtility.java@@ -193,11 +193,11 @@ public class DiffUtility extends SimpleDiffUtility {return otherProgram.getSymbolTable().createExternalLibrary(namespace.getName(), source);}else if (namespace instanceof GhidraClass) {- return otherProgram.getSymbolTable().createClass(otherParentNamespace,- namespace.getName(), source);+ return otherProgram.getSymbolTable()+ .createClass(otherParentNamespace, namespace.getName(), source);}- return otherProgram.getSymbolTable().createNameSpace(otherParentNamespace,- namespace.getName(), source);+ return otherProgram.getSymbolTable()+ .createNameSpace(otherParentNamespace, namespace.getName(), source);}// /**@@ -329,11 +329,11 @@ public class DiffUtility extends SimpleDiffUtility {if (toAddr == null) {return null;}- return otherProgram.getReferenceManager().getReference(fromAddr, toAddr,- ref.getOperandIndex());+ return otherProgram.getReferenceManager()+ .getReference(fromAddr, toAddr, ref.getOperandIndex());}- Reference otherRef = otherProgram.getReferenceManager().getPrimaryReferenceFrom(fromAddr,- ref.getOperandIndex());+ Reference otherRef = otherProgram.getReferenceManager()+ .getPrimaryReferenceFrom(fromAddr, ref.getOperandIndex());if (otherRef != null && ref.getToAddress().hasSameAddressSpace(otherRef.getToAddress())) {return otherRef;}@@ -357,11 +357,11 @@ public class DiffUtility extends SimpleDiffUtility {if (toAddr1 == null) {return null;}- return program.getReferenceManager().getReference(fromAddr1, toAddr1,- p2Ref.getOperandIndex());+ return program.getReferenceManager()+ .getReference(fromAddr1, toAddr1, p2Ref.getOperandIndex());}- Reference p1Ref = program.getReferenceManager().getPrimaryReferenceFrom(fromAddr1,- p2Ref.getOperandIndex());+ Reference p1Ref = program.getReferenceManager()+ .getPrimaryReferenceFrom(fromAddr1, p2Ref.getOperandIndex());if (p1Ref != null && p1Ref.getToAddress().hasSameAddressSpace(p2Ref.getToAddress())) {return p1Ref;}@@ -385,8 +385,9 @@ public class DiffUtility extends SimpleDiffUtility {otherAddr = getCompatibleAddress(program, addr, otherProgram);}// FIXME Should this be passing the Namespace?- return otherProgram.getExternalManager().addExtLocation(extLoc.getLibraryName(),- extLoc.getLabel(), otherAddr, extLoc.getSource());+ return otherProgram.getExternalManager()+ .addExtLocation(extLoc.getLibraryName(), extLoc.getLabel(), otherAddr,+ extLoc.getSource());}/**@@ -707,6 +708,9 @@ public class DiffUtility extends SimpleDiffUtility {Address refAddress = getCompatibleAddress(program, location.refAddr, otherProgram);if (address != null) {+ if (byteAddress == null) {+ byteAddress = address; // Make sure the byte address isn't null.+ }ProgramLocation otherLocation = new ProgramLocation(otherProgram, address, byteAddress,location.getComponentPath(), refAddress, 0, 0, 0);return otherLocation;diff --git a/Ghidra/Features/Base/src/main/java/ghidra/program/util/ProgramDiffDetails.java b/Ghidra/Features/Base/src/main/java/ghidra/program/util/ProgramDiffDetails.javaindex d0cb2dfefd..751d08d165 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/program/util/ProgramDiffDetails.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/program/util/ProgramDiffDetails.java@@ -2555,7 +2555,7 @@ public class ProgramDiffDetails {}private void addColorAddress(StyledDocument doc, Address addr) {- String text = addr.toString();+ String text = (addr != null) ? addr.toString() : "no matching address";color(ADDRESS_COLOR);try {doc.insertString(doc.getLength(), text, textAttrSet);diff --git a/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/ProgramDiffPlugin.java b/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/ProgramDiffPlugin.javaindex 9240662b1a..04183ab7cd 100644--- a/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/ProgramDiffPlugin.java+++ b/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/ProgramDiffPlugin.java@@ -441,6 +441,9 @@ public class ProgramDiffPlugin extends ProgramPluginAddress primaryByteAddr = SimpleDiffUtility.getCompatibleAddress(secondaryDiffProgram,byteAddr, primaryProgram);+ if (primaryByteAddr == null) {+ primaryByteAddr = primaryAddr; // Make sure the byte address isn't null.+ }Address primaryRefAddr = SimpleDiffUtility.getCompatibleAddress(secondaryDiffProgram,refAddr, primaryProgram);ProgramLocation newP1Location = new ProgramLocation(primaryProgram, primaryAddr,@@ -463,7 +466,9 @@ public class ProgramDiffPlugin extends ProgramPlugin}ProgramLocation previousP1LocationAsP2 = DiffUtility.getCompatibleProgramLocation(primaryProgram, location, secondaryDiffProgram);- diffListingPanel.setCursorPosition(previousP1LocationAsP2);+ if (previousP1LocationAsP2 != null) {+ diffListingPanel.setCursorPosition(previousP1LocationAsP2);+ }if (diffDetailsProvider != null && diffDetails != null) {diffDetailsProvider.locationChanged(previousP1Location);}@@ -749,7 +754,7 @@ public class ProgramDiffPlugin extends ProgramPluginrunSwing(() -> {MarkerSet selectionMarkers = getSelectionMarkers();selectionMarkers.clearAll();- selectionMarkers.add(p2SelectionAsP1);+ selectionMarkers.add(p2Selection);});diffListingPanel.setSelection(p2SelectionAsP1);@@ -798,9 +803,9 @@ public class ProgramDiffPlugin extends ProgramPlugin// Limit the apply to the selection in the view.AddressSet p2SelectionAsP1 =DiffUtility.getCompatibleAddressSet(p2Selection, primaryProgram);- AddressSet p1ApplySet =- p2SelectionAsP1.intersect(p1ViewAddrSet).subtract(addressesOnlyInP1).subtract(- compatibleOnlyInP2);+ AddressSet p1ApplySet = p2SelectionAsP1.intersect(p1ViewAddrSet)+ .subtract(addressesOnlyInP1)+ .subtract(compatibleOnlyInP2);if (p1ApplySet.isEmpty()) {Msg.showInfo(getClass(), tool.getToolFrame(), "Apply Differences",(p2Selection.isEmpty()) ? "No diff selection in the current view."@@ -860,7 +865,7 @@ public class ProgramDiffPlugin extends ProgramPlugin// Right side markers need p1 addresses since they use p1 indexMap.MarkerSet diffMarkers = getDiffMarkers(); // Get right side markers for program 2.diffMarkers.clearAll();- diffMarkers.add(p2DiffSetAsP1);+ diffMarkers.add(p2DiffSet);MarkerSet codeViewerDiffMarkers = getCodeViewerMarkers(); // Get left side markers for program 1.codeViewerDiffMarkers.clearAll();@@ -884,7 +889,7 @@ public class ProgramDiffPlugin extends ProgramPluginAddressSet p1DiffHighlightSet =DiffUtility.getCompatibleAddressSet(p2Highlight, primaryProgram);p2DiffHighlight = p2Highlight;- diffMarkers.add(p1DiffHighlightSet);+ diffMarkers.add(p2Highlight);codeViewerDiffMarkers.add(p1DiffHighlightSet);}@@ -1603,7 +1608,14 @@ public class ProgramDiffPlugin extends ProgramPlugindiffListingPanel.goTo(currentLocation);MarkerSet cursorMarkers = getCursorMarkers();- cursorMarkers.setAddressSet(new AddressSet(currentLocation.getAddress()));+ Address currentP2Address = currentLocation.getAddress();+ if (currentLocation.getProgram() != secondaryDiffProgram) { // Make sure address is from P2.+ currentP2Address = SimpleDiffUtility.getCompatibleAddress(currentLocation.getProgram(),+ currentLocation.getAddress(), secondaryDiffProgram);+ }+ if (currentP2Address != null) {+ cursorMarkers.setAddressSet(new AddressSet(currentP2Address));+ }updatePgm2Enablement();