コード例 #1
0
 internal static DkmIntermediateEvaluationResult EvalIntermediateResult(
     string name,
     string fullName,
     string expression,
     DkmLanguage language)
 {
     return(DkmIntermediateEvaluationResult.Create(
                InspectionContext: null,
                StackFrame: null,
                Name: name,
                FullName: fullName,
                Expression: expression,
                IntermediateLanguage: language,
                TargetRuntime: null,
                DataItem: null));
 }
コード例 #2
0
        private void CreateEvaluationResultAndContinue(EvalResult result, WorkList workList, DkmInspectionContext inspectionContext, DkmStackWalkFrame stackFrame, CompletionRoutine <DkmEvaluationResult> completionRoutine)
        {
            switch (result.Kind)
            {
            case ExpansionKind.Error:
                completionRoutine(DkmFailedEvaluationResult.Create(
                                      inspectionContext,
                                      StackFrame: stackFrame,
                                      Name: result.Name,
                                      FullName: result.FullName,
                                      ErrorMessage: result.DisplayValue,
                                      Flags: DkmEvaluationResultFlags.None,
                                      Type: null,
                                      DataItem: null));
                break;

            case ExpansionKind.NativeView:
            {
                var value    = result.Value;
                var name     = Resources.NativeView;
                var fullName = result.FullName;
                var display  = result.Name;
                DkmEvaluationResult evalResult;
                if (value.IsError())
                {
                    evalResult = DkmFailedEvaluationResult.Create(
                        inspectionContext,
                        stackFrame,
                        Name: name,
                        FullName: fullName,
                        ErrorMessage: display,
                        Flags: result.Flags,
                        Type: null,
                        DataItem: result.ToDataItem());
                }
                else
                {
                    // For Native View, create a DkmIntermediateEvaluationResult.
                    // This will allow the C++ EE to take over expansion.
                    var process = inspectionContext.RuntimeInstance.Process;
                    var cpp     = process.EngineSettings.GetLanguage(new DkmCompilerId(DkmVendorId.Microsoft, DkmLanguageId.Cpp));
                    evalResult = DkmIntermediateEvaluationResult.Create(
                        inspectionContext,
                        stackFrame,
                        Name: name,
                        FullName: fullName,
                        Expression: display,
                        IntermediateLanguage: cpp,
                        TargetRuntime: process.GetNativeRuntimeInstance(),
                        DataItem: result.ToDataItem());
                }
                completionRoutine(evalResult);
            }
            break;

            case ExpansionKind.NonPublicMembers:
                completionRoutine(DkmSuccessEvaluationResult.Create(
                                      inspectionContext,
                                      stackFrame,
                                      Name: Resources.NonPublicMembers,
                                      FullName: result.FullName,
                                      Flags: result.Flags,
                                      Value: null,
                                      EditableValue: null,
                                      Type: string.Empty,
                                      Category: DkmEvaluationResultCategory.Data,
                                      Access: DkmEvaluationResultAccessType.None,
                                      StorageType: DkmEvaluationResultStorageType.None,
                                      TypeModifierFlags: DkmEvaluationResultTypeModifierFlags.None,
                                      Address: result.Value.Address,
                                      CustomUIVisualizers: null,
                                      ExternalModules: null,
                                      DataItem: result.ToDataItem()));
                break;

            case ExpansionKind.StaticMembers:
                completionRoutine(DkmSuccessEvaluationResult.Create(
                                      inspectionContext,
                                      stackFrame,
                                      Name: StaticMembersString,
                                      FullName: result.FullName,
                                      Flags: result.Flags,
                                      Value: null,
                                      EditableValue: null,
                                      Type: string.Empty,
                                      Category: DkmEvaluationResultCategory.Class,
                                      Access: DkmEvaluationResultAccessType.None,
                                      StorageType: DkmEvaluationResultStorageType.None,
                                      TypeModifierFlags: DkmEvaluationResultTypeModifierFlags.None,
                                      Address: result.Value.Address,
                                      CustomUIVisualizers: null,
                                      ExternalModules: null,
                                      DataItem: result.ToDataItem()));
                break;

            case ExpansionKind.RawView:
                completionRoutine(DkmSuccessEvaluationResult.Create(
                                      inspectionContext,
                                      stackFrame,
                                      Name: Resources.RawView,
                                      FullName: result.FullName,
                                      Flags: result.Flags,
                                      Value: null,
                                      EditableValue: result.EditableValue,
                                      Type: string.Empty,
                                      Category: DkmEvaluationResultCategory.Data,
                                      Access: DkmEvaluationResultAccessType.None,
                                      StorageType: DkmEvaluationResultStorageType.None,
                                      TypeModifierFlags: DkmEvaluationResultTypeModifierFlags.None,
                                      Address: result.Value.Address,
                                      CustomUIVisualizers: null,
                                      ExternalModules: null,
                                      DataItem: result.ToDataItem()));
                break;

            case ExpansionKind.DynamicView:
            case ExpansionKind.ResultsView:
                completionRoutine(DkmSuccessEvaluationResult.Create(
                                      inspectionContext,
                                      stackFrame,
                                      result.Name,
                                      result.FullName,
                                      result.Flags,
                                      result.DisplayValue,
                                      EditableValue: null,
                                      Type: string.Empty,
                                      Category: DkmEvaluationResultCategory.Method,
                                      Access: DkmEvaluationResultAccessType.None,
                                      StorageType: DkmEvaluationResultStorageType.None,
                                      TypeModifierFlags: DkmEvaluationResultTypeModifierFlags.None,
                                      Address: result.Value.Address,
                                      CustomUIVisualizers: null,
                                      ExternalModules: null,
                                      DataItem: result.ToDataItem()));
                break;

            case ExpansionKind.TypeVariable:
                completionRoutine(DkmSuccessEvaluationResult.Create(
                                      inspectionContext,
                                      stackFrame,
                                      result.Name,
                                      result.FullName,
                                      result.Flags,
                                      result.DisplayValue,
                                      EditableValue: null,
                                      Type: result.DisplayValue,
                                      Category: DkmEvaluationResultCategory.Data,
                                      Access: DkmEvaluationResultAccessType.None,
                                      StorageType: DkmEvaluationResultStorageType.None,
                                      TypeModifierFlags: DkmEvaluationResultTypeModifierFlags.None,
                                      Address: result.Value.Address,
                                      CustomUIVisualizers: null,
                                      ExternalModules: null,
                                      DataItem: result.ToDataItem()));
                break;

            case ExpansionKind.PointerDereference:
            case ExpansionKind.Default:
                // This call will evaluate DebuggerDisplayAttributes.
                GetResultAndContinue(
                    result,
                    workList,
                    declaredType: result.DeclaredTypeAndInfo.ClrType,
                    declaredTypeInfo: result.DeclaredTypeAndInfo.Info,
                    inspectionContext: inspectionContext,
                    useDebuggerDisplay: result.UseDebuggerDisplay,
                    completionRoutine: completionRoutine);
                break;

            default:
                throw ExceptionUtilities.UnexpectedValue(result.Kind);
            }
        }
コード例 #3
0
        private static DkmEvaluationResult CreateEvaluationResult(
            DkmInspectionContext inspectionContext,
            DkmClrValue value,
            string name,
            string typeName,
            string display,
            EvalResultDataItem dataItem)
        {
            if (value.IsError())
            {
                // Evaluation failed
                return(DkmFailedEvaluationResult.Create(
                           InspectionContext: inspectionContext,
                           StackFrame: value.StackFrame,
                           Name: name,
                           FullName: dataItem.FullName,
                           ErrorMessage: display,
                           Flags: dataItem.Flags,
                           Type: typeName,
                           DataItem: dataItem));
            }
            else if (dataItem.Kind == ExpansionKind.NativeView)
            {
                // For Native View, create a DkmIntermediateEvaluationResult.  This will allow the C++ EE
                // to take over expansion.
                DkmProcess  process = inspectionContext.RuntimeInstance.Process;
                DkmLanguage cpp     = process.EngineSettings.GetLanguage(new DkmCompilerId(DkmVendorId.Microsoft, DkmLanguageId.Cpp));
                return(DkmIntermediateEvaluationResult.Create(
                           InspectionContext: inspectionContext,
                           StackFrame: value.StackFrame,
                           Name: Resources.NativeView,
                           FullName: dataItem.FullName,
                           Expression: dataItem.Name,
                           IntermediateLanguage: cpp,
                           TargetRuntime: process.GetNativeRuntimeInstance(),
                           DataItem: dataItem));
            }
            else
            {
                ReadOnlyCollection <DkmCustomUIVisualizerInfo> customUIVisualizers = null;

                if (!value.IsNull)
                {
                    DkmCustomUIVisualizerInfo[] customUIVisualizerInfo = value.Type.GetDebuggerCustomUIVisualizerInfo();
                    if (customUIVisualizerInfo != null)
                    {
                        customUIVisualizers = new ReadOnlyCollection <DkmCustomUIVisualizerInfo>(customUIVisualizerInfo);
                    }
                }

                // If the EvalResultData item doesn't specify a particular category, we'll just propagate DkmClrValue.Category,
                // which typically appears to be set to the default value ("Other").
                var category = (dataItem.Category != DkmEvaluationResultCategory.Other) ? dataItem.Category : value.Category;

                // Valid value
                return(DkmSuccessEvaluationResult.Create(
                           InspectionContext: inspectionContext,
                           StackFrame: value.StackFrame,
                           Name: name,
                           FullName: dataItem.FullName,
                           Flags: dataItem.Flags,
                           Value: display,
                           EditableValue: dataItem.EditableValue,
                           Type: typeName,
                           Category: category,
                           Access: value.Access,
                           StorageType: value.StorageType,
                           TypeModifierFlags: value.TypeModifierFlags,
                           Address: value.Address,
                           CustomUIVisualizers: customUIVisualizers,
                           ExternalModules: null,
                           DataItem: dataItem));
            }
        }