private String GetText(ThreadStack threadStack)
        {
            Int32 osid = threadStack.OsThreadId;
            Int64 ktid = threadStack.KTrhead;

            return("Thread: " + r_manager.GetValue(osid) + " (" + r_manager.GetValue(ktid) + ")");
        }
        private void RefreshWaitedObjects(ThreadStack threadStack)
        {
            List <WaitBlock> newWaitedNodes = new List <WaitBlock>(threadStack.WaitBlocks.Values);

            int countOld = r_waitedNodes.Count;
            int countNew = newWaitedNodes.Count;
            int to       = countNew;

            if (countNew < countOld)
            {
                for (int i = countNew; i < countOld; ++i)
                {
                    r_ownedNodes[countNew].Remove();
                    r_ownedNodes.RemoveAt(countNew);
                }
            }
            else if (countOld < countNew)
            {
                to = countOld;
                int index = countOld;

                for (int i = 0; i < (countNew - countOld); ++i)
                {
                    WaitBlock objectAddress = newWaitedNodes[index];
                    ThreadStackWaitedOnNode waitedOnNode = new ThreadStackWaitedOnNode(r_manager, r_threadStackNode, index, objectAddress);
                    r_waitedNodes.Add(waitedOnNode);
                    ++index;
                }
            }

            for (int i = 0; i < to; ++i)
            {
                r_waitedNodes[i].Refresh(newWaitedNodes[i]);
            }
        }
Example #3
0
        public void Poke_does_not_modify_StackPointer()
        {
            var uut = new ThreadStack();

            uut.Poke(Variable.One);
            uut.StackPointer.Should().Be(0);
        }
        private String GetText(ThreadStack threadStack)
        {
            Int32 osid = threadStack.OsThreadId;
            Int64 ktid = threadStack.KTrhead;

            return "Thread: " + r_manager.GetValue(osid) + " (" + r_manager.GetValue(ktid) + ")";
        }
        void AddChildren(ThreadStack parent)
        {
            if (parent.ThreadStackChildren == null || parent.ThreadStackChildren.Count == 0)
            {
                return;
            }

            foreach (var ts in parent.ThreadStackChildren)
            {
                if (ts == null)
                {
                    continue;
                }

                graph.AddVertex(ts);
                graph.AddEdge(new ParallelStacksEdge(parent, ts));

                if (ts.ThreadStackChildren == null || ts.ThreadStackChildren.Count == 0)
                {
                    continue;
                }

                AddChildren(ts);
            }
        }
        void CreateThreadStack(Thread thread)
        {
            var items = CreateItems(thread);

            if (items == null || items.Count == 0)
            {
                return;
            }

            ThreadStack threadStack = new ThreadStack();

            threadStack.StackSelected += OnThreadStackSelected;
            threadStack.FrameSelected += OnFrameSelected;
            threadStack.Process        = debuggedProcess;
            threadStack.ItemCollection = items;
            threadStack.UpdateThreadIds(parallelStacksView == ParallelStacksView.Tasks, thread.ID);

            if (debuggedProcess.SelectedThread != null)
            {
                threadStack.IsSelected = threadStack.ThreadIds.Contains(debuggedProcess.SelectedThread.ID);
                if (selectedFrame == null)
                {
                    selectedFrame = debuggedProcess.SelectedStackFrame;
                }
            }

            currentThreadStacks.Add(threadStack);
        }
Example #7
0
        public void BasePointer_is_modifiable()
        {
            var uut = new ThreadStack();

            uut.BasePointer = 1;
            uut.BasePointer.Should().Be(1);
        }
Example #8
0
        public void Push_Increments_StackPointer()
        {
            var uut = new ThreadStack();

            uut.Push(Variable.Null);
            uut.StackPointer.Should().Be(1);
        }
        private void RefreshChildren(ThreadStack threadStack)
        {
            RefreshWaitedObjects(threadStack);

            RefreshOwnedObjects(threadStack);

            RefreshFrames(threadStack.StackFrames);
        }
        private void RefreshChildren(ThreadStack threadStack)
        {
            r_waitedOnNode.Refresh(threadStack);

            RefreshOwnedObjects(threadStack);

            RefreshFrames(threadStack.Frames);
        }
        private void RefreshChildren(ThreadStack threadStack)
        {
            RefreshWaitedObjects(threadStack);

            RefreshOwnedObjects(threadStack);

            RefreshFrames(threadStack.StackFrames);
        }
Example #12
0
        public void Pop_decrements_StackPointer()
        {
            var uut = new ThreadStack();

            uut.Push(Variable.One);
            uut.Pop();
            uut.StackPointer.Should().Be(0);
        }
        private void RefreshChildren(ThreadStack threadStack)
        {
            r_waitedOnNode.Refresh(threadStack);

            RefreshOwnedObjects(threadStack);

            RefreshFrames(threadStack.Frames);
        }
Example #14
0
        public void Can_Pop_a_pushed_item()
        {
            var uut = new ThreadStack();

            uut.Push(Variable.One);
            var result = uut.Pop();

            result.Should().Be(Variable.One);
        }
Example #15
0
        public void Pop_with_param_decrements_StackPointer_by_same_value()
        {
            var uut = new ThreadStack();

            uut.Push(Variable.One);
            uut.Push(2);
            uut.Pop(2);
            uut.StackPointer.Should().Be(0);
        }
Example #16
0
        public void Poke_modifies_top_value()
        {
            var uut = new ThreadStack();

            uut.Poke(Variable.One);
            var result = uut.Peek();

            result.Should().Be(Variable.One);
        }
Example #17
0
        public void Peek_with_param_returns_the_item_offset_from_StackPointer()
        {
            var uut = new ThreadStack();

            uut.Push(Variable.One);
            uut.Push(2);
            var result = uut.Peek(-2);

            result.Should().Be(Variable.One);
        }
Example #18
0
        public void Pop_with_param_returns_the_correct_item()
        {
            var uut = new ThreadStack();

            uut.Push(Variable.One);
            uut.Push(2);
            var result = uut.Pop(2);

            result.Should().Be(Variable.One);
        }
Example #19
0
        public void PeekAbsreturns_the_item_at_offset()
        {
            var uut = new ThreadStack();

            uut.Push(Variable.One);
            uut.Push(2);
            var result = uut.PeekAbs(0);

            result.Should().Be(Variable.One);
        }
Example #20
0
        public void Peek_returns_the_top_item()
        {
            var uut = new ThreadStack();

            uut.Push(Variable.One);
            uut.Push(2);
            var result = uut.Peek();

            result.Should().BeNull();
        }
 private String GetText(Dictionary <UInt32, ThreadStack> threadStacks)
 {
     Dictionary <UInt32, ThreadStack> .Enumerator enumer = threadStacks.GetEnumerator();
     if (enumer.MoveNext())
     {
         ThreadStack threadStack = enumer.Current.Value;
         return("AppDomain (" + r_manager.GetValue(threadStack.DomainId) + ") " + threadStack.DomainName);
     }
     return(r_appDomainNode.Text);
 }
Example #22
0
        public void PokeAbs_modifies_the_item_at_offset()
        {
            var uut = new ThreadStack();

            uut.Push(Variable.One);
            uut.Push(2);
            uut.PokeAbs(1, 15);
            var result = uut.PeekAbs(1);

            result.GetInteger().Should().Be(15);
        }
Example #23
0
        public void Poke_with_param_modifies_the_item_offset_from_StackPointer()
        {
            var uut = new ThreadStack();

            uut.Push(Variable.One);
            uut.Push(2);
            uut.Poke(-2, 15);
            var result = uut.Peek(-2);

            result.GetInteger().Should().Be(15);
        }
Example #24
0
        public void PeekBase_returns_the_item_at_offset_from_BasePointer()
        {
            var uut = new ThreadStack();

            uut.Push(Variable.One);
            uut.Push(2);
            uut.BasePointer = 1;
            var result = uut.PeekBase(-1);

            result.Should().Be(Variable.One);
        }
Example #25
0
        public void PeekBase_with_zero_returns_the_item_at_BasePointer()
        {
            var uut = new ThreadStack();

            uut.Push(Variable.One);
            uut.Push(2);
            uut.BasePointer = 1;
            var result = uut.PeekBase(0);

            result.GetInteger().Should().Be(2);
        }
Example #26
0
        public void PokeBase_modifes_the_item_at_offset_from_BasePointer()
        {
            var uut = new ThreadStack();

            uut.Push(Variable.One);
            uut.Push(2);
            uut.BasePointer = 1;
            uut.PokeBase(-1, 5);
            var result = uut.PeekBase(-1);

            result.GetInteger().Should().Be(5);
        }
        public void Refresh(List <ThreadStack> threadStacks)
        {
            Dictionary <UInt64, Dictionary <UInt32, ThreadStack> > segregated = new Dictionary <UInt64, Dictionary <UInt32, ThreadStack> >();

            for (int i = 0; i < threadStacks.Count; ++i)
            {
                ThreadStack tStack = threadStacks[i];
                Dictionary <UInt32, ThreadStack> tStacks;
                UInt64 did = tStack.DomainId;
                if (!(segregated.TryGetValue(did, out tStacks)))
                {
                    tStacks = new Dictionary <UInt32, ThreadStack>();
                    segregated.Add(did, tStacks);
                }
                tStacks.Add(tStack.OsThreadId, tStack);
            }

            List <UInt64> appDomainsNoLonger = new List <UInt64>();

            foreach (KeyValuePair <UInt64, AppDomainNode> pair in r_appDomainNodes)
            {
                UInt64        oldId     = pair.Key;
                AppDomainNode oldDomain = pair.Value;
                Dictionary <UInt32, ThreadStack> tStacks;
                if (segregated.TryGetValue(oldId, out tStacks))
                {
                    oldDomain.Refresh(tStacks);
                }
                else
                {
                    oldDomain.Remove();
                    appDomainsNoLonger.Add(oldId);
                }
            }

            foreach (UInt64 key in appDomainsNoLonger)
            {
                r_appDomainNodes.Remove(key);
            }

            foreach (KeyValuePair <UInt64, Dictionary <UInt32, ThreadStack> > pair in segregated)
            {
                UInt64        newId = pair.Key;
                AppDomainNode appDomainNode;
                if (!r_appDomainNodes.TryGetValue(newId, out appDomainNode))
                {
                    appDomainNode = new AppDomainNode(r_manager, r_rootNode, pair.Value);
                    r_appDomainNodes.Add(newId, appDomainNode);
                }
            }
        }
        internal ThreadStackNode(ThreadStackNodeManager manager, TreeNode appDomainNode, ThreadStack threadStack)
        {
            if (appDomainNode == null)
                throw new ArgumentNullException("appDomainNode");

            if (manager == null)
                throw new ArgumentNullException("manager");

            r_manager = manager;
            r_appDomainNode = appDomainNode;

            String text = GetText(threadStack);
            r_threadStackNode = appDomainNode.Nodes.Add(text);
            r_threadStackNode.ImageKey = "cog.png";
            r_threadStackNode.SelectedImageKey = r_threadStackNode.ImageKey;
            r_threadStackNode.Tag = this;
            r_waitedOnNode = new ThreadStackWaitedOnNode(r_manager, r_threadStackNode);
            r_ownedNodes = new List<ThreadStackOwnedNode>();
            r_frameNodes = new List<ThreadStackFrameNode>();

            RefreshChildren(threadStack);
        }
 internal void Refresh(ThreadStack threadStack)
 {
     if (threadStack.SyncBlockObjectWaitedOn > 0)
     {
         if (_waitedOnNode == null)
         {
             _waitedOnNode                  = r_threadStackNode.Nodes.Insert(0, GetText(threadStack));
             _waitedOnNode.ImageKey         = "hourglass.png";
             _waitedOnNode.SelectedImageKey = _waitedOnNode.ImageKey;
             _waitedOnNode.Tag              = this;
         }
         else
         {
             _waitedOnNode.Text = GetText(threadStack);
         }
     }
     else if (_waitedOnNode != null)
     {
         _waitedOnNode.Tag = null;
         _waitedOnNode.Remove();
         _waitedOnNode = null;
     }
 }
 internal void Refresh(ThreadStack threadStack)
 {
     if (threadStack.SyncBlockObjectWaitedOn > 0)
     {
         if (_waitedOnNode == null)
         {
             _waitedOnNode = r_threadStackNode.Nodes.Insert(0, GetText(threadStack));
             _waitedOnNode.ImageKey = "hourglass.png";
             _waitedOnNode.SelectedImageKey = _waitedOnNode.ImageKey;
             _waitedOnNode.Tag = this;
         }
         else
         {
             _waitedOnNode.Text = GetText(threadStack);
         }
     }
     else if (_waitedOnNode != null)
     {
         _waitedOnNode.Tag = null;
         _waitedOnNode.Remove();
         _waitedOnNode = null;
     }
 }
        private void RefreshOwnedObjects(ThreadStack threadStack)
        {
            List <UInt64> newOwnedNodes = threadStack.SyncBlockObjectsOwned;

            int indexDelta = r_waitedOnNode.Ordinal;
            int countOld   = r_ownedNodes.Count;
            int countNew   = newOwnedNodes.Count;
            int to         = countNew;

            if (countNew < countOld)
            {
                for (int i = countNew; i < countOld; ++i)
                {
                    r_ownedNodes[countNew].Remove();
                    r_ownedNodes.RemoveAt(countNew);
                }
            }
            else if (countOld < countNew)
            {
                to = countOld;
                int index = countOld;

                for (int i = 0; i < (countNew - countOld); ++i)
                {
                    UInt64 objectAddress           = newOwnedNodes[index];
                    ThreadStackOwnedNode ownedNode = new ThreadStackOwnedNode(r_manager, r_threadStackNode, index + indexDelta, objectAddress);
                    r_ownedNodes.Add(ownedNode);
                    ++index;
                }
            }

            for (int i = 0; i < to; ++i)
            {
                r_ownedNodes[i].Refresh(newOwnedNodes[i]);
            }
        }
        private void RefreshWaitedObjects(ThreadStack threadStack)
        {
            List<WaitBlock> newWaitedNodes = new List<WaitBlock>(threadStack.WaitBlocks.Values);

            int countOld = r_waitedNodes.Count;
            int countNew = newWaitedNodes.Count;
            int to = countNew;

            if (countNew < countOld)
            {
                for (int i = countNew; i < countOld; ++i)
                {
                    r_ownedNodes[countNew].Remove();
                    r_ownedNodes.RemoveAt(countNew);
                }
            }
            else if (countOld < countNew)
            {
                to = countOld;
                int index = countOld;

                for (int i = 0; i < (countNew - countOld); ++i)
                {
                    WaitBlock objectAddress = newWaitedNodes[index];
                    ThreadStackWaitedOnNode waitedOnNode = new ThreadStackWaitedOnNode(r_manager, r_threadStackNode, index, objectAddress);
                    r_waitedNodes.Add(waitedOnNode);
                    ++index;
                }
            }

            for (int i = 0; i < to; ++i)
            {
                r_waitedNodes[i].Refresh(newWaitedNodes[i]);
            }
        }
 internal void Refresh(ThreadStack threadStack)
 {
     RefreshMe(threadStack);
     RefreshChildren(threadStack);
 }
 private String GetText(ThreadStack threadStack)
 {
     uint osid = threadStack.OsThreadId;
     return "Thread: " + r_manager.GetValue(osid) + " " + r_manager.GetThreadName((int)osid);
 }
 internal void Refresh(ThreadStack threadStack)
 {
     RefreshMe(threadStack);
     RefreshChildren(threadStack);
 }
        void CreateCommonStacks()
        {
            // stack.ItemCollection     order
            // 0 -> top of stack        = S.C
            // 1 -> ............        = S.B
            // .......................
            // n -> bottom of stack     = [External Methods]

            // ThreadStacks with common frame
            var commonFrameThreads = new Dictionary <string, List <ThreadStack> >();

            bool isOver = false;

            while (true)
            {
                for (int i = currentThreadStacks.Count - 1; i >= 0; --i)
                {
                    var stack = currentThreadStacks[i];
                    if (stack.ItemCollection.Count == 0)
                    {
                        currentThreadStacks.Remove(stack);
                        continue;
                    }
                }
                //get all thread stacks with common start frame
                foreach (var stack in currentThreadStacks)
                {
                    int count = stack.ItemCollection.Count;
                    ParallelStackFrameModel frame = stack.ItemCollection[count - 1];
                    string fullname = frame.MethodName + stack.Level.ToString();

                    if (!commonFrameThreads.ContainsKey(fullname))
                    {
                        commonFrameThreads.Add(fullname, new List <ThreadStack>());
                    }

                    if (!commonFrameThreads[fullname].Contains(stack))
                    {
                        commonFrameThreads[fullname].Add(stack);
                    }
                }

                // for every list of common stacks, find split place and add them to currentThreadStacks
                foreach (var frameName in commonFrameThreads.Keys)
                {
                    var listOfCurrentStacks = commonFrameThreads[frameName];

                    if (listOfCurrentStacks.Count == 1)        // just skip the parents
                    {
                        isOver = true;                         // we finish when all are pseodo-parents: no more spliting
                        continue;
                    }

                    isOver = false;

                    // find the frameIndex where we can split
                    int    frameIndex  = 0;
                    string fn          = string.Empty;
                    bool   canContinue = true;

                    while (canContinue)
                    {
                        for (int i = 0; i < listOfCurrentStacks.Count; ++i)
                        {
                            var stack = listOfCurrentStacks[i];
                            if (stack.ItemCollection.Count == frameIndex)
                            {
                                canContinue = false;
                                break;
                            }

                            ParallelStackFrameModel item = stack.ItemCollection[stack.ItemCollection.Count - frameIndex - 1];

                            string currentName = item.MethodName;

                            if (i == 0)
                            {
                                fn = currentName;
                                continue;
                            }

                            if (fn == currentName)
                            {
                                continue;
                            }
                            else
                            {
                                canContinue = false;
                                break;
                            }
                        }
                        if (canContinue)
                        {
                            frameIndex++;
                        }
                    }

                    // remove last [frameIndex] and create a new ThreadStack as the parent of what remained in the children
                    var threadIds   = new List <uint>();
                    var parentItems = new Stack <ParallelStackFrameModel>();

                    while (frameIndex > 0)
                    {
                        for (int i = 0; i < listOfCurrentStacks.Count; ++i)
                        {
                            var stack         = listOfCurrentStacks[i];
                            int indexToRemove = stack.ItemCollection.Count - 1;

                                                        #if DEBUG
                            ParallelStackFrameModel d_item = stack.ItemCollection[indexToRemove];
                            string name = d_item.MethodName;
                                                        #endif
                            if (i == 0)
                            {
                                parentItems.Push(stack.ItemCollection[indexToRemove]);
                            }

                            stack.ItemCollection.RemoveAt(indexToRemove);
                        }

                        frameIndex--;
                    }

                    // update thread ids
                    for (int i = 0; i < listOfCurrentStacks.Count; ++i)
                    {
                        threadIds.AddRange(listOfCurrentStacks[i].ThreadIds);
                    }

                    // remove stacks with no items
                    for (int i = listOfCurrentStacks.Count - 1; i >= 0; --i)
                    {
                        var stack = listOfCurrentStacks[i];
                        if (stack.ItemCollection.Count == 0)
                        {
                            listOfCurrentStacks.Remove(stack);
                        }
                    }

                    // increase the Level
                    for (int i = 0; i < listOfCurrentStacks.Count; ++i)
                    {
                        listOfCurrentStacks[i].Level++;
                    }

                    // create new parent stack
                    ThreadStack commonParent = new ThreadStack();
                    commonParent.UpdateThreadIds(parallelStacksView == ParallelStacksView.Tasks, threadIds.ToArray());
                    commonParent.ItemCollection = parentItems.ToObservable();
                    commonParent.Process        = debuggedProcess;
                    commonParent.StackSelected += OnThreadStackSelected;
                    commonParent.FrameSelected += OnFrameSelected;
                    commonParent.IsSelected     = commonParent.ThreadIds.Contains(debuggedProcess.SelectedThread.ID);
                    // add new children
                    foreach (var stack in listOfCurrentStacks)
                    {
                        if (stack.ItemCollection.Count == 0)
                        {
                            currentThreadStacks.Remove(stack);
                            continue;
                        }
                        ParallelStackFrameModel item = stack.ItemCollection[stack.ItemCollection.Count - 1];
                        // add the parent to the parent
                        if (stack.ThreadStackParents != null)
                        {
                            // remove stack from it's parent because it will have the commonParent as parent
                            stack.ThreadStackParents[0].ThreadStackChildren.Remove(stack);
                            commonParent.ThreadStackParents = stack.ThreadStackParents.Clone();
                            commonParent.ThreadStackParents[0].ThreadStackChildren.Add(commonParent);
                            // set level
                            commonParent.Level = stack.Level - 1;
                        }
                        else
                        {
                            stack.ThreadStackParents = new List <ThreadStack>();
                        }

                        // update thread ids
                        if (commonParent.ThreadStackParents != null)
                        {
                            commonParent.ThreadStackParents[0].UpdateThreadIds(
                                parallelStacksView == ParallelStacksView.Tasks,
                                commonParent.ThreadIds.ToArray());
                        }

                        stack.ThreadStackParents.Clear();
                        stack.ThreadStackParents.Add(commonParent);
                        string currentName = item.MethodName + stack.Level.ToString();;

                        // add name or add to list
                        if (!commonFrameThreads.ContainsKey(currentName))
                        {
                            var newList = new List <ThreadStack>();
                            newList.Add(stack);
                            commonFrameThreads.Add(currentName, newList);
                        }
                        else
                        {
                            var list = commonFrameThreads[currentName];
                            list.Add(stack);
                        }
                    }

                    commonParent.ThreadStackChildren = listOfCurrentStacks.Clone();
                    commonFrameThreads[frameName].Clear();
                    commonFrameThreads[frameName].Add(commonParent);
                    currentThreadStacks.Add(commonParent);

                    // exit and retry
                    break;
                }

                if (isOver || currentThreadStacks.Count == 0)
                {
                    break;
                }
            }
        }
        private void RefreshOwnedObjects(ThreadStack threadStack)
        {
            List<UInt64> newOwnedNodes = threadStack.SyncBlockObjectsOwned;

            int indexDelta = r_waitedOnNode.Ordinal;
            int countOld = r_ownedNodes.Count;
            int countNew = newOwnedNodes.Count;
            int to = countNew;

            if (countNew < countOld)
            {
                for (int i = countNew; i < countOld; ++i)
                {
                    r_ownedNodes[countNew].Remove();
                    r_ownedNodes.RemoveAt(countNew);
                }
            }
            else if (countOld < countNew)
            {
                to = countOld;
                int index = countOld;

                for (int i = 0; i < (countNew - countOld); ++i)
                {
                    UInt64 objectAddress = newOwnedNodes[index];
                    ThreadStackOwnedNode ownedNode = new ThreadStackOwnedNode(r_manager, r_threadStackNode, index+indexDelta, objectAddress);
                    r_ownedNodes.Add(ownedNode);
                    ++index;
                }
            }

            for (int i = 0; i < to; ++i)
            {
                r_ownedNodes[i].Refresh(newOwnedNodes[i]);
            }
        }
        void CreateMethodViewStacks()
        {
            var list = new List <Tuple <ObservableCollection <ParallelStackFrameModel>, ObservableCollection <ParallelStackFrameModel>, List <uint> > >();

            // find all threadstacks that contains the selected frame
            for (int i = currentThreadStacks.Count - 1; i >= 0; --i)
            {
                var tuple = currentThreadStacks[i].ItemCollection.SplitStack(selectedFrame, currentThreadStacks[i].ThreadIds);
                if (tuple != null)
                {
                    list.Add(tuple);
                }
            }

            currentThreadStacks.Clear();

            // common
            ThreadStack             common = new ThreadStack();
            var                     observ = new ObservableCollection <ParallelStackFrameModel>();
            bool                    dummy  = false;
            ParallelStackFrameModel obj    = CreateItemForFrame(selectedFrame, ref dummy);

            obj.Image = PresentationResourceService.GetImage("Icons.48x48.CurrentFrame").Source;
            observ.Add(obj);
            common.ItemCollection = observ;
            common.StackSelected += OnThreadStackSelected;
            common.FrameSelected += OnFrameSelected;
            common.UpdateThreadIds(parallelStacksView == ParallelStacksView.Tasks, selectedFrame.Thread.ID);
            common.Process             = debuggedProcess;
            common.ThreadStackChildren = new List <ThreadStack>();
            common.ThreadStackParents  = new List <ThreadStack>();

            // for all thread stacks, split them in 2 :
            // one that invokes the method frame, second that get's invoked by current method frame
            foreach (var tuple in list)
            {
                // add top
                if (tuple.Item1.Count > 0)
                {
                    ThreadStack topStack = new ThreadStack();
                    topStack.ItemCollection = tuple.Item1;
                    topStack.StackSelected += OnThreadStackSelected;
                    topStack.FrameSelected += OnFrameSelected;
                    topStack.UpdateThreadIds(parallelStacksView == ParallelStacksView.Tasks, tuple.Item3.ToArray());
                    topStack.Process            = debuggedProcess;
                    topStack.ThreadStackParents = new List <ThreadStack>();
                    topStack.ThreadStackParents.Add(common);

                    currentThreadStacks.Add(topStack);
                    common.ThreadStackChildren.Add(topStack);
                }

                // add bottom
                if (tuple.Item2.Count > 0)
                {
                    ThreadStack bottomStack = new ThreadStack();
                    bottomStack.ItemCollection = tuple.Item2;
                    bottomStack.StackSelected += OnThreadStackSelected;
                    bottomStack.FrameSelected += OnFrameSelected;
                    bottomStack.UpdateThreadIds(parallelStacksView == ParallelStacksView.Tasks, tuple.Item3.ToArray());
                    bottomStack.Process             = debuggedProcess;
                    bottomStack.ThreadStackChildren = new List <ThreadStack>();
                    bottomStack.ThreadStackChildren.Add(common);
                    common.UpdateThreadIds(parallelStacksView == ParallelStacksView.Tasks, tuple.Item3.ToArray());
                    common.ThreadStackParents.Add(bottomStack);
                    currentThreadStacks.Add(bottomStack);
                }
            }

            currentThreadStacks.Add(common);
            common.IsSelected = true;
        }
 private String GetText(ThreadStack threadStack)
 {
     return "Waiting On (" + r_manager.GetValue(threadStack.SyncBlockObjectWaitedOn) + ") " + threadStack.SyncBlockObjectWaitedOnName;
 }
        ObservableCollection <ParallelStackFrameModel> CreateItems(Thread thread)
        {
            bool lastItemIsExternalMethod = false;
            int  noTasks   = 0;
            var  result    = new ObservableCollection <ParallelStackFrameModel>();
            var  callstack = thread.GetCallstack(100);

            if (parallelStacksView == ParallelStacksView.Threads)
            {
                foreach (StackFrame frame in callstack)
                {
                    ParallelStackFrameModel obj = CreateItemForFrame(frame, ref lastItemIsExternalMethod);

                    if (obj != null)
                    {
                        result.Add(obj);
                    }
                }
            }
            else
            {
                for (int i = 0; i < callstack.Length; ++i)
                {
                    StackFrame frame            = callstack[i];
                    ParallelStackFrameModel obj = CreateItemForFrame(frame, ref lastItemIsExternalMethod);

                    if (frame.MethodInfo.FullName.IndexOf("System.Threading.Tasks.Task.ExecuteEntry") != -1)
                    {
                        noTasks++;
                    }

                    if (noTasks == 1)
                    {
                        if (frame.HasSymbols)
                        {
                            // create thread stack for the items collected until now
                            ThreadStack threadStack = new ThreadStack();
                            threadStack.StackSelected += OnThreadStackSelected;
                            threadStack.FrameSelected += OnFrameSelected;
                            threadStack.Process        = debuggedProcess;
                            threadStack.ItemCollection = result.Clone();
                            threadStack.UpdateThreadIds(true, frame.Thread.ID);

                            if (debuggedProcess.SelectedThread != null)
                            {
                                threadStack.IsSelected = threadStack.ThreadIds.Contains(debuggedProcess.SelectedThread.ID);
                                if (selectedFrame == null)
                                {
                                    selectedFrame = debuggedProcess.SelectedStackFrame;
                                }
                            }

                            currentThreadStacks.Add(threadStack);
                            // reset
                            result.Clear();
                            noTasks = 0;
                        }
                    }

                    if (obj != null)
                    {
                        result.Add(obj);
                    }
                }

                // return null if we are dealing with a simple thread
                return(noTasks == 0 ? null : result);
            }

            return(result);
        }
 private void RefreshMe(ThreadStack threadStack)
 {
     r_threadStackNode.Text = GetText(threadStack);
 }