private static void EvaluateDebuggerDisplayStringAndContinue(
            DkmClrValue value,
            WorkList workList,
            DkmInspectionContext inspectionContext,
            DkmClrType targetType,
            string str,
            CompletionRoutine <DkmEvaluateDebuggerDisplayStringAsyncResult> onCompleted,
            CompletionRoutine <Exception> onException)
        {
            DkmCompletionRoutine <DkmEvaluateDebuggerDisplayStringAsyncResult> completionRoutine =
                result =>
            {
                try
                {
                    onCompleted(result);
                }
                catch (Exception e) when(ExpressionEvaluatorFatalError.ReportNonFatalException(e, DkmComponentManager.ReportCurrentNonFatalException))
                {
                    onException(e);
                }
            };

            if (str == null)
            {
                completionRoutine(default(DkmEvaluateDebuggerDisplayStringAsyncResult));
            }
            else
            {
                value.EvaluateDebuggerDisplayString(workList.InnerWorkList, inspectionContext, targetType, str, completionRoutine);
            }
        }
Beispiel #2
0
 internal static void ContinueWithExceptionHandling(CompletionRoutine onCompleted, CompletionRoutine <Exception> onException)
 {
     try
     {
         onCompleted();
     }
     catch (Exception e) when(ExpressionEvaluatorFatalError.ReportNonFatalException(e, DkmComponentManager.ReportCurrentNonFatalException))
     {
         onException(e);
     }
 }
 internal void Execute()
 {
     while (_completionRoutine != null)
     {
         var completionRoutine = _completionRoutine;
         _completionRoutine = null;
         try
         {
             completionRoutine();
         }
         catch (Exception e) when(ExpressionEvaluatorFatalError.ReportNonFatalException(e, DkmComponentManager.ReportCurrentNonFatalException))
         {
             _onException(e);
         }
     }
 }
Beispiel #4
0
        private void GetNameWithGenericTypeArguments(
            DkmInspectionContext inspectionContext,
            DkmWorkList workList,
            DkmStackWalkFrame frame,
            Action <TMethodSymbol> onSuccess,
            Action <Exception> onFailure)
        {
            // NOTE: We could always call GetClrGenericParameters, pass them to GetMethod and have that
            // return a constructed method symbol, but it seems unwise to call GetClrGenericParameters
            // for all frames (as this call requires a round-trip to the debuggee process).
            var instructionAddress = (DkmClrInstructionAddress)frame.InstructionAddress;
            var compilation        = _instructionDecoder.GetCompilation(instructionAddress.ModuleInstance);
            var method             = _instructionDecoder.GetMethod(compilation, instructionAddress);
            var typeParameters     = _instructionDecoder.GetAllTypeParameters(method);

            if (!typeParameters.IsEmpty)
            {
                frame.GetClrGenericParameters(
                    workList,
                    result =>
                {
                    try
                    {
                        // DkmGetClrGenericParametersAsyncResult.ParameterTypeNames will throw if ErrorCode != 0.
                        var serializedTypeNames = (result.ErrorCode == 0) ? result.ParameterTypeNames : null;
                        var typeArguments       = _instructionDecoder.GetTypeSymbols(compilation, method, serializedTypeNames);
                        if (!typeArguments.IsEmpty)
                        {
                            method = _instructionDecoder.ConstructMethod(method, typeParameters, typeArguments);
                        }
                        onSuccess(method);
                    }
                    catch (Exception e) when(ExpressionEvaluatorFatalError.ReportNonFatalException(e, DkmComponentManager.ReportCurrentNonFatalException))
                    {
                        onFailure(e);
                    }
                });
            }
            else
            {
                onSuccess(method);
            }
        }
Beispiel #5
0
        private void GetFrameName(
            DkmInspectionContext inspectionContext,
            DkmWorkList workList,
            DkmStackWalkFrame frame,
            DkmVariableInfoFlags argumentFlags,
            DkmCompletionRoutine <DkmGetFrameNameAsyncResult> completionRoutine,
            TMethodSymbol method)
        {
            var includeParameterTypes = argumentFlags.Includes(DkmVariableInfoFlags.Types);
            var includeParameterNames = argumentFlags.Includes(DkmVariableInfoFlags.Names);

            if (argumentFlags.Includes(DkmVariableInfoFlags.Values))
            {
                // No need to compute the Expandable bit on
                // argument values since that can be expensive.
                inspectionContext = DkmInspectionContext.Create(
                    inspectionContext.InspectionSession,
                    inspectionContext.RuntimeInstance,
                    inspectionContext.Thread,
                    inspectionContext.Timeout,
                    inspectionContext.EvaluationFlags | DkmEvaluationFlags.NoExpansion,
                    inspectionContext.FuncEvalFlags,
                    inspectionContext.Radix,
                    inspectionContext.Language,
                    inspectionContext.ReturnValue,
                    inspectionContext.AdditionalVisualizationData,
                    inspectionContext.AdditionalVisualizationDataPriority,
                    inspectionContext.ReturnValues);

                // GetFrameArguments returns an array of formatted argument values. We'll pass
                // ourselves (GetFrameName) as the continuation of the GetFrameArguments call.
                inspectionContext.GetFrameArguments(
                    workList,
                    frame,
                    result =>
                {
                    var argumentValues = result.Arguments;
                    try
                    {
                        var builder = ArrayBuilder <string> .GetInstance();
                        foreach (var argument in argumentValues)
                        {
                            var formattedArgument = argument as DkmSuccessEvaluationResult;
                            // Not expecting Expandable bit, at least not from this EE.
                            Debug.Assert((formattedArgument == null) || (formattedArgument.Flags & DkmEvaluationResultFlags.Expandable) == 0);
                            builder.Add(formattedArgument?.Value);
                        }

                        var frameName = _instructionDecoder.GetName(method, includeParameterTypes, includeParameterNames, builder);
                        builder.Free();
                        completionRoutine(new DkmGetFrameNameAsyncResult(frameName));
                    }
                    catch (Exception e) when(ExpressionEvaluatorFatalError.ReportNonFatalException(e, DkmComponentManager.ReportCurrentNonFatalException))
                    {
                        completionRoutine(DkmGetFrameNameAsyncResult.CreateErrorResult(e));
                    }
                    finally
                    {
                        foreach (var argument in argumentValues)
                        {
                            argument.Close();
                        }
                    }
                });
            }
            else
            {
                var frameName = _instructionDecoder.GetName(method, includeParameterTypes, includeParameterNames, null);
                completionRoutine(new DkmGetFrameNameAsyncResult(frameName));
            }
        }