Ejemplo n.º 1
0
 string IDkmClrFullNameProvider.GetClrTypeName(DkmInspectionContext inspectionContext, DkmClrType clrType, DkmClrCustomTypeInfo customTypeInfo)
 {
     Debug.Assert(inspectionContext != null);
     bool sawInvalidIdentifier;
     var name = GetTypeName(new TypeAndCustomInfo(clrType, customTypeInfo), escapeKeywordIdentifiers: true, sawInvalidIdentifier: out sawInvalidIdentifier);
     return sawInvalidIdentifier ? null : name;
 }
Ejemplo n.º 2
0
 private DkmSuccessEvaluationResult(
     DkmInspectionContext inspectionContext,
     DkmStackWalkFrame stackFrame,
     string name,
     string fullName,
     DkmEvaluationResultFlags flags,
     string value,
     string editableValue,
     string type,
     DkmEvaluationResultCategory category,
     DkmEvaluationResultAccessType access,
     DkmEvaluationResultStorageType storageType,
     DkmEvaluationResultTypeModifierFlags typeModifierFlags,
     DkmDataAddress address,
     ReadOnlyCollection<DkmCustomUIVisualizerInfo> customUIVisualizers,
     ReadOnlyCollection<DkmModuleInstance> externalModules,
     DkmDataItem dataItem) :
     base(inspectionContext, stackFrame, name, fullName, flags, type, dataItem)
 {
     this.Value = value;
     this.EditableValue = editableValue;
     this.Category = category;
     this.Access = access;
     this.StorageType = storageType;
     this.TypeModifierFlags = typeModifierFlags;
     this.CustomUIVisualizers = customUIVisualizers;
 }
Ejemplo n.º 3
0
 string IDkmClrFormatter.GetValueString(DkmClrValue value, DkmInspectionContext inspectionContext, ReadOnlyCollection<string> formatSpecifiers)
 {
     var options = ((inspectionContext.EvaluationFlags & DkmEvaluationFlags.NoQuotes) == 0) ?
         ObjectDisplayOptions.UseQuotes :
         ObjectDisplayOptions.None;
     return GetValueString(value, inspectionContext, options, GetValueFlags.IncludeObjectId);
 }
        /// <summary>
        /// Generate a Results Only row if the value is a synthesized
        /// value declared as IEnumerable or IEnumerable&lt;T&gt;.
        /// </summary>
        internal static EvalResultDataItem CreateResultsOnlyRowIfSynthesizedEnumerable(
            DkmInspectionContext inspectionContext,
            string name,
            DkmClrType declaredType,
            DkmClrCustomTypeInfo declaredTypeInfo,
            DkmClrValue value,
            Formatter formatter)
        {
            if ((value.ValueFlags & DkmClrValueFlags.Synthetic) == 0)
            {
                return null;
            }

            // Must be declared as IEnumerable or IEnumerable<T>, not a derived type.
            var enumerableType = GetEnumerableType(value, declaredType, requireExactInterface: true);
            if (enumerableType == null)
            {
                return null;
            }

            var expansion = CreateExpansion(inspectionContext, value, enumerableType, formatter);
            if (expansion == null)
            {
                return null;
            }

            return expansion.CreateResultsViewRow(
                inspectionContext,
                name,
                new TypeAndCustomInfo(declaredType.GetLmrType(), declaredTypeInfo),
                value,
                includeResultsFormatSpecifier: false,
                formatter: formatter);
        }
Ejemplo n.º 5
0
 DkmCompiledClrLocalsQuery IDkmClrExpressionCompiler.GetClrLocalVariableQuery(
     DkmInspectionContext inspectionContext,
     DkmClrInstructionAddress instructionAddress,
     bool argumentsOnly)
 {
     try
     {
         var references = instructionAddress.Process.GetMetadataBlocks(instructionAddress.ModuleInstance.AppDomain);
         var context = this.CreateMethodContext(instructionAddress, references);
         var builder = ArrayBuilder<LocalAndMethod>.GetInstance();
         string typeName;
         var assembly = context.CompileGetLocals(
             builder,
             argumentsOnly,
             out typeName,
             testData: null);
         Debug.Assert((builder.Count == 0) == (assembly.Count == 0));
         var locals = new ReadOnlyCollection<DkmClrLocalVariableInfo>(builder.SelectAsArray(l => DkmClrLocalVariableInfo.Create(l.LocalName, l.MethodName, l.Flags, DkmEvaluationResultCategory.Data)));
         builder.Free();
         return DkmCompiledClrLocalsQuery.Create(inspectionContext.RuntimeInstance, null, this.CompilerId, assembly, typeName, locals);
     }
     catch (Exception e) when (ExpressionEvaluatorFatalError.CrashIfFailFastEnabled(e))
     {
         throw ExceptionUtilities.Unreachable;
     }
 }
Ejemplo n.º 6
0
 private EvalResult GetRow(
     ResultProvider resultProvider,
     DkmInspectionContext inspectionContext,
     DkmClrValue value,
     int index,
     EvalResultDataItem parent)
 {
     var indices = GetIndices(index);
     var fullNameProvider = resultProvider.FullNameProvider;
     var name = fullNameProvider.GetClrArrayIndexExpression(inspectionContext, indices);
     var element = value.GetArrayElement(indices, inspectionContext);
     var fullName = GetFullName(inspectionContext, parent, name, fullNameProvider);
     return resultProvider.CreateDataItem(
         inspectionContext,
         name,
         typeDeclaringMemberAndInfo: default(TypeAndCustomInfo),
         declaredTypeAndInfo: _elementTypeAndInfo,
         value: element,
         useDebuggerDisplay: parent != null,
         expansionFlags: ExpansionFlags.IncludeBaseMembers,
         childShouldParenthesize: false,
         fullName: fullName,
         formatSpecifiers: Formatter.NoFormatSpecifiers,
         category: DkmEvaluationResultCategory.Other,
         flags: element.EvalFlags,
         evalFlags: inspectionContext.EvaluationFlags);
 }
Ejemplo n.º 7
0
 private EvalResult GetRow(
     DkmInspectionContext inspectionContext,
     DkmClrValue value,
     int index,
     EvalResultDataItem parent)
 {
     var typeParameter = _typeParameters[index];
     var typeArgument = _typeArguments[index];
     var typeArgumentInfo = _customTypeInfoMap.SubstituteCustomTypeInfo(typeParameter, customInfo: null);
     var formatSpecifiers = Formatter.NoFormatSpecifiers;
     return new EvalResult(
         ExpansionKind.TypeVariable,
         typeParameter.Name,
         typeDeclaringMemberAndInfo: default(TypeAndCustomInfo),
         declaredTypeAndInfo: new TypeAndCustomInfo(DkmClrType.Create(value.Type.AppDomain, typeArgument), typeArgumentInfo),
         useDebuggerDisplay: parent != null,
         value: value,
         displayValue: inspectionContext.GetTypeName(DkmClrType.Create(value.Type.AppDomain, typeArgument), typeArgumentInfo, formatSpecifiers),
         expansion: null,
         childShouldParenthesize: false,
         fullName: null,
         childFullNamePrefixOpt: null,
         formatSpecifiers: formatSpecifiers,
         category: DkmEvaluationResultCategory.Data,
         flags: DkmEvaluationResultFlags.ReadOnly,
         editableValue: null,
         inspectionContext: inspectionContext);
 }
        /// <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 &quot;query&quot; 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);
                }
            }
        }
Ejemplo n.º 9
0
        internal override void GetRows(
            ResultProvider resultProvider,
            ArrayBuilder<EvalResult> rows,
            DkmInspectionContext inspectionContext,
            EvalResultDataItem parent,
            DkmClrValue value,
            int startIndex,
            int count,
            bool visitAll,
            ref int index)
        {
            var fields = GetFields();

            int startIndex2;
            int count2;
            GetIntersection(startIndex, count, index, fields.Count, out startIndex2, out count2);

            int offset = startIndex2 - index;
            for (int i = 0; i < count2; i++)
            {
                var row = GetMemberRow(resultProvider, inspectionContext, value, fields[i + offset], parent);
                rows.Add(row);
            }

            index += fields.Count;
        }
Ejemplo n.º 10
0
        internal static DynamicViewExpansion CreateExpansion(DkmInspectionContext inspectionContext, DkmClrValue value, ResultProvider resultProvider)
        {
            if (value.IsError() || value.IsNull || value.HasExceptionThrown())
            {
                return null;
            }

            var type = value.Type.GetLmrType();
            if (!(type.IsComObject() || type.IsIDynamicMetaObjectProvider()))
            {
                return null;
            }

            var proxyValue = value.InstantiateDynamicViewProxy(inspectionContext);
            Debug.Assert((proxyValue == null) || (!proxyValue.IsNull && !proxyValue.IsError() && !proxyValue.HasExceptionThrown()));
            // InstantiateDynamicViewProxy may return null (if required assembly is missing, for instance).
            if (proxyValue == null)
            {
                return null;
            }

            // Expansion is based on the 'DynamicMetaObjectProviderDebugView.Items' property.
            var proxyType = proxyValue.Type;
            var itemsMemberExpansion = RootHiddenExpansion.CreateExpansion(
                proxyType.GetMemberByName("Items"),
                DynamicFlagsMap.Create(new TypeAndCustomInfo(proxyType)));
            return new DynamicViewExpansion(proxyValue, itemsMemberExpansion);
        }
Ejemplo n.º 11
0
 void IDkmClrResultProvider.GetResult(DkmClrValue value, DkmWorkList workList, DkmClrType declaredType, DkmClrCustomTypeInfo declaredTypeInfo, DkmInspectionContext inspectionContext, ReadOnlyCollection<string> formatSpecifiers, string resultName, string resultFullName, DkmCompletionRoutine<DkmEvaluationAsyncResult> completionRoutine)
 {
     if (formatSpecifiers == null)
     {
         formatSpecifiers = Formatter.NoFormatSpecifiers;
     }
     if (resultFullName != null)
     {
         ReadOnlyCollection<string> otherSpecifiers;
         resultFullName = FullNameProvider.GetClrExpressionAndFormatSpecifiers(inspectionContext, resultFullName, out otherSpecifiers);
         foreach (var formatSpecifier in otherSpecifiers)
         {
             formatSpecifiers = Formatter.AddFormatSpecifier(formatSpecifiers, formatSpecifier);
         }
     }
     var wl = new WorkList(workList, e => completionRoutine(DkmEvaluationAsyncResult.CreateErrorResult(e)));
     wl.ContinueWith(
         () => GetRootResultAndContinue(
             value,
             wl,
             declaredType,
             declaredTypeInfo,
             inspectionContext,
             resultName,
             resultFullName,
             formatSpecifiers,
             result => wl.ContinueWith(() => completionRoutine(new DkmEvaluationAsyncResult(result)))));
 }
Ejemplo n.º 12
0
 private DkmEvaluationResult GetRow(
     ResultProvider resultProvider,
     DkmInspectionContext inspectionContext,
     DkmClrValue value,
     int index,
     EvalResultDataItem parent)
 {
     var indices = GetIndices(index);
     var formatter = resultProvider.Formatter;
     var name = formatter.GetArrayIndexExpression(indices);
     var elementType = value.Type.ElementType;
     var element = value.GetArrayElement(indices);
     var fullName = GetFullName(parent, name, formatter);
     var dataItem = resultProvider.CreateDataItem(
         inspectionContext,
         name,
         typeDeclaringMember: null,
         declaredType: elementType.GetLmrType(),
         value: element,
         parent: parent,
         expansionFlags: ExpansionFlags.IncludeBaseMembers,
         childShouldParenthesize: false,
         fullName: fullName,
         formatSpecifiers: Formatter.NoFormatSpecifiers,
         category: DkmEvaluationResultCategory.Other,
         flags: element.EvalFlags,
         evalFlags: inspectionContext.EvaluationFlags);
     return resultProvider.GetResult(dataItem, element.Type, elementType, parent);
 }
        private static string TryGetFrameReturnTypeHelper(DkmInspectionContext inspectionContext, DkmStackWalkFrame frame)
        {
            ImportedMethod currentMethod = TryGetCurrentMethod(inspectionContext, frame);
            if (currentMethod == null)
                return null;

            return currentMethod.ReturnType.ToString();
        }
 internal static ResultsViewExpansion CreateExpansion(DkmInspectionContext inspectionContext, DkmClrValue value, Formatter formatter)
 {
     var enumerableType = GetEnumerableType(value);
     if (enumerableType == null)
     {
         return null;
     }
     return CreateExpansion(inspectionContext, value, enumerableType, formatter);
 }
 public static DkmEvaluationResultEnumContext Create(int Count, DkmStackWalkFrame StackFrame, DkmInspectionContext InspectionContext, DkmDataItem DataItem)
 {
     var enumContext = new DkmEvaluationResultEnumContext(Count, InspectionContext);
     if (DataItem != null)
     {
         enumContext.SetDataItem(DkmDataCreationDisposition.CreateNew, DataItem);
     }
     return enumContext;
 }
 /// <summary>
 /// This method is called by the debug engine to get the text representation of the return
 /// value of a stack frame.
 /// </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="workList">The current work list.  This is used to batch asynchronous
 /// work items.  If any asynchronous calls are needed later, this is the work list to pass
 /// to the asynchronous call.  It's not needed in our case.</param>
 /// <param name="frame">The frame to get the text representation of the return value for</param>
 /// <param name="completionRoutine">Completion routine to call when work is completed</param>
 void IDkmLanguageFrameDecoder.GetFrameReturnType(
     DkmInspectionContext inspectionContext,
     DkmWorkList workList,
     DkmStackWalkFrame frame,
     DkmCompletionRoutine<DkmGetFrameReturnTypeAsyncResult> completionRoutine)
 {
     string name = TryGetFrameReturnTypeHelper(inspectionContext, frame) ?? "<Unknown>";
     completionRoutine(new DkmGetFrameReturnTypeAsyncResult(name));
 }
 /// <summary>
 /// This method is called by the debug engine to get the text representation of a stack
 /// frame.
 /// </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="workList">The current work list.  This is used to batch asynchronous
 /// work items.  If any asynchronous calls are needed later, this is the work list to pass
 /// to the asynchronous call.  It's not needed in our case.</param>
 /// <param name="frame">The frame to get the text representation for</param>
 /// <param name="argumentFlags">Option flags to change the way we format frames</param>
 /// <param name="completionRoutine">Completion routine to call when work is completed</param>
 void IDkmLanguageFrameDecoder.GetFrameName(
     DkmInspectionContext inspectionContext,
     DkmWorkList workList,
     DkmStackWalkFrame frame,
     DkmVariableInfoFlags argumentFlags,
     DkmCompletionRoutine<DkmGetFrameNameAsyncResult> completionRoutine)
 {
     string name = TryGetFrameNameHelper(inspectionContext, frame, argumentFlags) ?? "<Unknown Method>";
     completionRoutine(new DkmGetFrameNameAsyncResult(name));
 }
Ejemplo n.º 18
0
 public void GetChildren(DkmWorkList workList, int initialRequestSize, DkmInspectionContext inspectionContext, DkmCompletionRoutine<DkmGetChildrenAsyncResult> completionRoutine)
 {
     InspectionContext.InspectionSession.InvokeResultProvider(
         MethodId.GetChildren,
         r =>
         {
             r.GetChildren(this, workList, initialRequestSize, inspectionContext, completionRoutine);
             return (object)null;
         });
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Get the rows within the given range. 'index' is advanced
 /// to the end of the range, or if 'visitAll' is true, 'index' is
 /// advanced to the end of the expansion.
 /// </summary>
 internal abstract void GetRows(
     ResultProvider resultProvider,
     ArrayBuilder<DkmEvaluationResult> rows,
     DkmInspectionContext inspectionContext,
     EvalResultDataItem parent,
     DkmClrValue value,
     int startIndex,
     int count,
     bool visitAll,
     ref int index);
Ejemplo n.º 20
0
 string IDkmClrFullNameProvider.GetClrCastExpression(DkmInspectionContext inspectionContext, string argument, DkmClrType type, DkmClrCustomTypeInfo customTypeInfo, bool parenthesizeArgument, bool parenthesizeEntireExpression)
 {
     bool sawInvalidIdentifier;
     var name = GetTypeName(new TypeAndCustomInfo(type, customTypeInfo), escapeKeywordIdentifiers: true, sawInvalidIdentifier: out sawInvalidIdentifier);
     if (sawInvalidIdentifier)
     {
         return null;
     }
     return GetCastExpression(argument, name, parenthesizeArgument, parenthesizeEntireExpression);
 }
Ejemplo n.º 21
0
 internal static EvalResultDataItem CreateMembersOnlyRow(
     DkmInspectionContext inspectionContext,
     string name,
     DkmClrValue value,
     Formatter formatter)
 {
     var expansion = CreateExpansion(inspectionContext, value, formatter);
     return (expansion != null) ?
         expansion.CreateDynamicViewRow(inspectionContext, name, parent: null, formatter: formatter) :
         new EvalResultDataItem(name, Resources.DynamicViewNotDynamic);
 }
Ejemplo n.º 22
0
 internal static EvalResult CreateMembersOnlyRow(
     DkmInspectionContext inspectionContext,
     string name,
     DkmClrValue value,
     ResultProvider resultProvider)
 {
     var expansion = CreateExpansion(inspectionContext, value, resultProvider);
     return (expansion != null) ?
         expansion.CreateDynamicViewRow(inspectionContext, name, parent: null, fullNameProvider: resultProvider.FullNameProvider) :
         new EvalResult(name, Resources.DynamicViewNotDynamic, inspectionContext);
 }
Ejemplo n.º 23
0
        void IDkmClrResultProvider.GetChildren(DkmEvaluationResult evaluationResult, DkmWorkList workList, int initialRequestSize, DkmInspectionContext inspectionContext, DkmCompletionRoutine<DkmGetChildrenAsyncResult> completionRoutine)
        {
            var dataItem = evaluationResult.GetDataItem<EvalResultDataItem>();
            if (dataItem == null)
            {
                // We don't know about this result.  Call next implementation
                evaluationResult.GetChildren(workList, initialRequestSize, inspectionContext, completionRoutine);
                return;
            }

            completionRoutine(GetChildren(inspectionContext, evaluationResult, dataItem, initialRequestSize));
        }
        /// <summary>
        /// This method is called by the debug engine to populate the text representing the value
        /// of an expression.
        /// </summary>
        /// <param name="clrValue">The raw value to get the text for</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="formatSpecifiers"></param>
        /// <returns>The text representing the given value</returns>
        string IDkmClrFormatter.GetValueString(DkmClrValue clrValue, DkmInspectionContext inspectionContext, ReadOnlyCollection<string> formatSpecifiers)
        {
            DkmClrType clrType = clrValue.Type;
            if (clrType == null)
            {
                // This can be null in some error cases
                return string.Empty;
            }

            // Try to format the value.  If we can't format the value, delegate to the C# Formatter.
            string value = TryFormatValue(clrValue, inspectionContext);
            return value ?? clrValue.GetValueString(inspectionContext, formatSpecifiers);
        }
Ejemplo n.º 25
0
 public static string GetTypeName(this System.Type type, DkmClrCustomTypeInfo typeInfo, bool escapeKeywordIdentifiers = false, DkmInspectionContext inspectionContext = null)
 {
     var formatter = new CSharpFormatter();
     var clrType = new DkmClrType((TypeImpl)type);
     if (inspectionContext == null)
     {
         var inspectionSession = new DkmInspectionSession(ImmutableArray.Create<IDkmClrFormatter>(formatter), ImmutableArray.Create<IDkmClrResultProvider>(new CSharpResultProvider()));
         inspectionContext = new DkmInspectionContext(inspectionSession, DkmEvaluationFlags.None, radix: 10, runtimeInstance: null);
     }
     return escapeKeywordIdentifiers ?
         ((IDkmClrFullNameProvider)formatter).GetClrTypeName(inspectionContext, clrType, typeInfo) :
         inspectionContext.GetTypeName(clrType, typeInfo, Formatter.NoFormatSpecifiers);
 }
Ejemplo n.º 26
0
        public CppExpressionEvaluator(DkmThread thread, ulong frameBase, ulong vframe) {
            _process = thread.Process;

            var inspectionSession = DkmInspectionSession.Create(_process, null);
            _cppInspectionContext = DkmInspectionContext.Create(inspectionSession, _process.GetNativeRuntimeInstance(), thread, Timeout,
                DkmEvaluationFlags.TreatAsExpression | DkmEvaluationFlags.NoSideEffects, DkmFuncEvalFlags.None, 10, CppLanguage, null);

            const int CV_ALLREG_VFRAME = 0x00007536;
            var vframeReg = DkmUnwoundRegister.Create(CV_ALLREG_VFRAME, new ReadOnlyCollection<byte>(BitConverter.GetBytes(vframe)));
            var regs = thread.GetCurrentRegisters(new[] { vframeReg });
            var iaddr = _process.CreateNativeInstructionAddress(regs.GetInstructionPointer());
            _nativeFrame = DkmStackWalkFrame.Create(thread, iaddr, frameBase, 0, DkmStackWalkFrameFlags.None, null, regs, null);
        }
Ejemplo n.º 27
0
 private DkmFailedEvaluationResult(
     DkmInspectionContext inspectionContext,
     DkmStackWalkFrame stackFrame,
     string name,
     string fullName,
     string errorMessage,
     DkmEvaluationResultFlags flags,
     string type,
     DkmDataItem dataItem) :
     base(inspectionContext, stackFrame, name, fullName, flags, type, dataItem)
 {
     this.ErrorMessage = errorMessage;
 }
        private static DkmEvaluationResult GetRow(
            ResultProvider resultProvider,
            DkmInspectionContext inspectionContext,
            DkmClrValue pointer,
            Type elementType,
            EvalResultDataItem parent)
        {
            var value = pointer.Dereference();
            var valueType = value.Type.GetLmrType();
            var wasExceptionThrown = value.EvalFlags.Includes(DkmEvaluationResultFlags.ExceptionThrown);

            string debuggerDisplayName;
            string debuggerDisplayValue;
            string debuggerDisplayType;
            value.GetDebuggerDisplayStrings(out debuggerDisplayName, out debuggerDisplayValue, out debuggerDisplayType);

            var declaredType = elementType;
            var typeName = debuggerDisplayType ?? pointer.InspectionContext.GetTypeName(DkmClrType.Create(pointer.Type.AppDomain, declaredType));
            var expansion = wasExceptionThrown
                ? null
                : resultProvider.GetTypeExpansion(inspectionContext, declaredType, value, ExpansionFlags.None);
            var fullName = string.Format("*{0}", parent.ChildFullNamePrefix);
            var editableValue = resultProvider.Formatter.GetEditableValue(value);

            // NB: Full name is based on the real (i.e. not DebuggerDisplay) name.  This is a change from dev12, 
            // which used the DebuggerDisplay name, causing surprising results in "Add Watch" scenarios.
            var dataItem = new EvalResultDataItem(
                name: null, // Okay for pointer dereferences.
                typeDeclaringMember: null,
                declaredType: declaredType,
                value: value,
                expansion: expansion,
                childShouldParenthesize: true,
                fullName: fullName,
                childFullNamePrefixOpt: fullName,
                formatSpecifiers: Formatter.NoFormatSpecifiers,
                category: DkmEvaluationResultCategory.Other,
                flags: DkmEvaluationResultFlags.None,
                editableValue: editableValue);

            var name = debuggerDisplayName ?? fullName;
            var display = debuggerDisplayValue ?? 
                (wasExceptionThrown ? string.Format(Resources.InvalidPointerDereference, fullName) : value.GetValueString());

            return ResultProvider.CreateEvaluationResult(
                value,
                name,
                typeName,
                display,
                dataItem);
        }
        private static string TryGetFrameNameHelper(DkmInspectionContext inspectionContext, DkmStackWalkFrame frame, DkmVariableInfoFlags argumentFlags)
        {
            ImportedMethod currentMethod = TryGetCurrentMethod(inspectionContext, frame);
            if (currentMethod == null)
                return null;

            string name = currentMethod.Name;
            if (string.Equals(name, "$.main", StringComparison.Ordinal))
                return "<Main Block>";

            if (argumentFlags == DkmVariableInfoFlags.None)
                return name;

            Variable[] args = currentMethod.GetParameters();
            if (args.Length == 0)
                return name;

            StringBuilder nameBuilder = new StringBuilder();
            nameBuilder.Append(name);
            nameBuilder.Append('(');

            bool first = true;
            bool showTypes = argumentFlags.HasFlag(DkmVariableInfoFlags.Types);
            bool showNames = argumentFlags.HasFlag(DkmVariableInfoFlags.Names);
            foreach (Variable arg in args)
            {
                if (first)
                    first = false;
                else
                    nameBuilder.Append("; ");

                IrisType argType = arg.Type;
                if (argType.IsByRef)
                {
                    nameBuilder.Append("var ");
                    argType = argType.GetElementType();
                }

                if (showNames)
                    nameBuilder.Append(arg.Name);

                if (showNames && showTypes)
                    nameBuilder.Append(" : ");

                if (showTypes)
                    nameBuilder.Append(argType);
            }

            nameBuilder.Append(')');
            return nameBuilder.ToString();
        }
Ejemplo n.º 30
0
 void IDkmClrResultProvider.GetResult(DkmClrValue value, DkmWorkList workList, DkmClrType declaredType, DkmClrCustomTypeInfo declaredTypeInfo, DkmInspectionContext inspectionContext, ReadOnlyCollection<string> formatSpecifiers, string resultName, string resultFullName, DkmCompletionRoutine<DkmEvaluationAsyncResult> completionRoutine)
 {
     // TODO: Use full name
     var wl = new WorkList(workList, e => completionRoutine(DkmEvaluationAsyncResult.CreateErrorResult(e)));
     GetRootResultAndContinue(
         value,
         wl,
         declaredType,
         declaredTypeInfo,
         inspectionContext,
         resultName,
         result => wl.ContinueWith(() => completionRoutine(new DkmEvaluationAsyncResult(result))));
     wl.Execute();
 }
Ejemplo n.º 31
0
 public virtual void GetChildren(DkmWorkList workList, int initialRequestSize, DkmInspectionContext inspectionContext, DkmCompletionRoutine <DkmGetChildrenAsyncResult> completionRoutine)
 {
     throw new NotImplementedException();
 }
        public static DkmEvaluationResultEnumContext Create(int Count, DkmStackWalkFrame StackFrame, DkmInspectionContext InspectionContext, DkmDataItem DataItem)
        {
            var enumContext = new DkmEvaluationResultEnumContext(Count, InspectionContext);

            if (DataItem != null)
            {
                enumContext.SetDataItem(DkmDataCreationDisposition.CreateNew, DataItem);
            }
            return(enumContext);
        }
 internal DkmEvaluationResultEnumContext(int count, DkmInspectionContext inspectionContext)
 {
     this.Count             = count;
     this.InspectionContext = inspectionContext;
 }