@@ -57,13 +57,13 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
57
57
private AddressSet addrSet = new AddressSet ();
58
58
private AddressSet initializedLoadedAddrSet = new AddressSet ();
59
59
private AddressSet allInitializedAddrSet = new AddressSet ();
60
- private AddressSetView executeSet = new AddressSet () ;
60
+ private AddressSetView executeSet = null ;
61
61
62
62
private MemoryBlock lastBlock ;// the last accessed block
63
63
private LiveMemoryHandler liveMemory ;
64
-
64
+
65
65
// lazy hashmap of block names to blocks, must be reloaded if blocks are removed or added
66
- private HashMap <String ,MemoryBlock > nameBlockMap = new HashMap <String , MemoryBlock >();
66
+ private HashMap <String , MemoryBlock > nameBlockMap = new HashMap <String , MemoryBlock >();
67
67
private final static MemoryBlock NoBlock = new MemoryBlockStub (); // placeholder for no block, not given out
68
68
69
69
Lock lock ;
@@ -251,7 +251,7 @@ public AddressSetView getInitializedAddressSet() {
251
251
252
252
@ Override
253
253
public AddressSetView getAllInitializedAddressSet () {
254
- return allInitializedAddrSet ;
254
+ return new AddressSetViewAdapter ( allInitializedAddrSet ) ;
255
255
}
256
256
257
257
/**
@@ -262,7 +262,7 @@ public AddressSetView getLoadedAndInitializedAddressSet() {
262
262
if (liveMemory != null ) {
263
263
return this ;//all memory is initialized!
264
264
}
265
- return initializedLoadedAddrSet ;
265
+ return new AddressSetViewAdapter ( initializedLoadedAddrSet ) ;
266
266
}
267
267
268
268
void checkMemoryWrite (MemoryBlockDB block , Address start , long length )
@@ -396,15 +396,12 @@ void fireBlockChanged(MemoryBlock block) {
396
396
if (program != null ) {
397
397
program .setChanged (ChangeManager .DOCR_MEMORY_BLOCK_CHANGED , block , null );
398
398
}
399
-
399
+
400
400
// name could have changed
401
401
nameBlockMap = new HashMap <>();
402
-
403
- // execute state could have changed. check if in set and shouldn't be or vice/versa
404
- if (executeSet != null && executeSet .contains (block .getStart (), block .getEnd ()) != block .isExecute ()) {
405
- // don't regenerate now, do lazily later if needed
406
- executeSet = null ;
407
- }
402
+
403
+ // don't regenerate now, do lazily later if needed
404
+ executeSet = null ;
408
405
}
409
406
410
407
void fireBytesChanged (Address addr , int count ) {
@@ -1981,17 +1978,32 @@ public int hashCode() {
1981
1978
*/
1982
1979
@ Override
1983
1980
public AddressSetView getExecuteSet () {
1984
- if (executeSet != null ) {
1985
- return executeSet ;
1981
+ AddressSetView set = executeSet ;
1982
+
1983
+ if (set == null ) {
1984
+ set = computeExecuteSet ();
1986
1985
}
1987
- AddressSet set = new AddressSet ();
1988
- for (MemoryBlock block : blocks ) {
1989
- if (block .isExecute ()) {
1990
- set .addRange (block .getStart (), block .getEnd ());
1986
+ return set ;
1987
+ }
1988
+
1989
+ /**
1990
+ * @return executable address set
1991
+ */
1992
+ private AddressSetView computeExecuteSet () {
1993
+ lock .acquire ();
1994
+ try {
1995
+ AddressSet set = new AddressSet ();
1996
+ for (MemoryBlock block : blocks ) {
1997
+ if (block .isExecute ()) {
1998
+ set .addRange (block .getStart (), block .getEnd ());
1999
+ }
1991
2000
}
2001
+ executeSet = new AddressSetViewAdapter (set );
2002
+ return executeSet ;
2003
+ }
2004
+ finally {
2005
+ lock .release ();
1992
2006
}
1993
- executeSet = new AddressSetViewAdapter (set );
1994
- return executeSet ;
1995
2007
}
1996
2008
1997
2009
@ Override
0 commit comments