/* 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 dnSpy.Debugger.DotNet.Metadata; namespace dnSpy.Debugger.DotNet.Interpreter { /// /// Class implemented by the debugger. It provides access to the debugged process' locals, /// arguments, allows calling methods etc. /// public abstract class DebuggerRuntime { /// /// Gets the size of a pointer in bytes /// public abstract int PointerSize { get; } /// /// Called before executing the method /// /// Method /// Method body public abstract void Initialize(DmdMethodBase method, DmdMethodBody body); /// /// Gets an argument value or returns null on failure /// /// Argument index /// public abstract ILValue? LoadArgument(int index); /// /// Gets a local value or returns null on failure /// /// Local index /// public abstract ILValue? LoadLocal(int index); /// /// Gets the address of an argument or returns null on failure /// /// Argument index /// Type of the argument /// public abstract ILValue? LoadArgumentAddress(int index, DmdType type); /// /// Gets the address of a local or returns null on failure /// /// Local index /// Type of the local /// public abstract ILValue? LoadLocalAddress(int index, DmdType type); /// /// Writes to an argument or returns false on failure /// /// Argument index /// Type of the argument /// New value public abstract bool StoreArgument(int index, DmdType type, ILValue value); /// /// Writes to a local or returns false on failure /// /// Local index /// Type of the local /// New value public abstract bool StoreLocal(int index, DmdType type, ILValue value); /// /// Creates an SZ array or returns null on failure /// /// Element type /// Number of elements /// public abstract ILValue? CreateSZArray(DmdType elementType, long length); /// /// Creates a value or returns null on failure /// /// Type /// public abstract ILValue? CreateRuntimeTypeHandle(DmdType type); /// /// Creates a value or returns null on failure /// /// Field /// public abstract ILValue? CreateRuntimeFieldHandle(DmdFieldInfo field); /// /// Creates a value or returns null on failure /// /// Method /// public abstract ILValue? CreateRuntimeMethodHandle(DmdMethodBase method); /// /// Creates a type without calling its constructor or returns null on failure. All fields are initialized to 0 or null depending on field type /// /// Type to create /// public abstract ILValue? CreateTypeNoConstructor(DmdType type); /// /// Boxes a value or returns null on failure /// /// Value to box /// Target type /// public abstract ILValue? Box(ILValue value, DmdType type); /// /// Calls a static method or returns false on failure /// /// Method to call /// Method arguments /// Return value. It's ignored if the method returns /// public abstract bool CallStatic(DmdMethodBase method, ILValue[] arguments, out ILValue? returnValue); /// /// Creates a new instance and calls its constructor or returns null on failure. The constructor could be a CLR-generated array constructor /// /// Constructor /// Constructor arguments /// public abstract ILValue? CreateInstance(DmdConstructorInfo ctor, ILValue[] arguments); /// /// Calls a static method or returns false on failure /// /// Method address /// Method signature /// Method arguments /// Return value. It's ignored if the method returns /// public abstract bool CallStaticIndirect(DmdMethodSignature methodSig, ILValue methodAddress, ILValue[] arguments, out ILValue? returnValue); /// /// Returns the value of a static field or returns null on failure /// /// Field /// public abstract ILValue? LoadStaticField(DmdFieldInfo field); /// /// Returns the address of a static field or returns null on failure /// /// Field /// public abstract ILValue? LoadStaticFieldAddress(DmdFieldInfo field); /// /// Stores a value in a static field or returns false on failure /// /// Field /// Value to store in the field public abstract bool StoreStaticField(DmdFieldInfo field, ILValue value); /// /// Returns a new string value /// /// String type /// String value. This is never null. /// public abstract ILValue LoadString(DmdType type, string value); /// /// Compares and , returning less than 0, 0 or greater than 0. /// This method is called if one of the inputs is a non-constant native int or by-ref. /// /// Left operand /// Right operand /// public abstract int? CompareSigned(ILValue left, ILValue right); /// /// Compares and , returning less than 0, 0 or greater than 0. /// This method is called if one of the inputs is a non-constant native int or by-ref. /// /// Left operand /// Right operand /// public abstract int? CompareUnsigned(ILValue left, ILValue right); /// /// Checks if equals or returns null on failure /// /// Left operand /// Right operand /// public abstract bool? Equals(ILValue left, ILValue right); /// /// Gets the size of a value type /// /// Value type /// public abstract int GetSizeOfValueType(DmdType type); } #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public enum LoadValueType { I, I1, I2, I4, I8, R4, R8, Ref, U1, U2, U4, } #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member }