Example #1
0
        internal void ThreadExitedEvent(int id)
        {
            DebuggedThread thread = null;

            lock (_threadList)
            {
                thread = _threadList.Find(t => t.Id == id);
                if (thread != null)
                {
                    DeadThreads.Add(thread);
                    _threadList.Remove(thread);
                    _stateChange = true;
                }
                foreach (var g in _threadGroups)
                {
                    if (g.Value.Contains(id))
                    {
                        g.Value.Remove(id);
                        break;
                    }
                }
            }
            if (thread != null)
            {
                SendThreadEvents(null, null);
            }
        }
Example #2
0
        private async Task <ThreadContext> CollectThreadsInfo(int cxtThreadId)
        {
            ThreadContext ret = null;
            // set of threads has changed or thread locations have been asked for
            Results threadsinfo = await _debugger.MICommandFactory.ThreadInfo();

            if (threadsinfo.ResultClass != ResultClass.done)
            {
                Debug.Fail("Failed to get thread info");
            }
            else
            {
                var tlist = threadsinfo.Find <ValueListValue>("threads");

                // update our thread list
                lock (_threadList)
                {
                    foreach (var thread in _threadList)
                    {
                        thread.Alive = false;
                    }

                    foreach (var t in tlist.Content)
                    {
                        bool bNew     = false;
                        var  thread   = SetThreadInfoFromResultValue(t, out bNew);
                        int  threadId = thread.Id;

                        if (bNew)
                        {
                            NewThreads.Add(thread);
                        }

                        TupleValue[] frames = ((TupleValue)t).FindAll <TupleValue>("frame");

                        if (frames.Any())
                        {
                            List <ThreadContext> stack = new List <ThreadContext>();
                            stack.AddRange(frames.Select(frame => CreateContext(frame)));

                            _topContext[threadId] = stack[0];
                            if (threadId == cxtThreadId)
                            {
                                ret = _topContext[threadId];
                            }

                            if (stack.Count > 1)
                            {
                                _stackFrames[threadId] = stack;
                            }
                        }
                    }

                    foreach (var thread in _threadList.ToList())
                    {
                        if (!thread.Alive)
                        {
                            DeadThreads.Add(thread);
                            _threadList.Remove(thread);
                        }
                    }

                    _stateChange = false;
                    _full        = true;
                }
            }
            return(ret);
        }