Microsoft.VisualStudio.Debugger.Evaluation.IL Namespace

Classes

DkmCompiledILInspectionQuery

An inspection query compiled to one or more DkmIL instructions.

DkmILAdd

Pops two values off the evaluation stack, adds them, and pushes the sum onto the evaluation stack. Both operands popped off the stack must be the size indicated by DkmPrimitiveObjectType. The resultant value will have the same size as the operands. In the event of overflow, the result will be truncated.

DkmILAmpAdjustBufferTag

A request to translate a C++ AMP pointer tag if its buffer has been forwarded. Pops the 32-bit tag off the stack, pushes the new 32-bit tag on the stack. Usually a no-op.

DkmILBeginTry

Begins a try block. If an error occurs within the execution of the try block, control will jump to an appropriate catch block to allow the IL to recover from the error. Exception handling in native IL works as follows: An exception in native IL means that some operation, such as a register read or memory read failed. Each exception is identified by a 32-bit exception code that describes the problem. Exception code values are defined according to the DkmILFailureReason enumeration, and additional user-defined values may also be used to handle exception-conditions that are specific to an intrinsic function (e.g. attempt to take the log of 0).

By default, when an exception occurs, the IL processing will stop immediately, causing DkmCompiledInspectionQuery::ExecuteQuery() to fail, returning the exception code as an out parameter. To handle the exception with IL, the IL should execute a DkmILBeginTry instruction to enter a guarded exception-handling state. The IL processing will remain in this state until a DkmILEndTryBlock instruction is executed.

A DkmILBeginTryBlock instruction specifies what to do if an exception occurs within the block. The block's exception handling logic is defined by a collection of DkmILCatchBlock objects. Each catch block defines the exception code that the catch block will catch, as well as the offset into the instruction stream where the catch block is located at.

Thus, when an exception occurs, we will do the following:

  1. Check if we are inside a try block: No: Abort the IL operation and cause DkmCompiledInspectionQuery::ExecuteQuery() to fail. Yes: 2) Examine the list of DkmILCatchBlock objects associated with the try block in sequential order, looking for a catch block that catches the exception code. (If more than one catch block works, we use the first match and ignore the other matches). If we find a match: - Clear the state that says we're in a try block (so any exceptions from the catch handler will go unhandled unless a new try block gets set up) - Remove all values from the IL stack that got pushed after we entered the try block. Local variables, saved return values, and IL stack values that were already pushed before the try block began are retained. (It is illegal to pop a value off the stack inside a try block that got pushed outside the try block). - Push the exception code on the stack as a 32-bit value - Transfer control to the offset of the catch handler and continue the IL If we don't find a match: - The exception is unhandled. Abort the IL operation and cause DkmCompiledInspectionQuery::ExecuteQuery() to fail.

If during the execution of the inspection query, we detect that the work list has been canceled, we will promptly abort the IL processing. The IL will not have a chance to handle this.

In general, exception handling is allowed when an inspection fails, or an arithmetic error occurs (e.g. division by zero), however, on error conditions that can only arise through invalid IL (e.g. attempt to pop from empty stack), we do not guarantee that exception handling of such errors will be supported. If an exception occurs that we do not support handling, the IL processing will simply abort.

DkmILBitAnd

Pops two integer values off of the evaluation stack. Performs a bitwise and on the two values, and pushes the result onto the stack. The two values popped from the stack must be the same size.

DkmILBitFieldRead

Reads the value of a bit field from memory. The address of the bit field is popped off the stack.

DkmILBitFieldReadFromBytes

Pops a value off the IL stack. Then, reads a bit-field directly off that value. This is different from DkmILBitFieldRead in that the value popped from the stack directly contains the value to read the bits from, rather than a memory address.

DkmILBitFieldWrite

Pops a value off the stack. Then, pops a memory address off the stack. Then, modifies the value of the bit field at that memory address, at the given offset and size, to match the value that was just popped off the stack.

DkmILBitFieldWriteToBytes

Pops a value off the IL stack. Then pops a second value off the IL stack. The first value to be popped (second to be pushed) will be treated as an object that contains a bit field described herein. The second value to be popped (first to be pushed) will be the value of the bit field that will be inserted into the first value. The result of the modification is then pushed onto the IL stack.

DkmILBitNot

Pops an integer value off of the evaluation stack. Inverts all the bits and pushes the result onto the stack.

DkmILBitOr

Pops two integer values off of the evaluation stack. Performs a bitwise or on the two values, and pushes the result onto the stack. The two values popped from the stack must be the same size.

DkmILBitShiftLeft

Pops two integer values off of the evaluation stack. Shifts the first value left by the second value and pushes the result onto the evaluation stack. The first operand must be the size indicated by by DkmPrimitiveObjectType. The second operand must be 32-bit.

DkmILBitShiftRight

Pops two integer values off of the evaluation stack. Shifts the first value right by the second value and pushes the result onto the evaluation stack. The first operand must be the size indicated by by DkmPrimitiveObjectType. The second operand must be 32-bit.

DkmILBitXor

Pops two integer values off of the evaluation stack. Performs a bitwise exclusive-or on the two values, and pushes the result onto the stack. The two values popped from the stack must be the same size.

DkmILCatchBlock

An IL catch block, which can be used to recover from errors while executing IL.

DkmILCheckTimeout

Checks if the timeout limit on the IL stream has been exceeded. If so, throws an IL exception with failure code 'Aborted'. This exception may be handled in a catch block, so immediate termination of the IL is not guaranteed. Otherwise, this instruction simply returns.

This API was introduced in Visual Studio 14 RTM (DkmApiVersion.VS14RTM).

DkmILCompareEqual

Pops two values off of the evaluation stack. If the two values are equal (same size, all the bytes have the same value), pushes a 32-bit 1 onto the stack. Otherwise, pushes a 32-bit 0 onto the stack.

DkmILCompareGreaterThan

Pops two values off the evaluation stack and performs a numerical comparison of the values, using the arithmetic mode specified. If the first operand is greater than the second operand, pushes a 32-bit value of 1 on the stack; otherwise, pushes a 32-bit value of 0 on the stack.

DkmILCompareGreaterThanOrEqual

Pops two values off the evaluation stack and performs a numerical comparison of the values, using the arithmetic mode specified. If the first operand is greater than or equal to the second operand, pushes a 32-bit value of 1 on the stack; otherwise, pushes a 32-bit value of 0 on the stack.

DkmILCompareLessThan

Pops two values off the evaluation stack and performs a numerical comparison of the values, using the arithmetic mode specified. If the first operand is less than the second operand, pushes a 32-bit value of 1 on the stack; otherwise, pushes a 32-bit value of 0 on the stack.

DkmILCompareLessThanOrEqual

Pops two values off the evaluation stack and performs a numerical comparison of the values, using the arithmetic mode specified. If the first operand is less than the second operand, pushes a 32-bit value of 1 on the stack; otherwise, pushes a 32-bit value of 0 on the stack.

DkmILCompareNotEqual

Pops two values off of the evaluation stack. If the two values are not equal (same size, all the bytes don't have the same value), pushes a 32-bit 1 onto the stack. Otherwise, pushes a 32-bit 0 onto the stack.

DkmILConvert

Pops a value off the evaluation stack and converts it from one type to another.

DkmILDivide

Pops two values off the evaluation stack, divides them, and pushes the result onto the evaluation stack. Both operands popped off the stack must be the size indicated by DkmPrimitiveObjectType. The first value popped from the stack will be divided by the second value popped, so to evaluate "a / b", you would push a, then push b, then divide. The resultant value will have the same size as the operands. In the event of overflow, the result will be truncated.

DkmILDuplicateTop

Make a duplicate copy of the value on the top of the DkmIL stack and push this copy on top of the stack. If the result of a DkmDuplicateTop gets returned, the GUID associated with the result will be the GUID of the original instruction, not the GUID of the DkmDuplicateTop.

DkmILEndTry

Ends a try block. After this, all exceptions will go unhandled unless a new DkmILBeginTry instruction is executed.

DkmILEvaluationResult

DkmILEvaluationResult represents the result of evaluating one DkmILInstruction.

DkmILExecuteFunction

Pops the arguments off the IL stack in reverse order. Then, pops the address of the function off the eval stack. Next, executes the function in the debuggee process. (Prior to execution, the IL stream should push the function address first, then the arguments in forwards order). The return value for the function is copied to the IL Stack as a byte array.

DkmILExecuteIntrinsic

Pops the arguments off the IL stack in reverse order (prior to the DkmILExecuteIntrinsic instruction, arguments should be pushed on the stack in order). Then, executes an EE-defined operation that makes use of these values. Then, pushes the result back onto the IL stack.

DkmILExtractBytes

Pops a value off the IL stack and extracts a subset of the bytes of that value, pushing the result back onto the IL stack. If the entire region of bytes to extract doesn't fall within the bounds of the value popped from the stack, an IL exception of code ByteExtractionOutOfBounds will be thrown.

DkmILExtractBytesPopArguments

Pops a length, offset, and blob of bytes from the IL stack (in that order). Extracts the portion of the blob of bytes at the given offset of the given length, pushing the result back onto the stack. The length and offset popped from the stack will be interpreted as either 32-bit or 64-bit unsigned integers, depending on the address space of the debuggee. If the entire region of bytes to extract doesn't fall within the bounds of the value popped from the stack, an IL exception of code ByteExtractionOutOfBounds will be thrown. This is similar to the DkmILExtractBytes instruction, except the offset and length are popped from the stack and do not need to be known at the time that the IL is generated.

This API was introduced in Visual Studio 14 RTM (DkmApiVersion.VS14RTM).

DkmILHlslBufferRead

A request to read data from a shader shared buffer. The offset in the buffer is popped from the IL stack. The result is pushed on the IL stack.

DkmILHlslGetGroupId

A request to 'read' the current group ID. The result is pushed on the stack.

DkmILHlslGetThreadId

A request to 'read' the current thread ID. The result is pushed on the stack.

DkmILHlslIndexedRegisterRead

A request to read the value of a specific register. The index of the first vector element to read is popped from the IL stack. The result is pushed on the IL stack.

DkmILHlslRegisterRead

A request to read the value of a specific register. The result is pushed on the IL stack.

DkmILInstruction

Abstract base class for the concrete debugger immediate language instructions used by expression evaluators to batch query information about the debuggee.

Derived classes: DkmILAdd, DkmILAmpAdjustBufferTag, DkmILBeginTry, DkmILBitAnd, DkmILBitFieldRead, DkmILBitFieldReadFromBytes, DkmILBitFieldWrite, DkmILBitFieldWriteToBytes, DkmILBitNot, DkmILBitOr, DkmILBitShiftLeft, DkmILBitShiftRight, DkmILBitXor, DkmILCompareEqual, DkmILCompareGreaterThan, DkmILCompareGreaterThanOrEqual, DkmILCompareLessThan, DkmILCompareLessThanOrEqual, DkmILCompareNotEqual, DkmILConvert, DkmILDivide, DkmILDuplicateTop, DkmILEndTry, DkmILExecuteFunction, DkmILExecuteIntrinsic, DkmILExtractBytes, DkmILHlslBufferRead, DkmILHlslGetGroupId, DkmILHlslGetThreadId, DkmILHlslIndexedRegisterRead, DkmILHlslRegisterRead, DkmILIsFalse, DkmILIsTrue, DkmILJump, DkmILJumpIfFalse, DkmILJumpIfTrue, DkmILLoad, DkmILMemoryRead, DkmILMemoryStringRead, DkmILMemoryWrite, DkmILMultiply, DkmILNop, DkmILPop, DkmILPushConstant, DkmILRegisterRead, DkmILRegisterWrite, DkmILRemainder, DkmILReturnTop, DkmILSave, DkmILSetBytesRegion, DkmILSubtract, DkmILThrow, DkmILTlsGetValue, DkmILCheckTimeout, DkmILExtractBytesPopArguments, DkmILPushLocalVariablePseudoAddress, DkmILPushRegisterPseudoAddress

DkmILIsFalse

Pops a value off of the evaluation stack. If the value is zero, pushes a 32-bit value of 1 on the stack. Otherwise, pushes a 32-bit value of 0 on the stack.

DkmILIsTrue

Pops a value off of the evaluation stack. If the value is non-zero, pushes a 32-bit value of 1 on the stack. Otherwise, pushes a 32-bit value of 0 on the stack.

DkmILJump

Jumps to another instruction in the instruction stream.

DkmILJumpIfFalse

Pops a value off the IL stack. Then, jumps to another instruction in the instruction stream only if the value bytes are all zero.

DkmILJumpIfTrue

Pops a value off the IL stack. Then, jumps to another instruction in the instruction stream only if the value bytes are not all zero.

DkmILLoad

Loads a value from an index previously saved from a DkmSave instruction and pushes the value to the top of the stack.

DkmILMemoryRead

A request to read a sequence of bytes from memory. The address to read from is popped off the DkmIL stack and must have a size of 4 if the debuggee is 32-bit, or 8 if the debuggee is 64-bit. The bytes that are read from memory are pushed onto the stack.

DkmILMemoryStringRead

A request to read a null-terminated string from the target process. The address to read from is popped off the DkmIL stack and must have a size of 4 if the debuggee is 32-bit, or 8 if the debuggee is 64-bit. The bytes that are read from memory are pushed onto the stack. This will include the null-terminator if this value is read. The null-terminator will be missing when DkmReadMemoryFlags.AllowPartialRead is true, and either the MaxCharacters is hit, or unreadable memory is hit before the null terminator.

DkmILMemoryWrite

A request to write a sequence of bytes from memory. Pops a value off the stack. Then, pops an address of the stack. Writes the value popped off the stack to debuggee memory at the address popped off the stack.

DkmILMultiply

Pops two values off the evaluation stack, multiplies them, and pushes the product onto the evaluation stack. Both operands popped off the stack must be the size indicated by DkmPrimitiveObjectType. In the event of overflow, the result will be truncated.

DkmILNop

Placeholder instruction that does no operation.

DkmILParameterValue

A value that can be passed in as a parameter to an IL stream.

DkmILPop

Pop the value on top of the DkmIL stack.

DkmILPushConstant

Pushes a constant value onto the DkmIL stack.

DkmILPushLocalVariablePseudoAddress

Pushes a pseudo address on the stack representing the IL local variable and a byte offset within that variable. When popped from the stack as an address, instructions that would ordinarily read or write memory in the debuggee process will instead read or write bytes at the IL local variable and offset specified in the pseudo-address. It is permissible to push a pseudo-address onto the stack corresponding to a local variable that does not exist or has fewer bytes than the specified offset. However, when the times to actually read or write data at a pseudo-address, the backing local variable must exist and must have enough data to encompass the entire read or write operation. (Reads may be truncated at the end of the buffer if AllowPartialRead is specified). A pseudo-address may be used as the operand of an arithmetic operation in the following cases: - adding an integer a pseudo-address. (The integer will be added to the offset) - subtracting an integer from a pseudo-address. (The integer will be subtracted from the offset). - subtracting two pseudo-addresses from each other, backed by the same local variable. (The result is the difference in offsets).

  • comparing a pseudo address with NULL. (Any pseudo-address is considered greater than NULL. An operand is considered to be NULL if all bytes are zero.) - comparing two pseudo-addresses for equality. - comparing two pseudo-addresses for inequality, when backed by the same variable. (The offsets will be compared). Pseudo-addresses may also be used with DkmILDuplicateTop or saved in local variables via DkmILLoad and DkmILSave. It is illegal to read or write data at a pseudo-address, however, if the backing local variable contains another pseudo-address. Pseudo-addresses may be returned as an IL result via the DkmILReturnTop instruction. The resulting DkmILEvaluationResult can be identified as a pseudo-address via the IsPseudoAddress property. The result bytes of a pseudo-address will be set to either the contents of the backing local variable, from the specified offset until the end of the variable, or empty if the backing local variable does not exist, is another pseudo-address, or does not store enough bytes to contain data at the given offset. Pseudo-addresses may also be passed in as a parameter to a DkmCompiledILInspectionQuery by setting IsByRef to true on the DkmILParameterValue. It is illegal to use a pseudo-address in any IL instruction, except as described above. An attempt to use a pseudo-address in any other manner will result in an IL exception of type DkmILFailureReason::InvalidPseudoAddressOperation. For example, you cannot multiply or divide with pseudo-addresses or store them anywhere in the debuggee process.

This API was introduced in Visual Studio 14 RTM (DkmApiVersion.VS14RTM).

DkmILPushRegisterPseudoAddress

Pushes a pseudo-address onto the stack representing a register and a byte offset within that register. The semantics of a register-pseudo address are the same as that of a pseudo address pushed via a DkmILPushLocalVariablePseudoAddress instruction, except that reads and writes involving a register pseudo-address will read or write the register, rather than an IL local variable.

This API was introduced in Visual Studio 15 RTM (DkmApiVersion.VS15RTM).

DkmILRegisterRead

A request to read the value of a specific register. The result is pushed on the DkmIL stack.

DkmILRegisterWrite

Pops a value off the IL stack. Then, writes the value to the given register of the given thread. The write will be visible to the debuggee from the top frame of that thread.

DkmILRemainder

Pops two values off the evaluation stack and computes the second value popped off the stack modulo the first value popped off the stack.

DkmILReturnTop

Pop the value on top of the DkmIL stack and return it as an instance of DkmILEvaluationResult.

DkmILSave

Saves the value at the top of the stack in a temporary slot at the given index, from which it can later be loaded back.

DkmILSetBytesRegion

Pops a value off the IL stack. Then pops an offset, followed by a blob of bytes. Modifies the first value so that the segment at the offset is replaced with the blob of bytes provided. Pushes the resultant value back onto the IL stack.

DkmILSubtract

Pops two values off the evaluation stack, subtracts them, and pushes the difference onto the evaluation stack. Both operands popped off the stack must be the size indicated by DkmPrimitiveObjectType. The first value popped from the stack will be subtracted from the second value popped, so to evaluate "a - b", you would push a, then push b, then subtract. The resultant value will have the same size as the operands. In the event of overflow, the result will be truncated.

DkmILThrow

Throws a native IL exception within the given failure code.

DkmILTlsGetValue

Pushes an index of a TLS slot off the IL stack. Reads the value of that TLS slot for the thread of the current stack frame and pushes the result onto the IL stack. If the TLS index is not valid, the result is undefined. It may read a random value from memory, or fail. The value that is pushed on the stack is a pointer-sized value (4 bytes if the debuggee is 32-bit, 8 bytes if the debuggee is 64-bit).

Enums

DkmILCallingConvention

Describes the calling convention for a function evaluation on x86. Ignored for other architectures.

DkmILFailureReason

Indicates a reason why an IL instruction failed to execute. In addition to these constants, negative values may be used to indicate customized error conditions resulting from the execution of intrinsic functions.

DkmILFunctionEvaluationArgumentFlags

Flags affecting how arguments to a function evaluation are treated.

DkmILFunctionEvaluationFlags

Flags affecting how a function evaluation should occur.

DkmILInstruction.Tag

DkmILInstruction is an abstract base class. This enum indicates which derived class this object is an instance of.

DkmPrimitiveObjectType

Indicates the underlying primitive type (ex: UInt32) being operated on.