//========================================= // onDelete //========================================= public void onDelete(uint mpHeap, uint mpBlock, HaloWarsMem.BALContext context) { HeapAlloc pHeap = AllocStats.getHeapFromBasePtr(mpHeap); uint blockSize = pHeap.getBlockSize(mpBlock); drawBlock(mpBlock, blockSize, GDIStatic.CommonBGColor); }
//========================================= // allocMem //========================================= public void allocMem(uint pHeap, uint pBlock, uint blockSize, HaloWarsMem.BALContext context) { SymbolInfo.LookupInfo li = new SymbolInfo.LookupInfo(); for (int i = 0; i < context.mBackTraceSize; i++) { HaloWarsMem.getSymbolInfo().lookup(context.mBackTrace[i], ref li); if (HaloWarsMem.getSymbolInfo().isIgnoreSymbol(Path.GetFileName(li.mFilename))) { continue; } if (mBlockToFile.Contains(pBlock)) { GlobalErrors.addError("HeapAlloc : Multiple Allocations of block 0x" + pBlock.ToString("x") + " in heap 0x" + pHeap.ToString("x")); return; } FileAlloc fa = (FileAlloc)mAllocations[li.mFilename]; if (fa == null) { fa = new FileAlloc(li.mFilename); mAllocations.Add(li.mFilename, fa); } mBlockToFile.Add(pBlock, li.mFilename); fa.allocMem(pHeap, pBlock, blockSize, (uint)li.mLine, context); break; } mNumNews++; }
//============================================================================== // resizeMem //============================================================================== public void resizeMem(uint pOrigBlock, uint NewSize, uint pNewBlock, HaloWarsMem.BALContext context) { deleteMem(pOrigBlock, context); allocMem(this.mPtrToHeap, pNewBlock, NewSize, context); mNumNews--; mNumDeletes--; mNumResizes++; }
//========================================= // onDelete //========================================= public void onDelete(uint mpHeap, uint mpBlock, HaloWarsMem.BALContext context) { XBOXMemView.VirtualAddressInfo vai = XBOXMemView.getVirtualAddressInfo(mpBlock); if (vai.mMemRegion != XBOXMemView.VirtualAddressInfo.eMemRegion.ePhysical) { return; } uint translatedAddress = XBOXMemView.convertVirtualAddrToPhysicalAddr(mpBlock); mPhysicalMemoryRange.onDelete(mpHeap, translatedAddress, context); }
//========================================= // onNew //========================================= public void onNew(uint mpHeap, uint mSize, uint mpBlock, uint mBlockSize, HaloWarsMem.BALContext context) { XBOXMemView.VirtualAddressInfo vai = XBOXMemView.getVirtualAddressInfo(mpBlock); if (vai.mMemRegion == XBOXMemView.VirtualAddressInfo.eMemRegion.eVirtual) { if (vai.mSizeOfContainingPage == XBOXMemView.VirtualAddressInfo.ePageSize.e4k) { mVirtual4KRange.onNew(mpHeap, mSize, mpBlock, mBlockSize, context); } else if (vai.mSizeOfContainingPage == XBOXMemView.VirtualAddressInfo.ePageSize.e64k) { mVirtual64KRange.onNew(mpHeap, mSize, mpBlock, mBlockSize, context); } } else if (vai.mMemRegion == XBOXMemView.VirtualAddressInfo.eMemRegion.eImage) { if (vai.mSizeOfContainingPage == XBOXMemView.VirtualAddressInfo.ePageSize.e4k) { mImage4KRange.onNew(mpHeap, mSize, mpBlock, mBlockSize, context); } else if (vai.mSizeOfContainingPage == XBOXMemView.VirtualAddressInfo.ePageSize.e64k) { mImage64KRange.onNew(mpHeap, mSize, mpBlock, mBlockSize, context); } } else if (vai.mMemRegion == XBOXMemView.VirtualAddressInfo.eMemRegion.eEncrypted) { mEncrypted64KRange.onNew(mpHeap, mSize, mpBlock, mBlockSize, context); } else if (vai.mMemRegion == XBOXMemView.VirtualAddressInfo.eMemRegion.ePhysical) { if (vai.mSizeOfContainingPage == XBOXMemView.VirtualAddressInfo.ePageSize.e4k) { Physical4KRange.onNew(mpHeap, mSize, mpBlock, mBlockSize, context); } else if (vai.mSizeOfContainingPage == XBOXMemView.VirtualAddressInfo.ePageSize.e64k) { Physical64KRange.onNew(mpHeap, mSize, mpBlock, mBlockSize, context); } else if (vai.mSizeOfContainingPage == XBOXMemView.VirtualAddressInfo.ePageSize.e16m) { mPhysical16MBRange.onNew(mpHeap, mSize, mpBlock, mBlockSize, context); } } }
//========================================= // allocMem //========================================= public void allocMem(uint pHeap, uint pBlock, uint blockSize, HaloWarsMem.BALContext context) { if (mAllocations.Contains(pBlock)) { GlobalErrors.addError(" LineAlloc : Multiple Allocations of block 0x" + pBlock.ToString("x") + " in heap 0x" + pHeap.ToString("x")); return; } BlockAlloc ba = new BlockAlloc(); ba.mpHeap = pHeap; ba.mpBlock = pBlock; ba.mBlockSize = blockSize; context.copyTo(ref ba.mContext); mAllocations.Add(pBlock, ba); mTotalBytes += blockSize; }
//============================================================================== // deleteMem //============================================================================== public void deleteMem(uint pBlock, HaloWarsMem.BALContext context) { mNumDeletes++; FileAlloc fa = getFileContaining(pBlock); mBlockToFile.Remove(pBlock); if (fa != null) { fa.deleteMem(pBlock); if (fa.getTotalAllocatedBytes(false) == 0) { mAllocations.Remove(fa.getFilename()); } return; } GlobalErrors.addError("HeapAlloc : Stray delete of block 0x" + pBlock.ToString("x") + ". No file!"); }
//========================================= // allocMem //========================================= public void allocMem(uint pHeap, uint pBlock, uint blockSize, uint lineNum, HaloWarsMem.BALContext context) { if (mBlockToLineNum.Contains(pBlock)) { GlobalErrors.addError("FileAlloc : Multiple Allocations of block 0x" + pBlock.ToString("x") + " in heap 0x" + pHeap.ToString("x")); return; } LineAlloc la = (LineAlloc)mAllocations[lineNum]; if (la == null) { la = new LineAlloc(lineNum); mAllocations.Add(lineNum, la); } la.allocMem(pHeap, pBlock, blockSize, context); mBlockToLineNum.Add(pBlock, lineNum); mTotalBytes += blockSize; }
//========================================= // onDelete //========================================= public void onDelete(uint mpHeap, uint mpBlock, HaloWarsMem.BALContext context) { }
//========================================= // onResize //========================================= public void onResize(uint mpHeap, uint mpOrigBlock, uint mNewSize, uint mpNewBlock, HaloWarsMem.BALContext context) { }
//========================================= // onNew //========================================= public void onNew(uint mpHeap, uint mSize, uint mpBlock, uint mBlockSize, HaloWarsMem.BALContext context) { }
//============================================================================== // resizeMem //============================================================================== public void resizeMem(uint pHeap, uint pOrigBlock, uint NewSize, uint pNewBlock, uint lineNum, HaloWarsMem.BALContext context) { deleteMem(pOrigBlock); allocMem(pHeap, pNewBlock, NewSize, lineNum, context); }
//========================================= // onResize //========================================= public void onResize(uint mpHeap, uint mpOrigBlock, uint mNewSize, uint mpNewBlock, HaloWarsMem.BALContext context) { HeapAlloc pHeap = AllocStats.getHeapFromBasePtr(mpHeap); uint blockSize = pHeap.getBlockSize(mpOrigBlock); drawBlock(mpOrigBlock, blockSize, GDIStatic.CommonBGColor); drawBlock(mpNewBlock, mNewSize, pHeap.ColorVal); }
//========================================= // onNew //========================================= public void onNew(uint mpHeap, uint mSize, uint mpBlock, uint mBlockSize, HaloWarsMem.BALContext context) { HeapAlloc pHeap = AllocStats.getHeapFromBasePtr(mpHeap); drawBlock(mpBlock, mBlockSize, pHeap.ColorVal); }