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 initializedLoadedAddrSet = new AddressSet();
|
||||
private AddressSet allInitializedAddrSet = new AddressSet();
|
||||
private AddressSetView executeSet = new AddressSet();
|
||||
private AddressSetView executeSet = null;
|
||||
|
||||
private MemoryBlock lastBlock;// the last accessed block
|
||||
private LiveMemoryHandler liveMemory;
|
||||
|
||||
// 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
|
||||
|
||||
Lock lock;
|
||||
|
@ -251,7 +251,7 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
|||
|
||||
@Override
|
||||
public AddressSetView getAllInitializedAddressSet() {
|
||||
return allInitializedAddrSet;
|
||||
return new AddressSetViewAdapter(allInitializedAddrSet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,7 +262,7 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
|||
if (liveMemory != null) {
|
||||
return this;//all memory is initialized!
|
||||
}
|
||||
return initializedLoadedAddrSet;
|
||||
return new AddressSetViewAdapter(initializedLoadedAddrSet);
|
||||
}
|
||||
|
||||
void checkMemoryWrite(MemoryBlockDB block, Address start, long length)
|
||||
|
@ -400,12 +400,9 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
|||
// name could have changed
|
||||
nameBlockMap = new HashMap<>();
|
||||
|
||||
// execute state could have changed. check if in set and shouldn't be or vice/versa
|
||||
if (executeSet != null && executeSet.contains(block.getStart(), block.getEnd()) != block.isExecute()) {
|
||||
// don't regenerate now, do lazily later if needed
|
||||
executeSet = null;
|
||||
}
|
||||
}
|
||||
|
||||
void fireBytesChanged(Address addr, int count) {
|
||||
lock.acquire();
|
||||
|
@ -1981,9 +1978,20 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
|||
*/
|
||||
@Override
|
||||
public AddressSetView getExecuteSet() {
|
||||
if (executeSet != null) {
|
||||
return executeSet;
|
||||
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()) {
|
||||
|
@ -1993,6 +2001,10 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
|||
executeSet = new AddressSetViewAdapter(set);
|
||||
return executeSet;
|
||||
}
|
||||
finally {
|
||||
lock.release();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void memoryChanged(Address addr, int size) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue