GP-3903 Refactor of OverlayAddressSpaces to allow multiple blocks within

the same overlay space
This commit is contained in:
ghidra1 2023-10-18 21:55:59 -04:00
parent 7e4d2bcfaa
commit 0f95d266c3
80 changed files with 3383 additions and 1757 deletions

View file

@ -300,9 +300,8 @@ public class ProgramDiffPlugin extends ProgramPlugin
DiffUtility.getCompatibleAddressSet(p1AddressSet, secondaryDiffProgram);
AddressIndexMap p2IndexMap = new AddressIndexMap(p1AddressSetAsP2);
markerManager.getOverviewProvider().setProgram(secondaryDiffProgram, p2IndexMap);
fp.setBackgroundColorModel(
new MarkerServiceBackgroundColorModel(markerManager, secondaryDiffProgram,
p2IndexMap));
fp.setBackgroundColorModel(new MarkerServiceBackgroundColorModel(markerManager,
secondaryDiffProgram, p2IndexMap));
currentSelection = previousP1Selection;
p2DiffHighlight = previousP2DiffHighlight;
@ -1062,9 +1061,7 @@ public class ProgramDiffPlugin extends ProgramPlugin
setProgram2Selection(p2Selection);
clearDiff();
if (secondaryDiffProgram != null) {
Iterator<BookmarkNavigator> iter = bookmarkMap.values().iterator();
while (iter.hasNext()) {
BookmarkNavigator nav = iter.next();
for (BookmarkNavigator nav : bookmarkMap.values()) {
nav.dispose();
}
bookmarkMap.clear();
@ -1140,6 +1137,10 @@ public class ProgramDiffPlugin extends ProgramPlugin
}
private void selectAndOpenProgram2() {
if (checkStaleOverlays(currentProgram)) {
return;
}
final OpenVersionedFileDialog<Program> dialog = getOpenVersionedFileDialog();
List<Program> openProgramList = getOpenProgramList();
@ -1161,6 +1162,30 @@ public class ProgramDiffPlugin extends ProgramPlugin
dialog.showComponent();
}
private boolean hasStaleOverlays(Program p) {
return p.getAddressFactory().hasStaleOverlayCondition();
}
/**
* Check program's address factory for stale overlay condition.
* @param p program to check
* @return true if user chose to cancel operation due to stale overlays
*/
private boolean checkStaleOverlays(Program p) {
if (!hasStaleOverlays(p)) {
return false;
}
String usage = (p == currentProgram) ? "current" : "selected";
int rc = OptionDialog.showOptionDialogWithCancelAsDefaultButton(null, "Diff Warning",
"The " + usage +
" program has recently had an overlay space renamed which may prevent an accurate Diff.\n" +
"It is recommended that the program be closed and re-opened before performing Diff.",
"Continue");
return (rc != OptionDialog.OPTION_ONE);
}
private OpenVersionedFileDialog<Program> getOpenVersionedFileDialog() {
if (openVersionedFileDialog != null) {
@ -1567,6 +1592,11 @@ public class ProgramDiffPlugin extends ProgramPlugin
newProgram.release(this);
return false;
}
if (!hasStaleOverlays(currentProgram) && checkStaleOverlays(newProgram)) {
return false;
}
ProgramMemoryComparator programMemoryComparator = null;
try {
programMemoryComparator = new ProgramMemoryComparator(currentProgram, newProgram);
@ -1629,14 +1659,19 @@ public class ProgramDiffPlugin extends ProgramPlugin
secondaryDiffProgram);
actionManager.secondProgramOpened();
actionManager.addActions();
diffListingPanel.goTo(currentLocation);
MarkerSet cursorMarkers = getCursorMarkers();
Address currentP2Address = currentLocation.getAddress();
ProgramLocation current2PLocation = currentLocation;
if (currentLocation.getProgram() != secondaryDiffProgram) { // Make sure address is from P2.
currentP2Address = SimpleDiffUtility.getCompatibleAddress(currentLocation.getProgram(),
currentLocation.getAddress(), secondaryDiffProgram);
if (currentP2Address != null) {
current2PLocation = ProgramLocation.getTranslatedCopy(currentLocation,
secondaryDiffProgram, currentP2Address);
}
}
diffListingPanel.goTo(current2PLocation);
if (currentP2Address != null) {
cursorMarkers.setAddressSet(new AddressSet(currentP2Address));
}
@ -1812,10 +1847,11 @@ public class ProgramDiffPlugin extends ProgramPlugin
return;
}
ListingField lf = (ListingField) field;
FieldFactory factory = lf.getFieldFactory();
ProgramLocation pLoc =
factory.getProgramLocation(location.getRow(), location.getCol(), lf);
ProgramLocation pLoc = null;
if (field instanceof ListingField lf) {
FieldFactory factory = lf.getFieldFactory();
pLoc = factory.getProgramLocation(location.getRow(), location.getCol(), lf);
}
// if clicked in dummy field, try and find the address for the white space.
if (pLoc == null) {