/// <summary> /// This method is called by the debug engine to compile an expression that the user wants /// to evaluate. Before the call, we have the text of the expression and information about /// the context we want to evaluate in (code location, evaluation flags, etc.). The result /// of the call is a "query" containing IL the debugger will execute to get the /// result of the expression. /// </summary> /// <param name="expression">This is the raw expression to compile</param> /// <param name="instructionAddress">Instruction address or code location to use as the /// context of the compilation.</param> /// <param name="inspectionContext">Context of the evaluation. This contains options/flags /// to be used during compilation. It also contains the InspectionSession. The inspection /// session is the object that provides lifetime management for our objects. When the user /// steps or continues the process, the debug engine will dispose of the inspection session</param> /// <param name="error">[Out] If the there are any compile errors, this parameter is set to /// the error message to display to the user</param> /// <param name="result">[Out] If compilation was successful, this is the output query.</param> void IDkmClrExpressionCompiler.CompileExpression( DkmLanguageExpression expression, DkmClrInstructionAddress instructionAddress, DkmInspectionContext inspectionContext, out string error, out DkmCompiledClrInspectionQuery result) { error = null; result = null; using (DebugCompilerContext context = ContextFactory.CreateExpressionContext(inspectionContext, instructionAddress, expression.Text)) { context.GenerateQuery(); error = context.FirstError; if (string.IsNullOrEmpty(error)) { result = DkmCompiledClrInspectionQuery.Create( instructionAddress.RuntimeInstance, null, expression.Language.Id, new ReadOnlyCollection <byte>(context.GetPeBytes()), context.ClassName, context.MethodName, new ReadOnlyCollection <string>(context.FormatSpecifiers), context.ResultFlags, DkmEvaluationResultCategory.Data, DkmEvaluationResultAccessType.None, DkmEvaluationResultStorageType.None, DkmEvaluationResultTypeModifierFlags.None, null); } } }
/// <summary> /// This method is called by the debug engine to retrieve the current local variables. /// The result of this call will be a query containing the names of the local variables /// as well as IL code to retrieve each variable value. /// </summary> /// <param name="inspectionContext">Context of the evaluation. This contains options/flags /// to be used during compilation. It also contains the InspectionSession. The inspection /// session is the object that provides lifetime management for our objects. When the user /// steps or continues the process, the debug engine will dispose of the inspection session</param> /// <param name="instructionAddress">Instruction address or code location to use as the /// reference point for where we need to retrieve the local variables</param> /// <param name="argumentsOnly">True if only arguments are needed</param> /// <returns>A local variables query</returns> DkmCompiledClrLocalsQuery IDkmClrExpressionCompiler.GetClrLocalVariableQuery(DkmInspectionContext inspectionContext, DkmClrInstructionAddress instructionAddress, bool argumentsOnly) { using (DebugCompilerContext context = ContextFactory.CreateLocalsContext(inspectionContext, instructionAddress, argumentsOnly)) { context.GenerateQuery(); return(DkmCompiledClrLocalsQuery.Create( inspectionContext.RuntimeInstance, null, inspectionContext.Language.Id, new ReadOnlyCollection <byte>(context.GetPeBytes()), context.ClassName, new ReadOnlyCollection <DkmClrLocalVariableInfo>(context.GeneratedLocals))); } }