Example #1
0
        private void AddToCollection(MemOpBase aItem)
        {
            // Add the item to our master list...
            iAllItems.Add(aItem);
            aItem.OperationIndex = iAllItems.Count;

            // If the start region marker hasn't been initialised, it means
            // that the object operation took place outside of an allocation
            if (iCurrentCollection == null || iCurrentCollection.RegionStart.Initialised == false)
            {
                if (iCurrentCollection == null)
                {
                    iCurrentCollection = new MemObjRegionalCollection();
                }

                // In this case, we set the start line number to the line upon
                // which the operation took place.
                iCurrentCollection.RegionStart.LineNumber = aItem.LineNumber;
                iCurrentCollection.RegionStart.RegionText = KOperationOutsideOfRegionText;
            }

            // Associate the item with this collection
            aItem.Collection = iCurrentCollection;
            iCurrentCollection.Add(aItem);
        }
Example #2
0
 public MemObjRegionalCollection this[int aIndex]
 {
     get
     {
         MemObjRegionalCollection ret = (MemObjRegionalCollection)iCollections[aIndex];
         return(ret);
     }
 }
Example #3
0
        public void Add(MemOpBase aItem, bool aDiscardAllocAndFreedMatchingCells)
        {
            #region When deallocating, search for original alloc and link items...
            // If the item is a de-allocation, hunt backwards through the allocation
            // list until we find the allocating cell. Then setup their two-way relationship
            bool throwAwayObject = false;

            if (aItem.IsAllocationType == false)
            {
                int count = iAllItems.Count;
                for (int i = count - 1; i >= 0; i--)
                {
                    MemOpBase item = (MemOpBase)iAllItems[i];
                    //
                    if (item.Link == null && item.CellAddress == aItem.CellAddress && item.IsAllocationType != aItem.IsAllocationType)
                    {
                        // The item should be the allocation that this de-alloc is associated
                        // with..
                        //System.Diagnostics.Debug.Assert( item.IsAllocationType == true ); - User::Realloc screwing things up?
                        if (aDiscardAllocAndFreedMatchingCells)
                        {
                            // Can ignore both cells. First remove teh previous allocation cell.
                            iAllItems.RemoveAt(i);

                            // We don't even add aItem to the 'all items' container.
                            // However, we still need to remove the linked allocation from it's container.
                            if (item.Collection != null)
                            {
                                MemObjRegionalCollection collectionForAllocation = (MemObjRegionalCollection)item.Collection;
                                int colCount = collectionForAllocation.Count;
                                collectionForAllocation.RemoveByCellAddress(item);

                                // Make sure we really removed it.
                                System.Diagnostics.Debug.Assert(collectionForAllocation.Count == colCount - 1);

                                // We don't want to log this 'free' operation since it perfectly
                                // matched an allocation.
                                throwAwayObject = true;
                            }
                        }
                        else
                        {
                            item.Link  = aItem;
                            aItem.Link = item;
                        }

                        break;
                    }
                }
            }
            #endregion

            // Add the item to our master list...
            if (!throwAwayObject)
            {
                AddToCollection(aItem);
            }
        }
Example #4
0
        public void MarkerStartIdentified(string aText, long aLineNumber)
        {
            if (iCurrentCollection != null)
            {
                // We've just finished a collection. Normally this is handled
                // by the end item, but if the end item wasn't found, then
                // we must do it manually.
                CurrentCollectionComplete(KOperationOutsideOfRegionText, aLineNumber - 1, false);
            }

            // Set the starting items
            iCurrentCollection = new MemObjRegionalCollection();
            iCurrentCollection.RegionStart.RegionText        = aText;
            iCurrentCollection.RegionStart.LineNumber        = aLineNumber;
            iCurrentCollection.RegionStart.MatchedRegionText = true;
        }
Example #5
0
        public MemObjRegionalCollection CollectionByCellAddress(long aCellAddress, TClass aClass, out MemOpBase aItem, out int aCollectionIndex, out int aItemIndex)
        {
            aItem            = null;
            aCollectionIndex = -1;
            aItemIndex       = -1;
            MemObjRegionalCollection ret = null;

            // First check whether the item is in the current collection (if we have one)
            if (iCurrentCollection != null)
            {
                aItem = iCurrentCollection.ItemByAddress(aCellAddress, aClass, out aItemIndex);
                if (aItem != null)
                {
                    // Yes, it resides in the current collection...
                    ret = iCurrentCollection;
                }
            }
            else
            {
                // Need to search the remaining collections. Must search backwards!
                int count = iCollections.Count;
                for (int i = count - 1; i >= 0; i--)
                {
                    MemObjRegionalCollection collection = (MemObjRegionalCollection)iCollections[i];
                    aItem = collection.ItemByAddress(aCellAddress, aClass, out aItemIndex);
                    if (aItem != null)
                    {
                        // Yes, its in this collection
                        ret = collection;
                        aCollectionIndex = i;
                        break;
                    }
                }
            }

            return(ret);
        }