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; this.wrapped = wrapped;
} }
@Override
public String toString() {
return wrapped.toString();
}
void setWrapped(TraceObjectValueStorage wrapped) { void setWrapped(TraceObjectValueStorage wrapped) {
this.wrapped = wrapped; this.wrapped = wrapped;
if (wrapped instanceof DBTraceObjectValueData data) { if (wrapped instanceof DBTraceObjectValueData data) {

View file

@ -43,6 +43,12 @@ public class DBTraceObjectValueBehind implements TraceObjectValueStorage {
this.wrapper = new DBTraceObjectValue(manager, this); 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 @Override
public String getEntryKey() { public String getEntryKey() {
return entryKey; return entryKey;

View file

@ -222,18 +222,17 @@ class DBTraceObjectValueWriteBehindCache {
public Stream<DBTraceObjectValueBehind> streamCanonicalParents(DBTraceObject child, public Stream<DBTraceObjectValueBehind> streamCanonicalParents(DBTraceObject child,
Lifespan lifespan) { Lifespan lifespan) {
TraceObjectKeyPath path = child.getCanonicalPath(); 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(); return Stream.of();
} }
String entryKey = path.key(); String entryKey = path.key();
// TODO: Better indexing? return streamValues(parent, entryKey, lifespan, true);
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));
} }
public Stream<DBTraceObjectValueBehind> streamValues(DBTraceObject parent, Lifespan lifespan) { public Stream<DBTraceObjectValueBehind> streamValues(DBTraceObject parent, Lifespan lifespan) {

View file

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