public MemObjStatisticalCollection CollectionByCellAddressSearchForwards(uint aCellAddress, TClass aClass) { MemObjStatisticalCollection ret = null; // int count = iAllItems.Count; for (int i = 0; i < count; i++) { MemOpBase item = (MemOpBase)iAllItems[i]; // if (item.CellAddress == aCellAddress) { if (aClass == TClass.ENotApplicable) { // Found the item, now locate its collection... ret = CollectionBySymbol(item); break; } else if (aClass == item.Class) { // Found the item, now locate its collection... ret = CollectionBySymbol(item); break; } } } // return(ret); }
public MemObjStatisticalCollection CollectionBySymbol(MemOpBase aItem) { System.Diagnostics.Debug.Assert(aItem.IsAllocationType || aItem.IsReallocationType); // MemOpAllocation allocObject = (MemOpAllocation)aItem; MemObjStatisticalCollection ret = CollectionBySymbol(allocObject.LinkRegisterSymbol, allocObject.LinkRegisterAddress); // return(ret); }
public void AddToCollection(MemOpBase aItem, SymbolLib.Generics.GenericSymbol aSymbol, uint aLinkRegisterAddress) { MemObjStatisticalCollection collection = CollectionBySymbol(aSymbol, aLinkRegisterAddress); if (collection == null) { // Make a new collection collection = new MemObjStatisticalCollection(); iCollections.Add(collection); } collection.Add(aItem); }
public MemObjStatisticalCollection CollectionBySymbol(SymbolLib.Generics.GenericSymbol aSymbol, uint aAddress) { // We also need a symbol... MemObjStatisticalCollection ret = null; // if (aSymbol != null) { int count = iCollections.Count; for (int i = 0; i < count; i++) { MemObjStatisticalCollection collection = (MemObjStatisticalCollection)iCollections[i]; if (collection != iNullSymbolCollection) { System.Diagnostics.Debug.Assert(collection.Count > 0); MemOpAllocation compareToObject = (MemOpAllocation)collection[0]; // Comparing the link register address is a very specific match - therefore we // prefer the slightly slower comparison against the symbol name. This prevents // multiple entries in the list that come from the same symbol (but different // instruction address).. i.e. the allocation occurs within the same function, // but a slightly different location. if (compareToObject.LinkRegisterSymbol != null) { if (compareToObject.LinkRegisterSymbol.Symbol == aSymbol.Symbol) { ret = collection; break; } } else if (compareToObject.LinkRegisterAddress == aAddress) { // Symbols match, add it to this container ret = collection; break; } } } } else { // Must be from the null symbol collection then. ret = iNullSymbolCollection; } // return(ret); }
public void RemoveFromCollection(MemOpBase aItem) { int count = iCollections.Count; for (int i = count - 1; i >= 0; i--) { MemObjStatisticalCollection collection = (MemObjStatisticalCollection)iCollections[i]; System.Diagnostics.Debug.Assert(collection.Count > 0 || collection == iNullSymbolCollection); if (collection.Remove(aItem)) { // Remove the collection as well (if its empty) if (collection.Count == 0) { iCollections.RemoveAt(i); } break; } } }
public MemObjStatisticalCollection CollectionAt(int aIndex) { MemObjStatisticalCollection ret = (MemObjStatisticalCollection)iCollections[aIndex]; return(ret); }
public void Add(MemOpBase aItem, bool aDiscardAllocAndFreedMatchingCells) { /* * if ( aItem.CellAddress == 0xc8036684 ) * { * int x = 0; * x++; * MemOpAllocation ob = (MemOpAllocation) aItem; * if ( ob.LinkRegisterAddress == 0x80874729 ) * { * int x = 0; * x++; * } * } */ int allItemCount = iAllItems.Count; // Check for chained operations - we just treat it as a high level op in that case. if (aItem.Function.ChainedFunction != null && allItemCount > 0) { MemOpBase lastOp = PriorOperationByAllocationNumber(aItem.AllocationNumber); if (lastOp != null && lastOp.AllocationNumber == aItem.AllocationNumber && lastOp.CellAddress == aItem.CellAddress && lastOp.Class == aItem.Class && lastOp.Function.ToString() == aItem.Function.ChainedFunction.ToString()) { // The current operation, replaces the prior one. RemoveFromCollection(lastOp); RemovePriorOperation(lastOp); allItemCount = iAllItems.Count; // Also, we must reset any linkage that the prior operation may have // created when it was added. if (lastOp.Link != null) { lastOp.Link.Link = null; } } } // 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 saveItem = true; if (aItem.IsDeallocationType) { MemOpBase lastOp = PriorOperationByAllocationNumber(aItem.AllocationNumber); if (aItem.Function.ChainedFunction != null && lastOp != null && lastOp.Class == TClass.EDeallocation) { if (lastOp.CellAddress == aItem.CellAddress && lastOp.Function.ToString() == aItem.Function.ChainedFunction.ToString()) { if (aDiscardAllocAndFreedMatchingCells) { // This is a chained delete operation, e.g: // // [KMEM] OKF - C: 0xc802776c, HS: 80064, HCS: 85896, LR: 0x800c98c4, AS: 316, AN: 314, VT: 0x800d09c8 // [KMEM] OD - C: 0xc802776c, HS: 80064, HCS: 85896, LR: 0x800a2ea8, AS: 316, AN: 314, VT: 0x800d09c8 // [KMEM] ODBD - C: 0xc802776c, HS: 80064, HCS: 85896, LR: 0x800adec8, AS: 316, AN: 314, VT: 0x800d0000 // // and we're handling OD or ODBD after already having processed OKF. In that case, we've already thrown away the original // alloc, and there's nothing left for us to do here. saveItem = false; } else { // We need to replace the OKF/OD operation with the OD/ODBD respectively. In order // for the loop below to process the item, we must re-nullify the link MemOpBase originalAllocationOp = lastOp.Link; originalAllocationOp.Link = null; } } } // If the item is a deallocation, but we can't find any matching alloc // then just ignore the deallocation entirely. // // We'll assume that its an isolated dealloc, but if we find a matching // alloc we'll toggle this back again to preseve the item. saveItem = false; // for (int i = allItemCount - 1; i >= 0; i--) { MemOpBase item = 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.. if (aDiscardAllocAndFreedMatchingCells) { // Can ignore both the allocation and deallocation. RemoveFromCollection(item); iAllItems.RemoveAt(i); // Don't save the delete - we are ignoring matching alloc & frees break; } else { item.Link = aItem; aItem.Link = item; saveItem = true; break; } } } } // Add the item to our master list... if (saveItem) { // Locate the corresponding collection and also add the item there too MemOpAllocation searchObject = null; if (aItem.IsAllocationType) { searchObject = (MemOpAllocation)aItem; } else { // Try to base the search object on the link item (if we have one..) if (aItem.Link != null) { searchObject = (MemOpAllocation)aItem.Link; } } if (searchObject != null) { if (searchObject.LinkRegisterSymbol != null) { MemObjStatisticalCollection collection = CollectionBySymbol(searchObject); if (collection == null) { // Make a new collection collection = new MemObjStatisticalCollection(); iCollections.Add(collection); } collection.Add(aItem); } else { // Use the null symbol collection iNullSymbolCollection.Add(aItem); } } AddNewPriorOperation(aItem); } }