Пример #1
0
		public CilBodyOptions(CilBody body, RVA rva, FileOffset fileOffset)
		{
			this.KeepOldMaxStack = body.KeepOldMaxStack;
			this.InitLocals = body.InitLocals;
			this.MaxStack = body.MaxStack;
			this.LocalVarSigTok = body.LocalVarSigTok;
			this.RVA = rva;
			this.FileOffset = fileOffset;
			this.Instructions.AddRange(body.Instructions);
			this.ExceptionHandlers.AddRange(body.ExceptionHandlers);
			this.Locals.AddRange(body.Variables);
			this.Scope = body.Scope;
		}
Пример #2
0
		public CilBodyOptions(CilBody body, RVA headerRva, FileOffset headerFileOffset, RVA rva, FileOffset fileOffset) {
			KeepOldMaxStack = body.KeepOldMaxStack;
			InitLocals = body.InitLocals;
			HeaderSize = body.HeaderSize;
			MaxStack = body.MaxStack;
			LocalVarSigTok = body.LocalVarSigTok;
			HeaderRVA = headerRva;
			HeaderFileOffset = headerFileOffset;
			RVA = rva;
			FileOffset = fileOffset;
			Instructions.AddRange(body.Instructions);
			ExceptionHandlers.AddRange(body.ExceptionHandlers);
			Locals.AddRange(body.Variables);
			Scope = body.Scope;
		}
Пример #3
0
        void Write(MethodDef method)
        {
            uint rid = metaData.GetRid(method);

            if (rid == 0)
            {
                Error("Method {0} ({1:X8}) is not defined in this module ({2})", method, method.MDToken.Raw, module);
                return;
            }

            var info        = new CurrentMethod(this, method, instrToOffset);
            var body        = method.Body;
            var symbolToken = new SymbolToken((int)new MDToken(MD.Table.Method, metaData.GetRid(method)).Raw);

            writer.OpenMethod(symbolToken);
            seqPointsHelper.Write(this, info.Method.Body.Instructions);

            var pdbMethod = body.PdbMethod;

            if (pdbMethod == null)
            {
                body.PdbMethod = pdbMethod = new PdbMethod();
            }
            var scope = pdbMethod.Scope;

            if (scope == null)
            {
                pdbMethod.Scope = scope = new PdbScope();
            }
            if (scope.Namespaces.Count == 0 && scope.Variables.Count == 0 && scope.Constants.Count == 0)
            {
                if (scope.Scopes.Count == 0)
                {
                    // We must open at least one sub scope (the sym writer creates the 'method' scope
                    // which covers the whole method) or the native PDB reader will fail to read all
                    // sequence points.
                    writer.OpenScope(0);
                    writer.CloseScope((int)info.BodySize);
                }
                else
                {
                    foreach (var childScope in scope.Scopes)
                    {
                        WriteScope(ref info, childScope, 0);
                    }
                }
            }
            else
            {
                Debug.Fail("Root scope isn't empty");
                WriteScope(ref info, scope, 0);
            }

            if (pdbMethod.CustomDebugInfos.Count != 0)
            {
                customDebugInfoWriterContext.Logger = GetLogger();
                var cdiData = PdbCustomDebugInfoWriter.Write(metaData, method, customDebugInfoWriterContext, pdbMethod.CustomDebugInfos);
                if (cdiData != null)
                {
                    writer.SetSymAttribute(symbolToken, "MD2", cdiData);
                }
            }

            var asyncMethod = pdbMethod.AsyncMethod;

            if (asyncMethod != null)
            {
                if (writer3 == null || !writer3.SupportsAsyncMethods)
                {
                    Error("PDB symbol writer doesn't support writing async methods");
                }
                else
                {
                    WriteAsyncMethod(ref info, asyncMethod);
                }
            }

            writer.CloseMethod();
        }
Пример #4
0
		IEnumerable<PdbScope> GetScopes(PdbScope root) {
			if (root == null)
				return new PdbScope[0];
			return GetScopes(new PdbScope[1] { root });
		}