/*
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;
namespace dnSpy.Contracts.Debugger.Steppers {
///
/// Steps into, over or out of a method
///
public abstract class DbgStepper : DbgObject {
///
/// Gets the process
///
public DbgProcess Process => Thread.Process;
///
/// Gets the runtime
///
public DbgRuntime Runtime => Thread.Runtime;
///
/// Gets the thread
///
public abstract DbgThread Thread { get; }
///
/// true if it's possible to call (eg. process must be paused)
///
public abstract bool CanStep { get; }
///
/// true if has been called but hasn't been raised yet
///
public abstract bool IsStepping { get; }
///
/// Raised when the step is complete
///
public abstract event EventHandler? StepComplete;
///
/// Steps once. This method can be called again once is raised.
/// The method can only be called when its process is paused.
///
/// Step kind
/// true to call once is raised
public abstract void Step(DbgStepKind step, bool autoClose = false);
///
/// Cancels the step
///
public abstract void Cancel();
///
/// Closes the stepper and cancels
///
public abstract void Close();
}
///
/// Step complete event args
///
public readonly struct DbgStepCompleteEventArgs {
///
/// Gets the thread
///
public DbgThread Thread { get; }
///
/// Gets the error message or null if none
///
public string? Error { get; }
///
/// true if there was an error
///
public bool HasError => Error is not null;
///
/// Constructor
///
/// Thread
/// Error message or null if none
public DbgStepCompleteEventArgs(DbgThread thread, string? error) {
Thread = thread ?? throw new ArgumentNullException(nameof(thread));
Error = error;
}
}
}