mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-18 16:40:08 +00:00
GP-1949 corrected memory map cache update for block removals
This commit is contained in:
parent
bfe3dcfb95
commit
5be1971ecf
@ -571,7 +571,7 @@ public class MemoryBlockDB implements MemoryBlock {
|
||||
for (SubMemoryBlock subBlock : subBlocks) {
|
||||
subBlock.delete();
|
||||
}
|
||||
adapter.deleteMemoryBlock(getID());
|
||||
adapter.deleteMemoryBlock(this);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@ -670,7 +670,7 @@ public class MemoryBlockDB implements MemoryBlock {
|
||||
subBlocks.addAll(memBlock2.subBlocks);
|
||||
possiblyMergeSubBlocks(n - 1, n);
|
||||
sequenceSubBlocks();
|
||||
adapter.deleteMemoryBlock(memBlock2.id);
|
||||
adapter.deleteMemoryBlock(memBlock2);
|
||||
adapter.updateBlockRecord(record);
|
||||
|
||||
}
|
||||
|
@ -228,10 +228,10 @@ abstract class MemoryMapDBAdapter {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
abstract void deleteMemoryBlock(long key) throws IOException;
|
||||
abstract void deleteMemoryBlock(MemoryBlockDB block) throws IOException;
|
||||
|
||||
/**
|
||||
* Updates the memory block record.
|
||||
|
@ -210,7 +210,7 @@ class MemoryMapDBAdapterV0 extends MemoryMapDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
void deleteMemoryBlock(long key) throws IOException {
|
||||
void deleteMemoryBlock(MemoryBlockDB block) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ class MemoryMapDBAdapterV2 extends MemoryMapDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
void deleteMemoryBlock(long key) throws IOException {
|
||||
void deleteMemoryBlock(MemoryBlockDB block) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
@ -153,6 +153,14 @@ public class MemoryMapDBAdapterV3 extends MemoryMapDBAdapter {
|
||||
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
|
||||
MemoryBlockDB createInitializedBlock(String name, Address startAddr, InputStream is,
|
||||
long length, int permissions) throws AddressOverflowException, IOException {
|
||||
@ -319,8 +327,9 @@ public class MemoryMapDBAdapterV3 extends MemoryMapDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
void deleteMemoryBlock(long key) throws IOException {
|
||||
memBlockTable.deleteRecord(key);
|
||||
void deleteMemoryBlock(MemoryBlockDB block) throws IOException {
|
||||
removeCachedBlock(block);
|
||||
memBlockTable.deleteRecord(block.getID());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user