Skip to content

Commit

Permalink
GP-0: Fix DBTraceObject.getCanonicalParent(snap)
Browse files Browse the repository at this point in the history
  • Loading branch information
nsadeveloper789 committed Feb 16, 2024
1 parent 14f7e1f commit 8a3faa7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ public DBTraceObjectValue(DBTraceObjectManager manager,
this.wrapped = wrapped;
}

@Override
public String toString() {
return wrapped.toString();
}

void setWrapped(TraceObjectValueStorage wrapped) {
this.wrapped = wrapped;
if (wrapped instanceof DBTraceObjectValueData data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public DBTraceObjectValueBehind(DBTraceObjectManager manager, DBTraceObject pare
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,17 @@ private Stream<DBTraceObjectValueBehind> streamSub(
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public void testRefreshBreakpoints() throws Exception {
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");
Expand Down

0 comments on commit 8a3faa7

Please sign in to comment.