Merge remote-tracking branch 'origin/GP-1585_Dan_TargetBreakpointLocation-use-AddressRange--SQUASHED'

This commit is contained in:
Ryan Kurtz 2022-09-12 11:04:20 -04:00
commit 56949088ca
23 changed files with 1143 additions and 1161 deletions

View file

@ -24,6 +24,7 @@ import java.util.concurrent.locks.ReadWriteLock;
import com.google.common.collect.Range;
import db.DBHandle;
import ghidra.dbg.target.TargetBreakpointLocation;
import ghidra.program.model.address.*;
import ghidra.program.model.lang.Language;
import ghidra.trace.database.DBTrace;
@ -142,7 +143,8 @@ public class DBTraceBreakpointManager
public Collection<? extends TraceBreakpoint> getBreakpointsAt(long snap, Address address) {
if (trace.getObjectManager().hasSchema()) {
return trace.getObjectManager()
.getObjectsContaining(snap, address, TraceObjectBreakpointLocation.KEY_RANGE,
.getObjectsContaining(snap, address,
TargetBreakpointLocation.RANGE_ATTRIBUTE_NAME,
TraceObjectBreakpointLocation.class);
}
return delegateRead(address.getAddressSpace(), m -> m.getBreakpointsAt(snap, address),
@ -154,7 +156,8 @@ public class DBTraceBreakpointManager
AddressRange range) {
if (trace.getObjectManager().hasSchema()) {
return trace.getObjectManager()
.getObjectsIntersecting(span, range, TraceObjectBreakpointLocation.KEY_RANGE,
.getObjectsIntersecting(span, range,
TargetBreakpointLocation.RANGE_ATTRIBUTE_NAME,
TraceObjectBreakpointLocation.class);
}
return delegateRead(range.getAddressSpace(), m -> m.getBreakpointsIntersecting(span, range),

View file

@ -44,7 +44,7 @@ public class DBTraceObjectBreakpointLocation
protected class BreakpointChangeTranslator extends Translator<TraceBreakpoint> {
protected BreakpointChangeTranslator(DBTraceObject object, TraceBreakpoint iface) {
super(KEY_RANGE, object, iface);
super(TargetBreakpointLocation.RANGE_ATTRIBUTE_NAME, object, iface);
}
@Override
@ -64,7 +64,7 @@ public class DBTraceObjectBreakpointLocation
@Override
protected boolean appliesToKey(String key) {
return KEY_RANGE.equals(key) ||
return TargetBreakpointLocation.RANGE_ATTRIBUTE_NAME.equals(key) ||
TargetObject.DISPLAY_ATTRIBUTE_NAME.equals(key) ||
TargetBreakpointSpec.ENABLED_ATTRIBUTE_NAME.equals(key) ||
KEY_COMMENT.equals(key);
@ -122,7 +122,7 @@ public class DBTraceObjectBreakpointLocation
@Override
public void setRange(Range<Long> lifespan, AddressRange range) {
try (LockHold hold = object.getTrace().lockWrite()) {
object.setValue(lifespan, KEY_RANGE, range);
object.setValue(lifespan, TargetBreakpointLocation.RANGE_ATTRIBUTE_NAME, range);
this.range = range;
}
}
@ -133,8 +133,8 @@ public class DBTraceObjectBreakpointLocation
if (object.getLife().isEmpty()) {
return range;
}
return range = TraceObjectInterfaceUtils.getValue(object, getPlacedSnap(), KEY_RANGE,
AddressRange.class, range);
return range = TraceObjectInterfaceUtils.getValue(object, getPlacedSnap(),
TargetBreakpointLocation.RANGE_ATTRIBUTE_NAME, AddressRange.class, range);
}
}
@ -325,7 +325,7 @@ public class DBTraceObjectBreakpointLocation
}
public TraceAddressSpace getTraceAddressSpace() {
return spaceForValue(computeMinSnap(), KEY_RANGE);
return spaceForValue(computeMinSnap(), TargetBreakpointLocation.RANGE_ATTRIBUTE_NAME);
}
@Override

View file

@ -27,11 +27,10 @@ import com.google.common.collect.*;
import db.DBRecord;
import db.StringField;
import ghidra.dbg.target.TargetBreakpointLocation;
import ghidra.dbg.target.TargetObject;
import ghidra.dbg.target.schema.TargetObjectSchema;
import ghidra.dbg.util.*;
import ghidra.program.model.address.*;
import ghidra.program.model.address.AddressSpace;
import ghidra.trace.database.DBTrace;
import ghidra.trace.database.DBTraceUtils;
import ghidra.trace.database.breakpoint.DBTraceObjectBreakpointLocation;
@ -728,47 +727,6 @@ public class DBTraceObject extends DBAnnotatedObject implements TraceObject {
return manager.doCreateValue(lifespan, this, key, value);
}
// HACK: Because breakpoint uses address,length instead of range. FIXME!
protected void applyBreakpointRangeHack(Range<Long> lifespan, String key, Object value,
ConflictResolution resolution) {
/**
* NOTE: This should only be happening in Target/TraceBreakpointLocation, but I suppose
* anything using this scheme should be hacked.
*/
Address address;
int length;
if (key == TargetBreakpointLocation.ADDRESS_ATTRIBUTE_NAME &&
value instanceof Address) {
address = (Address) value;
InternalTraceObjectValue lengthObj = getValue(DBTraceUtils.lowerEndpoint(lifespan),
TargetBreakpointLocation.LENGTH_ATTRIBUTE_NAME);
if (lengthObj == null || !(lengthObj.getValue() instanceof Integer)) {
return;
}
length = (Integer) lengthObj.getValue();
}
else if (key == TargetBreakpointLocation.LENGTH_ATTRIBUTE_NAME &&
value instanceof Integer) {
length = (Integer) value;
InternalTraceObjectValue addressObj = getValue(DBTraceUtils.lowerEndpoint(lifespan),
TargetBreakpointLocation.ADDRESS_ATTRIBUTE_NAME);
if (addressObj == null || !(addressObj.getValue() instanceof Address)) {
return;
}
address = (Address) addressObj.getValue();
}
else {
return;
}
try {
setValue(lifespan, TraceObjectBreakpointLocation.KEY_RANGE,
new AddressRangeImpl(address, length), resolution);
}
catch (AddressOverflowException e) {
Msg.warn(this, "Could not set range: " + e);
}
}
@Override
public InternalTraceObjectValue setValue(Range<Long> lifespan, String key, Object value,
ConflictResolution resolution) {
@ -812,8 +770,6 @@ public class DBTraceObject extends DBAnnotatedObject implements TraceObject {
};
InternalTraceObjectValue result = setter.set(lifespan, value);
// NB. This hack will cause more value events. good.
applyBreakpointRangeHack(lifespan, key, value, resolution);
DBTraceObject child = setter.canonicalLifeChanged;
if (child != null) {
child.emitEvents(

View file

@ -31,14 +31,11 @@ import ghidra.util.exception.DuplicateNameException;
shortName = "breakpoint location",
fixedKeys = {
TargetObject.DISPLAY_ATTRIBUTE_NAME,
TargetBreakpointLocation.ADDRESS_ATTRIBUTE_NAME,
TargetBreakpointLocation.LENGTH_ATTRIBUTE_NAME,
TargetBreakpointLocation.RANGE_ATTRIBUTE_NAME,
TraceObjectBreakpointLocation.KEY_COMMENT,
TraceObjectBreakpointLocation.KEY_RANGE,
})
public interface TraceObjectBreakpointLocation extends TraceBreakpoint, TraceObjectInterface {
String KEY_COMMENT = "_comment";
String KEY_RANGE = "_range"; // Duplicates address,length
TraceObjectBreakpointSpec getSpecification();