private IEnumerable <Tuple <Snapshot, IArrayDescriptor> > getIArrayDescriptors( MemoryEntryCollector collector, AssociativeArray array) { List <Tuple <Snapshot, IArrayDescriptor> > results = new List <Tuple <Snapshot, IArrayDescriptor> >(); IArrayDescriptor descriptor; IEnumerable <Snapshot> snapshots; if (collector.Structure.TryGetDescriptor(array, out descriptor)) { results.Add(new Tuple <Snapshot, IArrayDescriptor>(collector.Snapshot, descriptor)); } else if (collector.Structure.TryGetCallArraySnapshot(array, out snapshots)) { foreach (Snapshot snapshot in snapshots) { IArrayDescriptor snapDescriptor = snapshot.Structure.Readonly.GetDescriptor(array); results.Add(new Tuple <Snapshot, IArrayDescriptor>(snapshot, snapDescriptor)); } } else { throw new Exception("Missing array descriptor"); } return(results); }
public void CollectValuesFromSources(MemoryEntryCollector collector) { mustHaveArray = true; foreach (SourceIndex source in SourceIndexes) { MemoryEntry entry = SnapshotDataUtils.GetMemoryEntry(source.Snapshot, source.Snapshot.Data.Readonly, source.Index); hasArray = false; this.VisitMemoryEntry(entry); mustHaveArray &= hasArray; } if (!IsMust) { if (ScalarValues == null) { ScalarValues = new HashSet <Value>(); } this.ScalarValues.Add(collector.Snapshot.UndefinedValue); } }
public void CollectAliasesFromSources(MemoryEntryCollector collector) { bool invalidateMust = !IsMust; foreach (SourceIndex source in SourceIndexes) { IMemoryAlias aliases; if (source.Snapshot.Structure.Readonly.TryGetAliases(source.Index, out aliases)) { if (References == null) { References = new ReferenceCollector(); } References.CollectMust(aliases.MustAliases); References.CollectMay(aliases.MayAliases); if (IsMust && SourceIndexes.Count == 1) { References.AddMustAlias(source.Index); } else { References.AddMayAlias(source.Index); } } else { invalidateMust = true; } } if (invalidateMust && References != null) { References.InvalidateMust(); } }
public void CollectChildren(MemoryEntryCollector collector) { if (Arrays != null && Arrays.Count > 0) { // Create new collection for named children NamedChildren = new Dictionary <string, MemoryEntryCollectorNode>(); // Any child node AnyChild = new MemoryEntryCollectorNode(); AnyChild.SourceIndexes = new List <SourceIndex>(); AnyChild.IsMust = false; collector.AddNode(AnyChild); // Collect child names and adds any child sources HashSet <string> names = new HashSet <string>(); List <Tuple <Snapshot, IArrayDescriptor> > sourceDescriptors = new List <Tuple <Snapshot, IArrayDescriptor> >(); foreach (AssociativeArray arrayValue in Arrays) { var descriptors = getIArrayDescriptors(collector, arrayValue); foreach (var tuple in descriptors) { sourceDescriptors.Add(tuple); Snapshot sourceSnapshot = tuple.Item1; IArrayDescriptor descriptor = tuple.Item2; AnyChild.SourceIndexes.Add(new SourceIndex(descriptor.UnknownIndex, sourceSnapshot)); foreach (var item in descriptor.Indexes) { names.Add(item.Key); } } } // Test whether new array as MAY or MUST bool mustHaveChildren = this.IsMust && mustHaveArray; mustHaveChildren &= (ScalarValues == null || ScalarValues.Count == 0); mustHaveChildren &= (Objects == null || Objects.Count == 0); // Iterates collected names and stors them into the structure foreach (string name in names) { MemoryEntryCollectorNode childNode = new MemoryEntryCollectorNode(); childNode.SourceIndexes = new List <SourceIndex>(); childNode.IsMust = mustHaveChildren; collector.AddNode(childNode); NamedChildren.Add(name, childNode); // Collect sources for named child foreach (var tuple in sourceDescriptors) { Snapshot sourceSnapshot = tuple.Item1; IArrayDescriptor descriptor = tuple.Item2; MemoryIndex index; if (descriptor.TryGetIndex(name, out index)) { childNode.SourceIndexes.Add(new SourceIndex(index, sourceSnapshot)); } else { childNode.IsMust = false; childNode.SourceIndexes.Add(new SourceIndex(descriptor.UnknownIndex, sourceSnapshot)); } } } } }