Esempio n. 1
0
        void IDkmLanguageFrameDecoder.GetFrameName(
            DkmInspectionContext inspectionContext,
            DkmWorkList workList,
            DkmStackWalkFrame frame,
            DkmVariableInfoFlags argumentFlags,
            DkmCompletionRoutine <DkmGetFrameNameAsyncResult> completionRoutine)
        {
            try
            {
                Debug.Assert((argumentFlags & (DkmVariableInfoFlags.Names | DkmVariableInfoFlags.Types | DkmVariableInfoFlags.Values)) == argumentFlags,
                             $"Unexpected argumentFlags '{argumentFlags}'");

                GetNameWithGenericTypeArguments(inspectionContext, workList, frame,
                                                onSuccess: method => GetFrameName(inspectionContext, workList, frame, argumentFlags, completionRoutine, method),
                                                onFailure: e => completionRoutine(DkmGetFrameNameAsyncResult.CreateErrorResult(e)));
            }
            catch (NotImplementedMetadataException)
            {
                inspectionContext.GetFrameName(workList, frame, argumentFlags, completionRoutine);
            }
            catch (Exception e) when(ExpressionEvaluatorFatalError.CrashIfFailFastEnabled(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
Esempio n. 2
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));
            }
        }
Esempio n. 3
0
        void IDkmLanguageFrameDecoder.GetFrameName(DkmInspectionContext inspectionContext, DkmWorkList workList, DkmStackWalkFrame frame, DkmVariableInfoFlags argumentFlags, DkmCompletionRoutine <DkmGetFrameNameAsyncResult> completionRoutine)
        {
            try
            {
                Debug.Assert((argumentFlags & (DkmVariableInfoFlags.Names | DkmVariableInfoFlags.Types | DkmVariableInfoFlags.Values)) == argumentFlags,
                             "Unexpected argumentFlags", "argumentFlags = {0}", argumentFlags);

                var instructionAddress    = (DkmClrInstructionAddress)frame.InstructionAddress;
                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 =>
                    {
                        try
                        {
                            var builder = ArrayBuilder <string> .GetInstance();
                            foreach (var argument in result.Arguments)
                            {
                                var evaluatedArgument = argument as DkmSuccessEvaluationResult;
                                // Not expecting Expandable bit, at least not from this EE.
                                Debug.Assert((evaluatedArgument == null) || (evaluatedArgument.Flags & DkmEvaluationResultFlags.Expandable) == 0);
                                builder.Add((evaluatedArgument != null) ? evaluatedArgument.Value : null);
                            }

                            var frameName = _instructionDecoder.GetName(instructionAddress, includeParameterTypes, includeParameterNames, builder);
                            builder.Free();
                            completionRoutine(new DkmGetFrameNameAsyncResult(frameName));
                        }
                        // TODO: Consider calling DkmComponentManager.ReportCurrentNonFatalException() to
                        // trigger a non-fatal Watson when this occurs.
                        catch (Exception e) when(!ExpressionEvaluatorFatalError.CrashIfFailFastEnabled(e))
                        {
                            completionRoutine(DkmGetFrameNameAsyncResult.CreateErrorResult(e));
                        }
                        finally
                        {
                            foreach (var argument in result.Arguments)
                            {
                                argument.Close();
                            }
                        }
                    });
                }
                else
                {
                    var frameName = _instructionDecoder.GetName(instructionAddress, includeParameterTypes, includeParameterNames, null);
                    completionRoutine(new DkmGetFrameNameAsyncResult(frameName));
                }
            }
            catch (Exception e) when(ExpressionEvaluatorFatalError.CrashIfFailFastEnabled(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }