/* Copyright (C) 2014-2019 de4dot@gmail.com This file is part of dnSpy dnSpy is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. dnSpy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with dnSpy. If not, see . */ using System; using System.Collections.ObjectModel; namespace dnSpy.Contracts.Debugger.CallStack { /// /// Provides all stack frames shown in the call stack window /// public abstract class DbgCallStackService { /// /// Gets the selected thread. This is identical to /// public abstract DbgThread? Thread { get; } /// /// Index of active thread. This could be invalid if is empty /// public abstract int ActiveFrameIndex { get; set; } /// /// Gets the active frame or null if is empty /// public DbgStackFrame? ActiveFrame => Frames.ActiveStackFrame; /// /// Gets all frames. This is a truncated list if there are too many frames /// public abstract DbgCallStackFramesInfo Frames { get; } /// /// Raised when is changed /// public abstract event EventHandler? FramesChanged; } /// /// Frames changed event args /// public readonly struct FramesChangedEventArgs { /// /// true if there are new frames available /// public bool FramesChanged { get; } /// /// true if active frame index changed /// public bool ActiveFrameIndexChanged { get; } /// /// Constructor /// /// true if there are new frames available /// true if active frame index changed public FramesChangedEventArgs(bool framesChanged, bool activeFrameIndexChanged) { FramesChanged = framesChanged; ActiveFrameIndexChanged = activeFrameIndexChanged; } } /// /// Contains the stack frames and related info /// public readonly struct DbgCallStackFramesInfo { /// /// Gets all frames /// public ReadOnlyCollection Frames { get; } /// /// true if there are too many frames and is a truncated list of all frames /// public bool FramesTruncated { get; } /// /// Index of active thread. This could be invalid if is empty /// public int ActiveFrameIndex { get; } /// /// Gets the active frame or null if is empty /// public DbgStackFrame? ActiveStackFrame => (uint)ActiveFrameIndex < (uint)Frames.Count ? Frames[ActiveFrameIndex] : null; /// /// Constructor /// /// All frames /// true if there are too many frames and is a truncated list of all frames /// Index of active thread. This could be invalid if is empty public DbgCallStackFramesInfo(ReadOnlyCollection frames, bool framesTruncated, int activeFrameIndex) { Frames = frames ?? throw new ArgumentNullException(nameof(frames)); FramesTruncated = framesTruncated; ActiveFrameIndex = activeFrameIndex; } } }