GP-0: Fix DBTraceObject.getCanonicalParent(snap)

This commit is contained in:
Dan 2024-02-16 10:48:18 -05:00
parent 14f7e1f458
commit 8a3faa73dc
4 changed files with 19 additions and 10 deletions

View File

@ -147,6 +147,11 @@ public class DBTraceObjectValue implements TraceObjectValue {
this.wrapped = wrapped;
}
@Override
public String toString() {
return wrapped.toString();
}
void setWrapped(TraceObjectValueStorage wrapped) {
this.wrapped = wrapped;
if (wrapped instanceof DBTraceObjectValueData data) {

View File

@ -43,6 +43,12 @@ public class DBTraceObjectValueBehind implements TraceObjectValueStorage {
this.wrapper = new DBTraceObjectValue(manager, this);
}
@Override
public String toString() {
return "<%s parent=%s entryKey=%s lifespan=%s value=%s>".formatted(
getClass().getSimpleName(), parent, entryKey, lifespan, value);
}
@Override
public String getEntryKey() {
return entryKey;

View File

@ -222,18 +222,17 @@ class DBTraceObjectValueWriteBehindCache {
public Stream<DBTraceObjectValueBehind> streamCanonicalParents(DBTraceObject child,
Lifespan lifespan) {
TraceObjectKeyPath path = child.getCanonicalPath();
if (path.isRoot()) {
TraceObjectKeyPath parentPath = path.parent();
if (parentPath == null) { // child is the root
return Stream.of();
}
DBTraceObject parent = manager.getObjectByCanonicalPath(parentPath);
if (parent == null) {
// Not inserted yet, or someone deleted the parent object
return Stream.of();
}
String entryKey = path.key();
// TODO: Better indexing?
return cachedValues.values()
.stream()
.flatMap(v -> v.entrySet()
.stream()
.filter(e -> entryKey.equals(e.getKey()))
.map(e -> e.getValue()))
.flatMap(v -> streamSub(v, lifespan, true));
return streamValues(parent, entryKey, lifespan, true);
}
public Stream<DBTraceObjectValueBehind> streamValues(DBTraceObject parent, Lifespan lifespan) {

View File

@ -108,7 +108,6 @@ public class GdbMethodsTest extends AbstractGdbTraceRmiTest {
file bash
ghidra trace start
%s
ghidra trace tx-open "Fake" 'ghidra trace create-obj Breakpoints'
starti"""
.formatted(INSTRUMENT_STOPPED));
RemoteMethod refreshBreakpoints = conn.getMethod("refresh_breakpoints");