Sdílet prostřednictvím


DkmILBeginTry Class

Definition

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.

public ref class DkmILBeginTry : Microsoft::VisualStudio::Debugger::Evaluation::IL::DkmILInstruction
[Windows::Foundation::Metadata::WebHostHidden]
public ref class DkmILBeginTry : Microsoft::VisualStudio::Debugger::Evaluation::IL::DkmILInstruction
[Windows::Foundation::Metadata::WebHostHidden]
class DkmILBeginTry : Microsoft::VisualStudio::Debugger::Evaluation::IL::DkmILInstruction
[System.Runtime.InteropServices.Guid("16f727a6-1a24-9c23-11b3-1a4cfe666cc6")]
public class DkmILBeginTry : Microsoft.VisualStudio.Debugger.Evaluation.IL.DkmILInstruction
[<System.Runtime.InteropServices.Guid("16f727a6-1a24-9c23-11b3-1a4cfe666cc6")>]
type DkmILBeginTry = class
    inherit DkmILInstruction
Public Class DkmILBeginTry
Inherits DkmILInstruction
Inheritance
DkmILBeginTry
Attributes

Properties

CatchBlocks

Ordered list of catch blocks to handle exceptions occurring within the try block.

TagValue

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

(Inherited from DkmILInstruction)
UniqueId

Uniquely identifies the DkmILInstruction object. Used as a hash-table key to allow for quickly matching up DkmIL instructions with their matching values.

(Inherited from DkmILInstruction)

Methods

Create(ReadOnlyCollection<DkmILCatchBlock>)

Create a new DkmILBeginTry object instance.

Applies to