Class CallFrame
- Namespace
- Echo.Platforms.AsmResolver.Emulation.Stack
- Assembly
- Echo.Platforms.AsmResolver.dll
Represents a single frame in a virtual stack.
public class CallFrame : IMemorySpace
- Inheritance
-
CallFrame
- Implements
- Inherited Members
Constructors
CallFrame(IMethodDescriptor, ValueFactory)
Constructs a new call stack frame.
public CallFrame(IMethodDescriptor method, ValueFactory factory)
Parameters
methodIMethodDescriptorThe method that this frame is associated with.
factoryValueFactoryA factory used for measuring the size of the frame.
Exceptions
- ArgumentException
Occurs when the provided method is invalid or contains invalid metadata that could not be dealt with.
Properties
AddressRange
Gets the range that this memory space spans.
public AddressRange AddressRange { get; }
Property Value
Body
Gets the managed body of the method that this frame is associated with (if available).
public CilMethodBody? Body { get; }
Property Value
CanAllocateMemory
Gets a value indicating whether the frame can be extended with extra stack memory.
public bool CanAllocateMemory { get; }
Property Value
ConstrainedType
Gets or sets the current type that the following call instruction is constrained by, if any.
public ITypeDescriptor? ConstrainedType { get; set; }
Property Value
EvaluationStack
Gets a virtual evaluation stack associated stored the frame.
public EvaluationStack EvaluationStack { get; }
Property Value
ExceptionHandlerStack
Gets the stack of currently active exception handler frames in the method.
public ExceptionHandlerStack ExceptionHandlerStack { get; }
Property Value
ExceptionHandlers
Gets a collection of exception handler frames present in the method body.
public IReadOnlyList<ExceptionHandlerFrame> ExceptionHandlers { get; }
Property Value
IsRoot
Gets a value indicating the frame is the root frame of the call stack.
public bool IsRoot { get; }
Property Value
IsTrampoline
Gets a value indicating that the frame is a trampoline, and that it immediately returns the value of the next method on the stack
public bool IsTrampoline { get; set; }
Property Value
LocalsCount
Gets the number of locals stored in the frame.
public int LocalsCount { get; }
Property Value
Method
Gets the method which this frame was associated with.
public IMethodDescriptor Method { get; }
Property Value
ProgramCounter
Gets the offset within the method body of the next instruction to evaluate.
public int ProgramCounter { get; set; }
Property Value
Size
Gets the number of bytes (excluding the evaluation stack) the stack frame spans.
public int Size { get; }
Property Value
Methods
Allocate(int)
Allocates local stack memory in the stack frame.
public long Allocate(int size)
Parameters
sizeint
Returns
GetArgumentAddress(int)
Gets the address (relative to the start of the frame) to an argument in the frame.
public long GetArgumentAddress(int index)
Parameters
indexintThe index of the argument to get the address for.
Returns
- long
The address
Exceptions
- ArgumentOutOfRangeException
Occurs when the argument index is invalid.
GetLocalAddress(int)
Gets the address (relative to the start of the frame) to a local variable in the frame.
public long GetLocalAddress(int index)
Parameters
indexintThe index of the local variable to get the address for.
Returns
- long
The address
Exceptions
- ArgumentOutOfRangeException
Occurs when the local index is invalid.
IsValidAddress(long)
Gets a value indicating whether the provided address is a valid address, and can be used to read and/or write to.
public bool IsValidAddress(long address)
Parameters
addresslongThe address to query.
Returns
- bool
trueif the address was valid,falseotherwise.
Read(long, BitVectorSpan)
Copies data at the provided address into the provided buffer.
public void Read(long address, BitVectorSpan buffer)
Parameters
addresslongThe address to start reading at.
bufferBitVectorSpanThe buffer to write into.
ReadArgument(int)
Reads the value of a local variable into a buffer.
public BitVector ReadArgument(int index)
Parameters
indexintThe index of the variable.
Returns
- BitVector
A bit vector with the current data of the argument.
ReadArgument(int, BitVectorSpan)
Reads the value of an argument into a buffer.
public void ReadArgument(int index, BitVectorSpan buffer)
Parameters
indexintThe index of the argument to read.
bufferBitVectorSpanThe buffer to write the data into.
ReadLocal(int)
Reads the value of a local variable into a buffer.
public BitVector ReadLocal(int index)
Parameters
indexintThe index of the variable.
Returns
- BitVector
A bit vector with the current data of the local variable.
ReadLocal(int, BitVectorSpan)
Reads the value of a local variable into a buffer.
public void ReadLocal(int index, BitVectorSpan buffer)
Parameters
indexintThe index of the variable.
bufferBitVectorSpanThe buffer to write the data into.
Rebase(long)
Relocates the memory to a new base address.
public void Rebase(long baseAddress)
Parameters
baseAddresslongThe new base address.
ToString()
public override string ToString()
Returns
Write(long, BitVectorSpan)
Writes the provided buffer of data at the provided address.
public void Write(long address, BitVectorSpan buffer)
Parameters
addresslongThe address to start writing at.
bufferBitVectorSpanThe data to write.
Write(long, ReadOnlySpan<byte>)
Writes the provided buffer of data at the provided address.
public void Write(long address, ReadOnlySpan<byte> buffer)
Parameters
addresslongThe address to start writing at.
bufferReadOnlySpan<byte>The data to write.
WriteArgument(int, BitVectorSpan)
Assigns a new value to an argument.
public void WriteArgument(int index, BitVectorSpan buffer)
Parameters
indexintThe index of the argument.
bufferBitVectorSpanThe buffer containing the new data.
WriteLocal(int, BitVectorSpan)
Assigns a new value to a local variable.
public void WriteLocal(int index, BitVectorSpan buffer)
Parameters
indexintThe index of the variable.
bufferBitVectorSpanThe buffer containing the new data.