GP-2765: Re-factor RegionsProvider for object-based trace

This commit is contained in:
Dan 2022-11-04 16:17:54 -04:00
parent da766b7e69
commit 3327cc6bb8
25 changed files with 1962 additions and 794 deletions

View file

@ -356,8 +356,8 @@ public class DBTraceObjectMemoryRegion implements TraceObjectMemoryRegion, DBTra
DBTrace trace = object.getTrace();
switch (key) {
case TargetMemoryRegion.RANGE_ATTRIBUTE_NAME:
trace.updateViewsChangeRegionBlockRange(this,
(AddressRange) oldValue, (AddressRange) newValue);
// NB. old/newValue are null here. The CREATED event just has the new entry.
trace.updateViewsRefreshBlocks();
return;
case TargetObject.DISPLAY_ATTRIBUTE_NAME:
trace.updateViewsChangeRegionBlockName(this);

View file

@ -44,7 +44,7 @@ public abstract class AbstractDBTraceProgramViewMemory
protected final DBTraceProgramView program;
protected final DBTraceMemoryManager memoryManager;
protected AddressSetView addressSet;
protected volatile AddressSetView addressSet;
protected boolean forceFullView = false;
protected long snap;
@ -79,7 +79,7 @@ public abstract class AbstractDBTraceProgramViewMemory
}
}
protected void computeFullAdddressSet() {
protected synchronized void computeFullAdddressSet() {
AddressSet temp = new AddressSet();
forPhysicalSpaces(space -> temp.add(space.getMinAddress(), space.getMaxAddress()));
addressSet = temp;
@ -125,17 +125,17 @@ public abstract class AbstractDBTraceProgramViewMemory
}
@Override
public synchronized AddressSetView getLoadedAndInitializedAddressSet() {
public AddressSetView getLoadedAndInitializedAddressSet() {
return addressSet;
}
@Override
public synchronized AddressSetView getAllInitializedAddressSet() {
public AddressSetView getAllInitializedAddressSet() {
return addressSet;
}
@Override
public synchronized AddressSetView getInitializedAddressSet() {
public AddressSetView getInitializedAddressSet() {
return addressSet;
}
@ -230,7 +230,7 @@ public abstract class AbstractDBTraceProgramViewMemory
}
@Override
public synchronized long getSize() {
public long getSize() {
return addressSet.getNumAddresses();
}

View file

@ -74,11 +74,12 @@ public class DBTraceProgramViewMemory extends AbstractDBTraceProgramViewMemory {
}
@Override
protected void recomputeAddressSet() {
protected synchronized void recomputeAddressSet() {
AddressSet temp = new AddressSet();
// TODO: Performance test this
forVisibleRegions(reg -> temp.add(reg.getRange()));
addressSet = temp;
System.err.println("Recomputed: " + temp);
}
protected MemoryBlock getRegionBlock(TraceMemoryRegion region) {
@ -139,7 +140,6 @@ public class DBTraceProgramViewMemory extends AbstractDBTraceProgramViewMemory {
public void updateChangeRegionBlockRange(TraceMemoryRegion region, AddressRange oldRange,
AddressRange newRange) {
// TODO: update cached block? Nothing to update.
changeRange(oldRange, newRange);
}

View file

@ -258,12 +258,22 @@ public class DBTraceObjectManager implements TraceObjectManager, DBTraceManager
rootSchema = schema;
}
protected void emitValueCreated(DBTraceObject parent, InternalTraceObjectValue entry) {
if (parent == null) {
// Don't need event for root value created
return;
}
parent.emitEvents(
new TraceChangeRecord<>(TraceObjectChangeType.VALUE_CREATED, null, entry));
}
protected InternalTraceObjectValue doCreateValue(Lifespan lifespan,
DBTraceObject parent, String key, Object value) {
if (value instanceof AddressRange) {
DBTraceObjectAddressRangeValue entry = rangeValueMap
.put(new ImmutableTraceAddressSnapRange((AddressRange) value, lifespan), null);
entry.set(parent, key, false);
emitValueCreated(parent, entry);
return entry;
}
else if (value instanceof Address) {
@ -272,15 +282,12 @@ public class DBTraceObjectManager implements TraceObjectManager, DBTraceManager
DBTraceObjectAddressRangeValue entry = rangeValueMap
.put(new ImmutableTraceAddressSnapRange(singleton, lifespan), null);
entry.set(parent, key, true);
emitValueCreated(parent, entry);
return entry;
}
DBTraceObjectValue entry = valueStore.create();
entry.set(lifespan, parent, key, value);
if (parent != null) {
// Don't need event for root value created
parent.emitEvents(
new TraceChangeRecord<>(TraceObjectChangeType.VALUE_CREATED, null, entry));
}
emitValueCreated(parent, entry);
return entry;
}