Beispiel #1
0
        /// <summary>
        /// creates a stack tree for each thread in samples
        /// </summary>
        /// <param name="samples"></param>
        /// <returns>a dictionary of [threadId,StackTreeRoot]</returns>
        public Dictionary<int, StackTreeNode> CreateStackTrees(List<ProcessSample> samples)
        {
            Dictionary<int, StackTreeNode> retval = new Dictionary<int, StackTreeNode>();
            //go over the process samples over time
            foreach (ProcessSample prSample in samples)
            {
                //go over threads in each sample
                foreach (StackSample thSample in prSample.Samples)
                {

                    StackTreeNode rootNode = null;
                    if (!retval.ContainsKey(thSample.ThreadId))
                    {
                        rootNode = new StackTreeNode();
                        retval.Add(thSample.ThreadId, rootNode);
                    }
                    else
                    {
                        rootNode = retval[thSample.ThreadId];
                    }

                    //go over lines in each thread sample
                    StackTreeNode prevNode = rootNode;
                    string prevLine = null;
                    foreach (string line in thSample.CallStack)
                    {
                        prevNode = prevNode.AddToSubTree(prevLine, line);
                        prevLine = line;
                        ++prevNode.StackAppearancesCounter;
                    }
                }
            }
            return retval;
        }
Beispiel #2
0
        /// <summary>
        /// adds the 
        /// </summary>
        /// <param name="parentLine"></param>
        /// <param name="childLine"></param>
        /// <returns></returns>
        public StackTreeNode AddToSubTree(string parentLine, string childLine)
        {
            if (parentLine == null)
            {
                this.Line = childLine;
                return this;
            }

            if (this.Line == parentLine)
            {
                var existingChild = Children.Where(c => c.Line == childLine).FirstOrDefault();
                if (existingChild == null)
                {
                    var node = new StackTreeNode { Line = childLine };
                    Children.Add(node);
                    existingChild = node;
                }
                return existingChild;
            }

            foreach (StackTreeNode childNode in Children)
            {
                return childNode.AddToSubTree(parentLine, childLine);
            }

            return null;
        }
Beispiel #3
0
        public List<StackTreeNode> GetMostTravelledPathInTree(StackTreeNode treeRoot)
        {
            List<StackTreeNode> retVal = new List<StackTreeNode>();
            StackTreeNode currentNode = treeRoot;
            retVal.Add(currentNode);

            while (currentNode.Children.Count > 0)
            {
                int maxAppearences = currentNode.Children.Max(c => c.StackAppearancesCounter);
                //choose the most travelled node
                currentNode = currentNode.Children.Where(c => c.StackAppearancesCounter == maxAppearences).FirstOrDefault();
                retVal.Add(currentNode);
            }
            return retVal;
        }
Beispiel #4
0
        //private void dumpOnUncaughtExceptionToolStripMenuItem_Click(object sender, EventArgs e)
        //{
        //    dumpOnUncaughtExceptionToolStripMenuItem.Checked = !dumpOnUncaughtExceptionToolStripMenuItem.Checked;
        //    DumpOnUncaughtException = dumpOnUncaughtExceptionToolStripMenuItem.Checked;
        //    ProcListener.WriteDumpOnUncaughtExceptions = m_blnDumpOnUncaughtException;
        //    ProcListener.StartListening();
        //}
        private void BuildTreeView(TreeNode parent, StackTreeNode stackTree)
        {
            foreach (StackTreeNode snode in stackTree.Children)
            {
                TreeNode newNode = parent.Nodes.Add(snode.ToString());

                foreach (StackTreeNode schild in snode.Children)
                    BuildTreeView(newNode, schild);
            }
        }