示例#1
0
        //=========================================
        // 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);
        }
示例#2
0
        //=========================================
        // timer1_Tick
        //=========================================
        private void timer1_Tick(object sender, EventArgs e)
        {
            int numHeaps = AllocStats.getNumHeaps();

            //ask the manager what our heap sizes are.
            for (int i = 0; i < numHeaps; i++)
            {
                HeapAlloc pHeap = AllocStats.getHeapFromIndex(i);

                uint allocSize = pHeap.getTotalAllocatedBytes();
                //covert the Y value to megabytes for graphing.
                int yMB = (int)(allocSize / (1024 * 1024));
                fastTimeLine.addPointToLine(pHeap.getMemPtr(), (int)yMB);
            }


            //elapsed time
            TimeSpan deltaTime = DateTime.Now - mStartTime;

            label2.Text = "Time Line [" + deltaTime.Hours + ":" + deltaTime.Minutes + ":" + deltaTime.Seconds + "]";

            if (mScrollerStuck)
            {
                fastTimeLine.setScrollPercent(1);
            }


            fastTimeLine.Refresh();
        }
示例#3
0
        //=========================================
        // 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);
        }
示例#4
0
        //=========================================
        // onHeapRegister
        //=========================================
        public void onHeapRegister(uint mPtr, int flags, string name)
        {
            HeapAlloc     pHeap = AllocStats.getHeapFromBasePtr(mPtr);
            HeapAllocNode has   = new HeapAllocNode(pHeap);

            mTreeView.addNode(has);
            mTreeView.updatePositions();
            mTreeView.Refresh();
        }
示例#5
0
        public void dumpEntireList(string filename)
        {
            Dictionary <string, tHashVal> fileHashes = new Dictionary <string, tHashVal>();

            int numHeaps = AllocStats.getNumHeaps();

            for (int i = 0; i < numHeaps; i++)
            {
                HeapAlloc pHeap  = AllocStats.getHeapFromIndex(i);
                Hashtable pFiles = pHeap.getFileAllocations();

                IDictionaryEnumerator _enumerator = pFiles.GetEnumerator();
                while (_enumerator.MoveNext())
                {
                    FileAlloc fa        = ((FileAlloc)_enumerator.Value);
                    string    fnameOnly = Path.GetFileName(fa.getFilename());
                    uint      memAmt    = fa.getTotalAllocatedBytes(false);

                    if (fileHashes.ContainsKey(fnameOnly))
                    {
                        tHashVal thv = fileHashes[fnameOnly];
                        thv.memAmt    += memAmt;
                        thv.heapsUsed += "," + pHeap.getName();
                    }
                    else
                    {
                        tHashVal th = new tHashVal();
                        th.heapsUsed = pHeap.getName();
                        th.memAmt    = memAmt;
                        th.tFname    = fa.getFilename();
                        fileHashes.Add(fnameOnly, th);
                    }
                }
            }


            StreamWriter          sw         = new StreamWriter(filename, true);
            IDictionaryEnumerator enumerator = fileHashes.GetEnumerator();

            while (enumerator.MoveNext())
            {
                tHashVal thv = ((tHashVal)enumerator.Value);
                sw.WriteLine(thv.tFname + "," + thv.memAmt + "," + thv.heapsUsed);
            }


            sw.Close();
            sw = null;
        }
示例#6
0
            //=========================================
            // update
            //=========================================
            public uint update()
            {
                uint totalBytes = 0;

                int numheaps = AllocStats.getNumHeaps();

                for (int i = 0; i < numheaps; i++)
                {
                    HeapAlloc pHeap = AllocStats.getHeapFromIndex(i);

                    IDictionaryEnumerator _enumerator = pHeap.getFileAllocations().GetEnumerator();
                    while (_enumerator.MoveNext())
                    {
                        FileAlloc fa        = ((FileAlloc)_enumerator.Value);
                        string    longFName = fa.getFilename();

                        if (longFName.Contains("xbox\\code"))
                        {
                            string trimedFName = giveTrimmedString(longFName);
                            if (trimedFName.ToLower() == mFilename.ToLower())
                            {
                                totalBytes += fa.getTotalAllocatedBytes(false);
                            }
                        }
                        else
                        {
                            if (longFName.ToLower() == mFilename.ToLower())
                            {
                                totalBytes += fa.getTotalAllocatedBytes(false);
                            }
                        }
                    }
                }

                if (totalBytes > mMaxAllocatedBytes)
                {
                    mMaxAllocatedBytes = totalBytes;
                }

                mCurrAllocatedBytes = totalBytes;

                this.Text = Path.GetFileName(mFilename) + ", curr :  " + MemoryNumber.convert(totalBytes) + " , max : " + MemoryNumber.convert(mMaxAllocatedBytes);


                return(totalBytes);
            }
示例#7
0
        //=========================================
        // timer1_Tick
        //=========================================
        private void timer1_Tick(object sender, EventArgs e)
        {
            uint mTotalAllocatedBytesI = 0;
            uint mTotalAllocatedBytesE = 0;

            int numHeaps = AllocStats.getNumHeaps();

            for (int i = 0; i < numHeaps; i++)
            {
                HeapAlloc pHeap = AllocStats.getHeapFromIndex(i);

                Hashtable             pHeapFiles      = pHeap.getFileAllocations();
                IDictionaryEnumerator file_enumerator = pHeapFiles.GetEnumerator();
                while (file_enumerator.MoveNext())
                {
                    FileAlloc fa      = ((FileAlloc)file_enumerator.Value);
                    string    trFName = giveTrimmedString(fa.getFilename());
                    if (trFName.ToLower() == mTruncatedFilePath.ToLower())
                    {
                        mTotalAllocatedBytesE += fa.getTotalAllocatedBytes(false);
                        mTotalAllocatedBytesI += fa.getTotalAllocatedBytes(true);
                    }
                }
            }

            //covert the Y value to megabytes for graphing.
            uint allocSize = mTotalAllocatedBytesE;
            int  yMB       = (int)(allocSize / (1024 * 1024));

            mTimeline.addPointToLine(0xBEEFCAD0, (int)yMB);

            if (mScrollerStuck)
            {
                mTimeline.setScrollPercent(1);
            }


            mTimeline.Refresh();

            FilenameLabel.Text = mFilenameOnly + " i(" + MemoryNumber.convert(mTotalAllocatedBytesI) + ")" + " e(" + MemoryNumber.convert(mTotalAllocatedBytesE) + ")";
        }
示例#8
0
        //============================================================================
        // onClientConnected
        //============================================================================
        public void onClientConnected(string name, string pdbFilename)
        {
            AllocStats.clearHeaps();


            LoadSymbolsParams lsp = new LoadSymbolsParams();

            lsp.mProcHandle     = 0x00ABBEEF;  // Process.GetCurrentProcess().Id;
            lsp.mSymbolFileName = pdbFilename; //string sName = @"C:\depot\phoenix\xbox\code\xgame\xbox\debug\xgameD.exe";

            //since this takes so long, spend display a 'wait' bar to the user..
            {
                mSymbolProcEvent.Reset();

                BackgroundWorker mWorkerThread = new BackgroundWorker();
                mWorkerThread.WorkerReportsProgress = false;
                //mWorkerThread.ProgressChanged += bw_ProgressChanged;
                mWorkerThread.WorkerSupportsCancellation = false;
                //mWorkerThread.RunWorkerCompleted += bw_RunWorkerCompleted;
                mWorkerThread.DoWork += bw_DoWork;
                mWorkerThread.RunWorkerAsync(lsp);

                HaloWarsMem.loadSymbolInfo((uint)lsp.mProcHandle, lsp.mSymbolFileName);

                mSymbolProcEvent.Set();
            }
            AllocLogStream.unpauseProcessing();


            heapLines.onConnect();
            heapKey.onConnect();
            heapFileView.onConnect();
            topAllocs.onConnect();
            mFileTimelines.onConnect();
            mFileGroupings.onConnect();
        }
示例#9
0
        private void button1_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            sfd.Filter           = "CSV File *.csv|*.csv";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                StreamWriter sw = new StreamWriter(sfd.FileName, true);


                int numHeaps = AllocStats.getNumHeaps();
                for (int i = 0; i < numHeaps; i++)
                {
                    HeapAlloc pHeap  = AllocStats.getHeapFromIndex(i);
                    Hashtable pFiles = pHeap.getFileAllocations();

                    sw.WriteLine(pHeap.getName() + ", ," + pHeap.getMaxAllocatedBytes());

                    IDictionaryEnumerator _enumerator = pFiles.GetEnumerator();
                    while (_enumerator.MoveNext())
                    {
                        FileAlloc fa        = ((FileAlloc)_enumerator.Value);
                        string    fnameOnly = Path.GetFileName(fa.getFilename());
                        uint      memAmt    = fa.getTotalAllocatedBytes(false);

                        sw.WriteLine(" ," + fa.getFilename() + "," + memAmt);
                    }
                }



                sw.Close();
                sw = null;
            }
        }
示例#10
0
        //=========================================
        // onHeapRegister
        //=========================================
        public void onHeapRegister(uint mPtr, int flags, string name)
        {
            HeapAlloc pHeap = AllocStats.getHeapFromBasePtr(mPtr);

            fastTimeLine.addNewGraphLine(pHeap.getMemPtr(), pHeap.getName(), pHeap.ColorVal);
        }
示例#11
0
        //============================================================================
        // onMessageRecieved
        //============================================================================
        public void onMessageRecieved(PacketWrapper packet)
        {
            HaloWarsMem.eALPacketType type = (HaloWarsMem.eALPacketType)packet.mPacketType;

            switch (type)
            {
            //================================================
            case HaloWarsMem.eALPacketType.cALNew:
            {
                HaloWarsMem.BALPacketNew pkt = new HaloWarsMem.BALPacketNew(packet.mPacketSize, packet.mPacketData);

                HeapAlloc pHeap = AllocStats.getHeapFromBasePtr(pkt.mpHeap);
                if (pHeap == null)
                {
                    return;
                }

                pHeap.allocMem(pkt.mSize, pkt.mpBlock, pkt.mBlockSize, pkt.mContext);

                //pass on
                mFileGroupings.onNew(pkt.mpHeap, pkt.mSize, pkt.mpBlock, pkt.mBlockSize, pkt.mContext);
                break;
            }

            //================================================
            case HaloWarsMem.eALPacketType.cALResize:
            {
                HaloWarsMem.BALPacketResize pkt = new HaloWarsMem.BALPacketResize(packet.mPacketSize, packet.mPacketData);

                HeapAlloc pHeap = AllocStats.getHeapFromBasePtr(pkt.mpHeap);
                if (pHeap == null)
                {
                    return;
                }


                //pass on
                mFileGroupings.onResize(pkt.mpHeap, pkt.mpOrigBlock, pkt.mNewSize, pkt.mpNewBlock, pkt.mContext);


                //this needs to be done last
                pHeap.resizeMem(pkt.mpOrigBlock, pkt.mNewSize, pkt.mpNewBlock, pkt.mContext);



                break;
            }

            //================================================
            case HaloWarsMem.eALPacketType.cALDelete:
            {
                HaloWarsMem.BALPacketDelete pkt = new HaloWarsMem.BALPacketDelete(packet.mPacketSize, packet.mPacketData);

                HeapAlloc pHeap = AllocStats.getHeapFromBasePtr(pkt.mpHeap);
                if (pHeap == null)
                {
                    return;
                }


                //pass on
                mFileGroupings.onDelete(pkt.mpHeap, pkt.mpBlock, pkt.mContext);
                //need to pass on before deletion to ensure any queries occur
                pHeap.deleteMem(pkt.mpBlock, pkt.mContext);


                break;
            }

            //================================================
            case HaloWarsMem.eALPacketType.cALRegisterHeap:
            {
                HaloWarsMem.BALPacketRegisterHeap pkt = new HaloWarsMem.BALPacketRegisterHeap(packet.mPacketSize, packet.mPacketData);

                AllocStats.registerHeap(pkt);

                //propagate to those that care..
                heapLines.onHeapRegister(pkt.mPtr, pkt.mFlags, pkt.mName);
                heapFileView.onHeapRegister(pkt.mPtr, pkt.mFlags, pkt.mName);
                break;
            }

            //================================================
            case HaloWarsMem.eALPacketType.cALIgnoreLeaf:
            {
                HaloWarsMem.BALPacketIgnoreLeaf pkt = new HaloWarsMem.BALPacketIgnoreLeaf(packet.mPacketSize, packet.mPacketData);
                HaloWarsMem.getSymbolInfo().addIgnoreSymbol(pkt.mSymbolName);

                break;
            }

            case HaloWarsMem.eALPacketType.cALEOF:
            {
                heapLines.onDisconnect();
                heapKey.onDisconnect();
                topAllocs.onDisconnect();
                heapFileView.onDisconnect();
                mFileTimelines.onDisconnect();
                mFileGroupings.onDisconnect();
                break;
            }
            }
            ;
        }
示例#12
0
        //=========================================
        // onUpdate
        //=========================================
        void onUpdate()
        {
            /////////////////////////////////////
            //find our sorting order..
            mLastSortedKeys.Clear();

            //this has changed a bit..
            //walk each heap, and get all the files per heap
            //get each file's memory, and use insertion sort to handle it.

            int numHeaps = AllocStats.getNumHeaps();

            for (int i = 0; i < numHeaps; i++)
            {
                HeapAlloc pHeap  = AllocStats.getHeapFromIndex(i);
                Hashtable pFiles = pHeap.getFileAllocations();

                IDictionaryEnumerator _enumerator = pFiles.GetEnumerator();
                while (_enumerator.MoveNext())
                {
                    FileAlloc fa = ((FileAlloc)_enumerator.Value);

                    uint memAmt = fa.getTotalAllocatedBytes(false);

                    //search the other heaps for this same file..
                    for (int j = 0; j < numHeaps; j++)
                    {
                        if (i == j)
                        {
                            continue;
                        }

                        HeapAlloc pHeap2  = AllocStats.getHeapFromIndex(j);
                        Hashtable pFiles2 = pHeap2.getFileAllocations();
                        if (pFiles2.Contains(fa.getFilename()))
                        {
                            FileAlloc fa2 = ((FileAlloc)pFiles2[fa.getFilename()]);
                            memAmt += fa2.getTotalAllocatedBytes(false);
                        }
                    }



                    //use insertion sort
                    bool inserted = false;
                    for (int j = 0; j < mLastSortedKeys.Count; j++)
                    {
                        if (mLastSortedKeys[j].mFilenameOnly == Path.GetFileName(fa.getFilename()))
                        {
                            inserted = true;
                            break;
                        }


                        if (memAmt < mLastSortedKeys[j].mTotalAllocatedBytes)
                        {
                            SortedFileStats sfs = new SortedFileStats();
                            sfs.mTotalAllocatedBytes = memAmt;
                            sfs.mFilenameOnly        = Path.GetFileName(fa.getFilename());
                            mLastSortedKeys.Insert(j, sfs);

                            if (mLastSortedKeys.Count >= cMaxNumBars)
                            {
                                mLastSortedKeys.RemoveAt(0);
                            }
                            inserted = true;

                            break;
                        }
                    }

                    if (!inserted)
                    {
                        SortedFileStats sfs = new SortedFileStats();
                        sfs.mTotalAllocatedBytes = memAmt;
                        sfs.mFilenameOnly        = Path.GetFileName(fa.getFilename());
                        mLastSortedKeys.Add(sfs);
                    }
                }
            }
        }
示例#13
0
        //=========================================
        // OnPaint
        //=========================================
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            int[] xTabs = { 5, 100, 170, 250, 330, 420, 510 };

            int x        = 0;
            int y        = 0;
            int ySpacing = 12;


            g.DrawString("allocated", GDIStatic.Font_Console_10, GDIStatic.SolidBrush_DimGray, xTabs[1], y);
            g.DrawString("blocks", GDIStatic.Font_Console_10, GDIStatic.SolidBrush_DimGray, xTabs[2], y);
            g.DrawString("N", GDIStatic.Font_Console_10, GDIStatic.SolidBrush_DimGray, xTabs[3], y);
            g.DrawString("D", GDIStatic.Font_Console_10, GDIStatic.SolidBrush_DimGray, xTabs[4], y);
            g.DrawString("R", GDIStatic.Font_Console_10, GDIStatic.SolidBrush_DimGray, xTabs[5], y);

            y += ySpacing + 1;

            g.DrawLine(GDIStatic.Pen_DimGray, 0, y, Width, y);

            y += 2;

            //SORT THE LIST!
            List <int> sortOrder = new List <int>();

            for (int i = 0; i < AllocStats.getNumHeaps(); i++)
            {
                sortOrder.Add(i);
            }

            //SORT!
            for (int i = 0; i < AllocStats.getNumHeaps(); i++)
            {
                for (int j = 0; j < AllocStats.getNumHeaps(); j++)
                {
                    uint target = AllocStats.getHeapFromIndex(sortOrder[i]).getTotalAllocatedBytes();
                    uint next   = AllocStats.getHeapFromIndex(sortOrder[j]).getTotalAllocatedBytes();
                    if (next < target)
                    {
                        int tmp = sortOrder[i];
                        sortOrder[i] = sortOrder[j];
                        sortOrder[j] = tmp;
                    }
                }
            }



            uint totalActiveBytes  = 0;
            uint totalActiveBlocks = 0;

            for (int i = 0; i < AllocStats.getNumHeaps(); i++)
            {
                HeapAlloc pHeap = AllocStats.getHeapFromIndex(sortOrder[i]);
                Brush     brush = new SolidBrush(pHeap.ColorVal);

                uint totalNumBlocks = pHeap.getTotalNumAllocations();
                uint totalNumBytes  = pHeap.getTotalAllocatedBytes();


                g.DrawString(pHeap.getName() + " :", GDIStatic.Font_Console_10, brush, xTabs[0], y);
                g.DrawString(MemoryNumber.convert(totalNumBytes), GDIStatic.Font_Console_10, brush, xTabs[1], y);
                g.DrawString(totalNumBlocks.ToString(), GDIStatic.Font_Console_10, brush, xTabs[2], y);
                g.DrawString(pHeap.getNumNews().ToString(), GDIStatic.Font_Console_10, brush, xTabs[3], y);
                g.DrawString(pHeap.getNumDeletes().ToString(), GDIStatic.Font_Console_10, brush, xTabs[4], y);
                g.DrawString(pHeap.getNumResizes().ToString(), GDIStatic.Font_Console_10, brush, xTabs[5], y);

                g.FillRectangle(brush, x + 0, y + 2, 4, 8);

                y += ySpacing;

                totalActiveBlocks += totalNumBlocks;
                totalActiveBytes  += totalNumBytes;
            }


            g.DrawString("Total :", GDIStatic.Font_Console_10, GDIStatic.SolidBrush_White, xTabs[0], y + ySpacing);
            g.DrawString(MemoryNumber.convert(totalActiveBytes), GDIStatic.Font_Console_10, GDIStatic.SolidBrush_White, xTabs[1], y + ySpacing);
            g.DrawString(totalActiveBlocks.ToString(), GDIStatic.Font_Console_10, GDIStatic.SolidBrush_White, xTabs[2], y + ySpacing);
        }
示例#14
0
        //=========================================
        // 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);
        }