コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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);
                            }
                        }
                    }
                }
            }
        }