Beispiel #1
0
        void UpdateFrames_DbgThread()
        {
            dbgManager.Dispatcher.VerifyAccess();
            bool           raiseActiveFrameIndexChanged, raiseFramesChanged;
            DbgStackWalker stackWalker = null;

            DbgStackFrame[] newFrames = null;
            try {
                var thread = dbgManager.CurrentThread.Current;
                if (thread == null || thread.Process.State != DbgProcessState.Paused)
                {
                    newFrames = Array.Empty <DbgStackFrame>();
                }
                else
                {
                    stackWalker = thread.CreateStackWalker();
                    newFrames   = stackWalker.GetNextStackFrames(MaxShownFrames + 1);
                }
                lock (lockObj) {
                    if (frames.Length > 0)
                    {
                        dbgManager.Close(frames);
                    }
                    int newActiveFrameIndex = GetFrameIndex(newFrames);
                    // Always raise frames-changed event even if old and new arrays have 0 length.
                    raiseFramesChanged           = true;
                    raiseActiveFrameIndexChanged = newActiveFrameIndex != activeFrameIndex;

                    // Note that we keep the extra frame so we don't have to create a new array with one less
                    // frame. If we got MaxShownFrames+1 frames, it's not very likely that the last one in the
                    // array is actually the last frame.
                    // Another solution is to create a custom IList<DbgStackFrame> that hides the last one
                    // but that's not worth it.
                    frames           = newFrames;
                    readOnlyFrames   = newFrames.Length == 0 ? emptyFrames : new ReadOnlyCollection <DbgStackFrame>(newFrames);
                    activeFrameIndex = newActiveFrameIndex;
                    framesTruncated  = newFrames.Length > MaxShownFrames;
                }
            }
            finally {
                stackWalker?.Close();
                if (newFrames != null && frames != newFrames && newFrames.Length > 0)
                {
                    dbgManager.Close(newFrames);
                }
            }
            if (raiseFramesChanged || raiseActiveFrameIndexChanged)
            {
                FramesChanged?.Invoke(this, new FramesChangedEventArgs(raiseFramesChanged, raiseActiveFrameIndexChanged));
            }
        }
Beispiel #2
0
 void SetActiveFrameIndex_DbgThread(int newIndex)
 {
     dbgManager.Dispatcher.VerifyAccess();
     lock (lockObj) {
         if (activeFrameIndex == newIndex)
         {
             return;
         }
         if ((uint)newIndex >= (uint)frames.Length)
         {
             return;
         }
         activeFrameIndex = newIndex;
     }
     FramesChanged?.Invoke(this, new FramesChangedEventArgs(framesChanged: false, activeFrameIndexChanged: true));
 }
 /// <summary>
 /// Invokes the <see cref="FramesChanged"/> event.
 /// </summary>
 protected virtual void OnFramesChanged()
 {
     FramesChanged?.Invoke();
 }