예제 #1
0
        string IDkmLanguageInstructionDecoder.GetMethodName(DkmLanguageInstructionAddress languageInstructionAddress, DkmVariableInfoFlags argumentFlags)
        {
            try
            {
                // DkmVariableInfoFlags.FullNames was accepted by the old GetMethodName implementation,
                // but it was ignored.  Furthermore, it's not clear what FullNames would mean with respect
                // to argument names in C# or Visual Basic.  For consistency with the old behavior, we'll
                // just ignore the flag as well.
                Debug.Assert((argumentFlags & (DkmVariableInfoFlags.FullNames | DkmVariableInfoFlags.Names | DkmVariableInfoFlags.Types)) == argumentFlags,
                             $"Unexpected argumentFlags '{argumentFlags}'");

                var instructionAddress    = (DkmClrInstructionAddress)languageInstructionAddress.Address;
                var compilation           = _instructionDecoder.GetCompilation(instructionAddress.ModuleInstance);
                var method                = _instructionDecoder.GetMethod(compilation, instructionAddress);
                var includeParameterTypes = argumentFlags.Includes(DkmVariableInfoFlags.Types);
                var includeParameterNames = argumentFlags.Includes(DkmVariableInfoFlags.Names);

                return(_instructionDecoder.GetName(method, includeParameterTypes, includeParameterNames));
            }
            catch (NotImplementedMetadataException)
            {
                return(languageInstructionAddress.GetMethodName(argumentFlags));
            }
            catch (Exception e) when(ExpressionEvaluatorFatalError.CrashIfFailFastEnabled(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
예제 #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));
            }
        }
예제 #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;
            }
        }