public Symbol Lookup(uint aAddress, out SymbolCollection aCollection) { WaitForLookupCache(); // Symbol ret = null; aCollection = null; // AddressCollectionPair temp = new AddressCollectionPair(new AddressRange(aAddress, aAddress), null); AddressCollectionPairComparer comparer = new AddressCollectionPairComparer(); // lock ( iLookupCache ) { int pos = iLookupCache.BinarySearch(temp, comparer); if (pos >= 0) { temp = iLookupCache[pos]; aCollection = temp.Collection; ret = aCollection[aAddress]; } } // return(ret); }
public bool Contains(uint aAddress) { WaitForLookupCache(); // bool ret = false; // AddressCollectionPair temp = new AddressCollectionPair(new AddressRange(aAddress, aAddress), null); AddressCollectionPairComparer comparer = new AddressCollectionPairComparer(); // lock ( iLookupCache ) { int pos = iLookupCache.BinarySearch(temp, comparer); ret = (pos >= 0); } // return(ret); }
private void BackgroundThreadRemoveFromCache(object aCollection) { System.Diagnostics.Debug.Assert(iLookUpCacheWaiter != null); SymbolCollection collection = (SymbolCollection)aCollection; // Predicate <AddressCollectionPair> predicate = delegate(AddressCollectionPair pair) { bool match = (pair.Collection == collection); return(match); }; // lock ( iLookupCache ) { AddressCollectionPair temp = new AddressCollectionPair(new AddressRange(), collection); iLookupCache.RemoveAll(predicate); } // iLookUpCacheWaiter.Set(); }
private void UpdateCacheForCollection(SymbolCollection aCollection) { bool isEmpty = aCollection.IsEmptyApartFromDefaultSymbol; if (isEmpty == false) { AddressRangeCollection ranges = aCollection.AddressRangeCollection; if (ranges != null) { // This comparer will help us sort the ranges AddressCollectionPairComparer comparer = new AddressCollectionPairComparer(); int rangeCount = ranges.Count; for (int rangeIndex = 0; rangeIndex < rangeCount; rangeIndex++) { AddressRange range = ranges[rangeIndex]; AddressCollectionPair pair = new AddressCollectionPair(range, aCollection); // lock ( iLookupCache ) { int pos = iLookupCache.BinarySearch(pair, comparer); if (pos >= 0) { AddressCollectionPair overlapsWith = iLookupCache[pos]; System.Diagnostics.Debug.WriteLine(string.Format("Collection {0} [{1}] overlaps with existing collection: {2} [{3}]", pair.Collection.FileName, pair.Range, overlapsWith.Collection, overlapsWith.Range)); } else { pos = ~pos; iLookupCache.Insert(pos, pair); } } } } } }