Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 3
0
        private void BackgroundThreadBuildLookupCache(object aNotUsed)
        {
            System.Diagnostics.Debug.Assert(iLookUpCacheWaiter != null);

            // This comparer will help us sort the ranges
            AddressCollectionPairComparer comparer = new AddressCollectionPairComparer();

            // Make sorted list entries
            lock ( iCollections )
            {
                int colCount = iCollections.Count;
                for (int colIndex = 0; colIndex < colCount; colIndex++)
                {
                    SymbolCollection collection = iCollections[colIndex];
                    //
                    UpdateCacheForCollection(collection);
                }
            }

            // Done building cache
            iLookUpCacheWaiter.Set();
        }
Esempio n. 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);
                            }
                        }
                    }
                }
            }
        }