private void dataGridView2_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
            {
                DataGridViewCell cell     = dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex];
                MemBlock         block    = dataGridView2.Rows[e.RowIndex].Tag as MemBlock;
                string           ttText   = "";
                string           blockTag = block.GetTagString();
                if (blockTag.Length > 0)
                {
                    ttText = ttText + "Tag: " + blockTag + "\n----------------------\n";
                }

                ulong[] callStack = CallstackTab.GetCallStack(block.m_callStackCRC);
                for (int i = 0; i < callStack.Length; ++i)
                {
                    IStackTracer.Symbol symbol = MemTracerForm.ms_MainForm.StackTracer.GetSymbolForAddress(callStack[i]);
                    if (symbol.functionName != null)
                    {
                        ttText = ttText + symbol.functionName + "\n";
                    }
                }
                cell.ToolTipText = ttText;
            }
        }
Esempio n. 2
0
        public void AddMemBlock(MemBlock block)
        {
            if (BottomUp)
            {
                AddMemBlockBottomUp(block);
                return;
            }

            if (m_subtreeRoot != 0 && !block.DoesCallStackContainAddress(m_subtreeRoot))
            {
                return;
            }

            int rootIndex = block.FindFirstValidSymbolIndex();

            if (rootIndex < 0)
            {
                return;
            }

            Node root = m_root;

            if (Tagged)
            {
                root = FindRootForTag(block.m_tag);
                if (root == null)
                {
                    root = m_root.AddTaggedChild(block.m_tag, block.m_tagCRC);
                }
            }

            ulong[]      callStack   = CallstackTab.GetCallStack(block.m_callStackCRC);
            Node         rootNode    = root.FindChildByCallAddress(callStack[rootIndex], true);
            IStackTracer stackTracer = MemTracerForm.ms_MainForm.StackTracer;

            if (rootNode == null)
            {
                IStackTracer.Symbol symbol = stackTracer.GetSymbolForAddress(callStack[rootIndex]);
                rootNode = root.AddChild(symbol);
            }
            Node parentNode = rootNode;

            for (int i = rootIndex + 1; i < callStack.Length; ++i)
            {
                ulong callAddress = callStack[i];
                Node  thisNode    = parentNode.FindChildByCallAddress(callAddress, false);

                if (thisNode == null)
                {
                    thisNode = parentNode.AddChild(stackTracer.GetSymbolForAddress(callAddress));
                }
                if (i == callStack.Length - 1)
                {
                    thisNode.m_allocatedSize += block.m_size;
                    ++thisNode.m_allocatedBlocks;
                }
                parentNode = thisNode;
            }
        }
Esempio n. 3
0
 public bool DoesCallStackContainAddress(ulong addr)
 {
     ulong[] callStack = CallstackTab.GetCallStack(m_callStackCRC);
     for (int i = 0; i < callStack.Length; ++i)
     {
         if (callStack[i] == addr)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 4
0
 public int FindFirstValidSymbolIndex(ulong addr)
 {
     ulong[] callStack = CallstackTab.GetCallStack(m_callStackCRC);
     for (int i = 0; i < callStack.Length; ++i)
     {
         if (callStack[i] == addr && IsSymbolValid(i, callStack))
         {
             return(i);
         }
     }
     return(-1);
 }
Esempio n. 5
0
        void AddAllocationPoint(MemBlock block, MemBlockTree tree)
        {
            int rootIndex = block.FindFirstValidSymbolIndex();

            if (rootIndex < 0)
            {
                return;
            }

            ulong[] callStack = CallstackTab.GetCallStack(block.m_callStackCRC);
            for (int i = rootIndex; i < callStack.Length; ++i)
            {
                IStackTracer.Symbol symbol = MemTracerForm.ms_MainForm.StackTracer.GetSymbolForAddress(callStack[i]);
                if (symbol.functionName == null)
                {
                    continue;
                }
                int rowIndex = FindRowIndexForCallerAddress(callStack[i]);
                if (rowIndex >= 0)
                {
                    //AllocInfo allocInfo = dataGridAllocs.Rows[rowIndex].Tag as AllocInfo;
                    //allocInfo.numBytes += (int)block.m_size;
                    //++allocInfo.numBlocks;
                }
                else
                {
                    //MemBlockTree.Node node = tree.Root.FindChildByCallAddress(callStack[i], true);
                    List <MemBlockTree.Node> nodes = new List <MemBlockTree.Node>();
                    tree.Root.CollectChildrenByCallAddress(callStack[i], true, nodes);

                    AllocInfo allocInfo = new AllocInfo();
                    allocInfo.symbol  = symbol;
                    allocInfo.address = callStack[i];

                    foreach (MemBlockTree.Node node in nodes)
                    {
                        allocInfo.numBytes  += (int)node.GetAllocatedSize();
                        allocInfo.numBlocks += node.GetNumAllocatedBlocks();
                    }

                    String[] rowData = { symbol.functionName, allocInfo.numBytes.ToString(), allocInfo.numBlocks.ToString(), "" };
                    dataGridAllocs.Rows.Add(rowData);
                    //allocInfo.numBytes = (int)node.GetAllocatedSize();
                    //allocInfo.numBlocks = node.GetNumAllocatedBlocks();
                    dataGridAllocs.Rows[dataGridAllocs.Rows.Count - 1].Tag = allocInfo;
                }
            }
        }
Esempio n. 6
0
        void AddAlloc(MemBlock mb)
        {
            string opText = "Alloc: " + mb.m_size + " byte(s) at " + mb.m_address.ToString("X") + " (" +
                            mb.GetTagString() + ")";

            treeView1.Nodes.Add(opText);
            TreeNode n = treeView1.Nodes[treeView1.Nodes.Count - 1];

            ulong[] callStack = CallstackTab.GetCallStack(mb.m_callStackCRC);
            foreach (uint callStackEntry in callStack)
            {
                IStackTracer.Symbol symbol = MemTracerForm.ms_MainForm.StackTracer.GetSymbolForAddress(callStackEntry);
                if (symbol.functionName != null)
                {
                    n.Nodes.Add(symbol.functionName);
                    n = n.Nodes[n.Nodes.Count - 1];
                }
            }
            ++m_numAllocated;
            m_bytesAllocated += mb.m_size;
        }