/* 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.Threading; using dnSpy.Contracts.Debugger.CallStack; using dnSpy.Contracts.Debugger.Code; namespace dnSpy.Contracts.Debugger.Evaluation { /// /// Debugger language that evaluates expressions and formats values /// public abstract class DbgLanguage { /// /// Gets the runtime kind GUID, see /// public abstract Guid RuntimeKindGuid { get; } /// /// Gets the language name, see /// public abstract string Name { get; } /// /// Gets the language's display name (shown in the UI) /// public abstract string DisplayName { get; } /// /// Gets the expression evaluator /// public abstract DbgExpressionEvaluator ExpressionEvaluator { get; } /// /// Gets the formatter /// public abstract DbgFormatter Formatter { get; } /// /// Gets the locals and parameters provider /// public abstract DbgLocalsValueNodeProvider LocalsProvider { get; } /// /// Gets the autos provider /// public abstract DbgValueNodeProvider AutosProvider { get; } /// /// Gets the exceptions provider /// public abstract DbgValueNodeProvider ExceptionsProvider { get; } /// /// Gets the return values provider /// public abstract DbgValueNodeProvider ReturnValuesProvider { get; } /// /// Gets the type variables provider /// public abstract DbgValueNodeProvider TypeVariablesProvider { get; } /// /// Gets the factory /// public abstract DbgValueNodeFactory ValueNodeFactory { get; } /// /// Default func-eval timeout value /// public static readonly TimeSpan DefaultFuncEvalTimeout = TimeSpan.FromSeconds(1); /// /// Creates an evaluation context /// /// Runtime /// Location or null /// Options /// Func-eval timeout (func-eval = calling functions in the debugged process) or default instance to use default timeout value /// Cancellation token /// public abstract DbgEvaluationContext CreateContext(DbgRuntime runtime, DbgCodeLocation? location, DbgEvaluationContextOptions options = DbgEvaluationContextOptions.None, TimeSpan funcEvalTimeout = default, CancellationToken cancellationToken = default); /// /// Creates an evaluation context /// /// Stack frame /// Options /// Func-eval timeout (func-eval = calling functions in the debugged process) or default instance to use default timeout value /// Cancellation token /// public DbgEvaluationContext CreateContext(DbgStackFrame frame, DbgEvaluationContextOptions options = DbgEvaluationContextOptions.None, TimeSpan funcEvalTimeout = default, CancellationToken cancellationToken = default) { if (frame is null) throw new ArgumentNullException(nameof(frame)); return CreateContext(frame.Runtime, frame.Location, options, funcEvalTimeout, cancellationToken); } } /// /// Evaluation context options /// [Flags] public enum DbgEvaluationContextOptions { /// /// No bit is set /// None = 0, /// /// Set if all threads should run when func-evaluating (calling code in the debugged process), /// or cleared if only one thread should run. Usually only one thread is run, but that can /// lead to a deadlock if the thread calls a suspended thread or if it tries to acquire a /// lock owned by a suspended thread. /// RunAllThreads = 0x00000001, /// /// If method body info isn't needed, this option should be used. It prevents decompiling the /// method to get sequence points and other debug info. Can be used when formatting stack frames. /// NoMethodBody = 0x00000002, } }