Ejemplo n.º 1
0
 internal DkmClrType(DkmClrModuleInstance module, DkmClrAppDomain appDomain, Type lmrType)
 {
     _module = module;
     _appDomain = appDomain;
     _lmrType = lmrType;
     _evalAttributes = GetEvalAttributes(lmrType);
 }
Ejemplo n.º 2
0
        internal override EvaluationContextBase CreateTypeContext(
            DkmClrAppDomain appDomain,
            ImmutableArray<MetadataBlock> metadataBlocks,
            Guid moduleVersionId,
            int typeToken,
            bool useReferencedModulesOnly)
        {
            if (useReferencedModulesOnly)
            {
                // Avoid using the cache for referenced assemblies only
                // since this should be the exceptional case.
                var compilation = metadataBlocks.ToCompilationReferencedModulesOnly(moduleVersionId);
                return EvaluationContext.CreateTypeContext(
                    compilation,
                    moduleVersionId,
                    typeToken);
            }

            var previous = appDomain.GetMetadataContext<CSharpMetadataContext>();
            var context = EvaluationContext.CreateTypeContext(
                previous,
                metadataBlocks,
                moduleVersionId,
                typeToken);

            // New type context is not attached to the AppDomain since it is less
            // re-usable than the previous attached method context. (We could hold
            // on to it if we don't have a previous method context but it's unlikely
            // that we evaluated a type-level expression before a method-level.)
            Debug.Assert(context != previous.EvaluationContext);

            return context;
        }
Ejemplo n.º 3
0
        internal override EvaluationContextBase CreateMethodContext(
            DkmClrAppDomain appDomain,
            ImmutableArray<MetadataBlock> metadataBlocks,
            Lazy<ImmutableArray<AssemblyReaders>> unusedLazyAssemblyReaders,
            object symReader,
            Guid moduleVersionId,
            int methodToken,
            int methodVersion,
            int ilOffset,
            int localSignatureToken)
        {
            var previous = appDomain.GetDataItem<CSharpMetadataContext>();
            var context = EvaluationContext.CreateMethodContext(
                previous,
                metadataBlocks,
                symReader,
                moduleVersionId,
                methodToken,
                methodVersion,
                ilOffset,
                localSignatureToken);

            if (previous == null || context != previous.EvaluationContext)
            {
                appDomain.SetDataItem(DkmDataCreationDisposition.CreateAlways, new CSharpMetadataContext(context));
            }

            return context;
        }
Ejemplo n.º 4
0
        internal override string GetArrayDisplayString(DkmClrAppDomain appDomain, Type lmrType, ReadOnlyCollection<int> sizes, ReadOnlyCollection<int> lowerBounds, ObjectDisplayOptions options)
        {
            Debug.Assert(lmrType.IsArray);

            Type originalLmrType = lmrType;

            // Strip off all array types.  We'll process them at the end.
            while (lmrType.IsArray)
            {
                lmrType = lmrType.GetElementType();
            }

            var pooled = PooledStringBuilder.GetInstance();
            var builder = pooled.Builder;
            builder.Append('{');

            // We're showing the type of a value, so "dynamic" does not apply.
            bool unused;
            builder.Append(GetTypeName(new TypeAndCustomInfo(DkmClrType.Create(appDomain, lmrType)), escapeKeywordIdentifiers: false, sawInvalidIdentifier: out unused)); // NOTE: call our impl directly, since we're coupled anyway.

            var numSizes = sizes.Count;

            builder.Append('[');
            for (int i = 0; i < numSizes; i++)
            {
                if (i > 0)
                {
                    builder.Append(", ");
                }
                var lowerBound = lowerBounds[i];
                var size = sizes[i];
                if (lowerBound == 0)
                {
                    builder.Append(FormatLiteral(size, options));
                }
                else
                {
                    builder.Append(FormatLiteral(lowerBound, options));
                    builder.Append("..");
                    builder.Append(FormatLiteral(size + lowerBound - 1, options));
                }
            }
            builder.Append(']');

            lmrType = originalLmrType.GetElementType(); // Strip off one layer (already handled).
            while (lmrType.IsArray)
            {
                builder.Append('[');
                builder.Append(',', lmrType.GetArrayRank() - 1);
                builder.Append(']');

                lmrType = lmrType.GetElementType();
            }

            builder.Append('}');
            return pooled.ToStringAndFree();
        }
Ejemplo n.º 5
0
 internal DkmClrType(
     DkmClrModuleInstance module,
     DkmClrAppDomain appDomain,
     Type lmrType,
     DkmClrObjectFavoritesInfo favorites = null
     )
 {
     _module         = module;
     _appDomain      = appDomain;
     _lmrType        = lmrType;
     _evalAttributes = GetEvalAttributes(lmrType);
     _favorites      = favorites;
 }
Ejemplo n.º 6
0
 internal DkmClrRuntimeInstance(
     Assembly[] assemblies,
     GetModuleDelegate getModule           = null,
     GetMemberValueDelegate getMemberValue = null,
     bool enableNativeDebugging            = false)
     : base(enableNativeDebugging)
 {
     getModule ??= (r, a) => new DkmClrModuleInstance(r, a, (a != null) ? new DkmModule(a.GetName().Name + ".dll") : null);
     this.Assemblies     = assemblies;
     this.Modules        = assemblies.Select(a => getModule(this, a)).Where(m => m != null).ToArray();
     _defaultModule      = getModule(this, null);
     _appDomain          = new DkmClrAppDomain(this);
     this.GetMemberValue = getMemberValue;
 }
Ejemplo n.º 7
0
 internal DkmClrRuntimeInstance(
     Assembly[] assemblies,
     GetModuleDelegate getModule           = null,
     GetMemberValueDelegate getMemberValue = null)
 {
     if (getModule == null)
     {
         getModule = (r, a) => new DkmClrModuleInstance(r, a, (a != null) ? new DkmModule(a.GetName().Name + ".dll") : null);
     }
     this.Assemblies = assemblies;
     this.Modules    = assemblies.Select(a => getModule(this, a)).Where(m => m != null).ToArray();
     _defaultModule  = getModule(this, null);
     _appDomain      = new DkmClrAppDomain(this);
     _getMemberValue = getMemberValue;
 }
Ejemplo n.º 8
0
 internal DkmClrRuntimeInstance(
     Assembly[] assemblies,
     GetModuleDelegate getModule = null,
     GetMemberValueDelegate getMemberValue = null)
 {
     if (getModule == null)
     {
         getModule = (r, a) => new DkmClrModuleInstance(r, a, (a != null) ? new DkmModule(a.GetName().Name + ".dll") : null);
     }
     this.Assemblies = assemblies;
     this.Modules = assemblies.Select(a => getModule(this, a)).Where(m => m != null).ToArray();
     _defaultModule = getModule(this, null);
     _appDomain = new DkmClrAppDomain(this);
     _getMemberValue = getMemberValue;
 }
Ejemplo n.º 9
0
        internal override EvaluationContextBase CreateMethodContext(
            DkmClrAppDomain appDomain,
            ImmutableArray<MetadataBlock> metadataBlocks,
            Lazy<ImmutableArray<AssemblyReaders>> unusedLazyAssemblyReaders,
            object symReader,
            Guid moduleVersionId,
            int methodToken,
            int methodVersion,
            uint ilOffset,
            int localSignatureToken,
            bool useReferencedModulesOnly)
        {
            if (useReferencedModulesOnly)
            {
                // Avoid using the cache for referenced assemblies only
                // since this should be the exceptional case.
                var compilation = metadataBlocks.ToCompilationReferencedModulesOnly(moduleVersionId);
                return EvaluationContext.CreateMethodContext(
                    compilation,
                    symReader,
                    moduleVersionId,
                    methodToken,
                    methodVersion,
                    ilOffset,
                    localSignatureToken);
            }

            var previous = appDomain.GetMetadataContext<CSharpMetadataContext>();
            var context = EvaluationContext.CreateMethodContext(
                previous,
                metadataBlocks,
                symReader,
                moduleVersionId,
                methodToken,
                methodVersion,
                ilOffset,
                localSignatureToken);

            if (context != previous.EvaluationContext)
            {
                appDomain.SetMetadataContext(new CSharpMetadataContext(metadataBlocks, context));
            }

            return context;
        }
Ejemplo n.º 10
0
        internal override EvaluationContextBase CreateTypeContext(
            DkmClrAppDomain appDomain,
            ImmutableArray<MetadataBlock> metadataBlocks,
            Guid moduleVersionId,
            int typeToken)
        {
            var previous = appDomain.GetDataItem<CSharpMetadataContext>();
            var context = EvaluationContext.CreateTypeContext(
                appDomain.GetDataItem<CSharpMetadataContext>(),
                metadataBlocks,
                moduleVersionId,
                typeToken);

            // New type context is not attached to the AppDomain since it is less
            // re-usable than the previous attached method context. (We could hold
            // on to it if we don't have a previous method context but it's unlikely
            // that we evaluated a type-level expression before a method-level.)
            Debug.Assert(previous == null || context != previous.EvaluationContext);

            return context;
        }
Ejemplo n.º 11
0
 internal override void RemoveDataItem(DkmClrAppDomain appDomain)
 {
     appDomain.RemoveMetadataContext<CSharpMetadataContext>();
 }
Ejemplo n.º 12
0
 public static DkmClrType Create(DkmClrAppDomain appDomain, Type type)
 {
     return(new DkmClrType(appDomain.RuntimeInstance.DefaultModule, appDomain, type));
 }
Ejemplo n.º 13
0
 private static DkmClrModuleInstance GetModule(DkmClrAppDomain appDomain, string moduleName)
 {
     var modules = appDomain.GetClrModuleInstances();
     foreach (var module in modules)
     {
         if (string.Equals(module.Name, moduleName, StringComparison.OrdinalIgnoreCase))
         {
             return module;
         }
     }
     return null;
 }
Ejemplo n.º 14
0
 internal override bool RemoveDataItem(DkmClrAppDomain appDomain)
 {
     return appDomain.RemoveDataItem<CSharpMetadataContext>();
 }
Ejemplo n.º 15
0
 public static DkmClrType Create(DkmClrAppDomain appDomain, Type type)
 {
     return new DkmClrType(appDomain.RuntimeInstance.DefaultModule, appDomain, type);
 }
Ejemplo n.º 16
0
 internal abstract string GetArrayDisplayString(DkmClrAppDomain appDomain, Type lmrType, ReadOnlyCollection<int> sizes, ReadOnlyCollection<int> lowerBounds, ObjectDisplayOptions options);
Ejemplo n.º 17
0
 private static bool ShouldTryAgainWithMoreMetadataBlocks(DkmClrAppDomain appDomain, ImmutableArray<AssemblyIdentity> missingAssemblyIdentities, ref ImmutableArray<MetadataBlock> references)
 {
     return ShouldTryAgainWithMoreMetadataBlocks(
         (AssemblyIdentity assemblyIdentity, out uint size) => appDomain.GetMetaDataBytesPtr(assemblyIdentity.GetDisplayName(), out size),
         missingAssemblyIdentities,
         ref references);
 }
Ejemplo n.º 18
0
 private static TypeAndCustomInfo GetTupleFieldTypeAndInfo(
     DkmClrAppDomain appDomain,
     FieldInfo field,
     CustomTypeInfoTypeArgumentMap customTypeInfoMap)
 {
     var declaringTypeDef = field.DeclaringType.GetGenericTypeDefinition();
     var fieldDef = declaringTypeDef.GetTupleField(field.Name);
     var fieldType = DkmClrType.Create(appDomain, field.FieldType);
     var fieldTypeInfo = customTypeInfoMap.SubstituteCustomTypeInfo(fieldDef.FieldType, null);
     return new TypeAndCustomInfo(fieldType, fieldTypeInfo);
 }
Ejemplo n.º 19
0
 internal abstract EvaluationContextBase CreateTypeContext(
     DkmClrAppDomain appDomain,
     ImmutableArray<MetadataBlock> metadataBlocks,
     Guid moduleVersionId,
     int typeToken);
Ejemplo n.º 20
0
 internal abstract EvaluationContextBase CreateMethodContext(
     DkmClrAppDomain appDomain,
     ImmutableArray<MetadataBlock> metadataBlocks,
     Lazy<ImmutableArray<AssemblyReaders>> lazyAssemblyReaders,
     object symReader,
     Guid moduleVersionId,
     int methodToken,
     int methodVersion,
     int ilOffset,
     int localSignatureToken);
Ejemplo n.º 21
0
 internal abstract bool RemoveDataItem(DkmClrAppDomain appDomain);