mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GT-3260_emteere changes from code-review
This commit is contained in:
parent
40a7425b3c
commit
652e689846
1 changed files with 32 additions and 20 deletions
|
@ -57,13 +57,13 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
||||||
private AddressSet addrSet = new AddressSet();
|
private AddressSet addrSet = new AddressSet();
|
||||||
private AddressSet initializedLoadedAddrSet = new AddressSet();
|
private AddressSet initializedLoadedAddrSet = new AddressSet();
|
||||||
private AddressSet allInitializedAddrSet = new AddressSet();
|
private AddressSet allInitializedAddrSet = new AddressSet();
|
||||||
private AddressSetView executeSet = new AddressSet();
|
private AddressSetView executeSet = null;
|
||||||
|
|
||||||
private MemoryBlock lastBlock;// the last accessed block
|
private MemoryBlock lastBlock;// the last accessed block
|
||||||
private LiveMemoryHandler liveMemory;
|
private LiveMemoryHandler liveMemory;
|
||||||
|
|
||||||
// lazy hashmap of block names to blocks, must be reloaded if blocks are removed or added
|
// lazy hashmap of block names to blocks, must be reloaded if blocks are removed or added
|
||||||
private HashMap<String,MemoryBlock> nameBlockMap = new HashMap<String, MemoryBlock>();
|
private HashMap<String, MemoryBlock> nameBlockMap = new HashMap<String, MemoryBlock>();
|
||||||
private final static MemoryBlock NoBlock = new MemoryBlockStub(); // placeholder for no block, not given out
|
private final static MemoryBlock NoBlock = new MemoryBlockStub(); // placeholder for no block, not given out
|
||||||
|
|
||||||
Lock lock;
|
Lock lock;
|
||||||
|
@ -251,7 +251,7 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AddressSetView getAllInitializedAddressSet() {
|
public AddressSetView getAllInitializedAddressSet() {
|
||||||
return allInitializedAddrSet;
|
return new AddressSetViewAdapter(allInitializedAddrSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -262,7 +262,7 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
||||||
if (liveMemory != null) {
|
if (liveMemory != null) {
|
||||||
return this;//all memory is initialized!
|
return this;//all memory is initialized!
|
||||||
}
|
}
|
||||||
return initializedLoadedAddrSet;
|
return new AddressSetViewAdapter(initializedLoadedAddrSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkMemoryWrite(MemoryBlockDB block, Address start, long length)
|
void checkMemoryWrite(MemoryBlockDB block, Address start, long length)
|
||||||
|
@ -396,15 +396,12 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
||||||
if (program != null) {
|
if (program != null) {
|
||||||
program.setChanged(ChangeManager.DOCR_MEMORY_BLOCK_CHANGED, block, null);
|
program.setChanged(ChangeManager.DOCR_MEMORY_BLOCK_CHANGED, block, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// name could have changed
|
// name could have changed
|
||||||
nameBlockMap = new HashMap<>();
|
nameBlockMap = new HashMap<>();
|
||||||
|
|
||||||
// execute state could have changed. check if in set and shouldn't be or vice/versa
|
// don't regenerate now, do lazily later if needed
|
||||||
if (executeSet != null && executeSet.contains(block.getStart(), block.getEnd()) != block.isExecute()) {
|
executeSet = null;
|
||||||
// don't regenerate now, do lazily later if needed
|
|
||||||
executeSet = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void fireBytesChanged(Address addr, int count) {
|
void fireBytesChanged(Address addr, int count) {
|
||||||
|
@ -1981,17 +1978,32 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AddressSetView getExecuteSet() {
|
public AddressSetView getExecuteSet() {
|
||||||
if (executeSet != null) {
|
AddressSetView set = executeSet;
|
||||||
|
|
||||||
|
if (set == null) {
|
||||||
|
set = computeExecuteSet();
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return executable address set
|
||||||
|
*/
|
||||||
|
private AddressSetView computeExecuteSet() {
|
||||||
|
lock.acquire();
|
||||||
|
try {
|
||||||
|
AddressSet set = new AddressSet();
|
||||||
|
for (MemoryBlock block : blocks) {
|
||||||
|
if (block.isExecute()) {
|
||||||
|
set.addRange(block.getStart(), block.getEnd());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
executeSet = new AddressSetViewAdapter(set);
|
||||||
return executeSet;
|
return executeSet;
|
||||||
}
|
}
|
||||||
AddressSet set = new AddressSet();
|
finally {
|
||||||
for (MemoryBlock block : blocks) {
|
lock.release();
|
||||||
if (block.isExecute()) {
|
|
||||||
set.addRange(block.getStart(), block.getEnd());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
executeSet = new AddressSetViewAdapter(set);
|
|
||||||
return executeSet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue