Debugger intrinsics are special functions that can be called by an Expression Compiler to get or set values in the debugger. Intrinsics are used to support the following features (using C# as an example):
$exception
to get the pending exception on the current thread.$stowedexception
to get the stowed exception - this is only used when debugging dumps of Windows Store Apps.$ReturnValue
, $ReturnValue1
, etc.int i = 0;
.The debugger provides a method, DkmClrRuntimeInstance.GetAliases
, to get the list of valid aliases. An alias is made up of a name, full name, alias kind, and type. The name and full name values are used to populate the DkmClrLocalVariableInfo
. The kind is one of (Exception, ObjectId, ReturnValue, StowedException, or Variable). The type is an assembly qualified name indicating the type of the variable. There is also a CustomTypeInfoPayload and CustomTypeInfoPayloadTypeId that can be used to communicate custom compiler-specific type information that can't be represented in CLR metadata.
To get the value of a alias, for example $exception
, the Expression Compiler generates a query calling an "intrinsic method". To get the value of $exception
, the C# Expression Compiler generates code that looks like this:
.method public hidebysig static System.Exception M1() cil managed
{
call System.Exception Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetException()
ret
}
Notice the call to Microsoft.VisualStudio.Debugger.Clr.IntrinsicMethods.GetException
. This is the intrinsic method call to get the current exception object. For the compiler to link to this method, it needs the metadata for all of the intrinsic methods. The intrinsic methods metadata block can be obtained by calling DkmClrRuntimeInstance.GetIntrinsicAssemblyMetaDataBytesPtr()
.
The intrinsic methods metadata is embedded in the debugger binaries and is generated by compiling this C# code:
(note: the implementations of the methods aren't used)
using System; namespace Microsoft.VisualStudio.Debugger.Clr { public class IntrinsicMethods { public static object GetObjectAtAddress(UInt64 address) { return null; } public static Exception GetException() { return null; } public static Exception GetStowedException() { return null; } public static object GetReturnValue(int index) { return null; } public static void CreateVariable(Type type, string name, Guid customTypeInfoPayloadTypeId, byte[] customTypeInfoPayload) { } public static object GetObjectByAlias(string name) { return null; } public static ref T GetVariableAddress<T>(string name) { throw null; } } }
These methods do the following:
@0x12341234
. This means evaluate the object at address 0x12341234.RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4