mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GP-1949 corrected memory map cache update for block removals
This commit is contained in:
@@ -571,7 +571,7 @@ public class MemoryBlockDB implements MemoryBlock {
|
|||||||
for (SubMemoryBlock subBlock : subBlocks) {
|
for (SubMemoryBlock subBlock : subBlocks) {
|
||||||
subBlock.delete();
|
subBlock.delete();
|
||||||
}
|
}
|
||||||
adapter.deleteMemoryBlock(getID());
|
adapter.deleteMemoryBlock(this);
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -670,7 +670,7 @@ public class MemoryBlockDB implements MemoryBlock {
|
|||||||
subBlocks.addAll(memBlock2.subBlocks);
|
subBlocks.addAll(memBlock2.subBlocks);
|
||||||
possiblyMergeSubBlocks(n - 1, n);
|
possiblyMergeSubBlocks(n - 1, n);
|
||||||
sequenceSubBlocks();
|
sequenceSubBlocks();
|
||||||
adapter.deleteMemoryBlock(memBlock2.id);
|
adapter.deleteMemoryBlock(memBlock2);
|
||||||
adapter.updateBlockRecord(record);
|
adapter.updateBlockRecord(record);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,10 +228,10 @@ abstract class MemoryMapDBAdapter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the given memory block.
|
* Deletes the given memory block.
|
||||||
* @param key the key for the memory block record
|
* @param block the memory block to be deleted
|
||||||
* @throws IOException if a database IO error occurs.
|
* @throws IOException if a database IO error occurs.
|
||||||
*/
|
*/
|
||||||
abstract void deleteMemoryBlock(long key) throws IOException;
|
abstract void deleteMemoryBlock(MemoryBlockDB block) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the memory block record.
|
* Updates the memory block record.
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ class MemoryMapDBAdapterV0 extends MemoryMapDBAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void deleteMemoryBlock(long key) throws IOException {
|
void deleteMemoryBlock(MemoryBlockDB block) throws IOException {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ class MemoryMapDBAdapterV2 extends MemoryMapDBAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void deleteMemoryBlock(long key) throws IOException {
|
void deleteMemoryBlock(MemoryBlockDB block) throws IOException {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,6 +153,14 @@ public class MemoryMapDBAdapterV3 extends MemoryMapDBAdapter {
|
|||||||
memoryBlocks.add(-insertionIndex - 1, newBlock);
|
memoryBlocks.add(-insertionIndex - 1, newBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeCachedBlock(MemoryBlockDB deletedBlock) {
|
||||||
|
int index = Collections.binarySearch(memoryBlocks, deletedBlock);
|
||||||
|
if (index < 0) { // should not find direct hit
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memoryBlocks.remove(index);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
MemoryBlockDB createInitializedBlock(String name, Address startAddr, InputStream is,
|
MemoryBlockDB createInitializedBlock(String name, Address startAddr, InputStream is,
|
||||||
long length, int permissions) throws AddressOverflowException, IOException {
|
long length, int permissions) throws AddressOverflowException, IOException {
|
||||||
@@ -319,8 +327,9 @@ public class MemoryMapDBAdapterV3 extends MemoryMapDBAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void deleteMemoryBlock(long key) throws IOException {
|
void deleteMemoryBlock(MemoryBlockDB block) throws IOException {
|
||||||
memBlockTable.deleteRecord(key);
|
removeCachedBlock(block);
|
||||||
|
memBlockTable.deleteRecord(block.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user