GP-1890: Add diff coloring to Debugger memory bytes window

This commit is contained in:
Dan 2022-09-23 15:34:21 -04:00
parent f31e6bd52e
commit 8b4bf133b5
6 changed files with 135 additions and 22 deletions

View file

@ -39,20 +39,12 @@ public class ByteBlockChangeManager {
private static String OLD_VALUE = "OldValue";
private static String NEW_VALUE = "NewValue";
private int dummy = 4;
/**
* Construct new change manager.
*/
ByteBlockChangeManager(ProgramByteBlockSet blockSet) {
protected ByteBlockChangeManager(ProgramByteBlockSet blockSet, ByteBlockChangeManager bbcm) {
this.blockSet = blockSet;
changeList = new ArrayList<ByteEditInfo>(3);
}
ByteBlockChangeManager(ProgramByteBlockSet blockSet, ByteBlockChangeManager bbcm) {
this.blockSet = blockSet;
changeList = bbcm.changeList;
changeList = bbcm == null ? new ArrayList<>() : bbcm.changeList;
}
/**
@ -61,7 +53,7 @@ public class ByteBlockChangeManager {
* @param edit edit object that has the old value and new value
*
*/
void add(ByteEditInfo edit) {
protected void add(ByteEditInfo edit) {
byte[] oldValue = edit.getOldValue();
byte[] newValue = edit.getNewValue();
@ -127,7 +119,7 @@ public class ByteBlockChangeManager {
*
* @return boolean true if an offset in the range was found
*/
boolean isChanged(ByteBlock block, BigInteger offset, int unitByteSize) {
protected boolean isChanged(ByteBlock block, BigInteger offset, int unitByteSize) {
Address blockAddr = blockSet.getBlockStart(block);
for (int i = 0; i < unitByteSize; i++) {

View file

@ -46,12 +46,7 @@ public class ProgramByteBlockSet implements ByteBlockSet {
this.provider = provider;
this.program = program;
if (bbcm == null) {
this.bbcm = new ByteBlockChangeManager(this);
}
else {
this.bbcm = new ByteBlockChangeManager(this, bbcm);
}
this.bbcm = provider.newByteBlockChangeManager(this, bbcm);
newMemoryBlocks();
}
@ -204,8 +199,7 @@ public class ProgramByteBlockSet implements ByteBlockSet {
/**
* Get the address for the given block and offset.
*/
protected Address getAddress(ByteBlock block, BigInteger offset) {
public Address getAddress(ByteBlock block, BigInteger offset) {
for (int i = 0; i < blocks.length; i++) {
if (blocks[i] != block) {
continue;

View file

@ -537,7 +537,7 @@ public class ProgramByteViewerComponentProvider extends ByteViewerComponentProvi
event.containsEvent(DomainObject.DO_DOMAIN_FILE_CHANGED)) {
// drop all changes
blockSet.setByteBlockChangeManager(new ByteBlockChangeManager(blockSet));
blockSet.setByteBlockChangeManager(newByteBlockChangeManager(blockSet, null));
updateManager.update();
}
}
@ -563,6 +563,11 @@ public class ProgramByteViewerComponentProvider extends ByteViewerComponentProvi
}
}
protected ByteBlockChangeManager newByteBlockChangeManager(ProgramByteBlockSet blockSet,
ByteBlockChangeManager bbcm) {
return new ByteBlockChangeManager(blockSet, bbcm);
}
protected ProgramByteBlockSet newByteBlockSet(ByteBlockChangeManager changeManager) {
if (program == null) {
return null;

View file

@ -125,7 +125,7 @@ public class ByteViewerPlugin1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testOpenProgramNoMemory() throws Exception {
tool.removePlugins(new Plugin[] { cbPlugin });
tool.removePlugins(List.of(cbPlugin));
runSwing(() -> {
ProgramManager pm = tool.getService(ProgramManager.class);