예제 #1
0
        private List <SymAttribute> ReadSymAttributes(ISymbolReader reader, ISymbolMethod method, bool haveCSharpCDI)
        {
            List <SymAttribute> attrs = new List <SymAttribute>();

            foreach (string name in AttributeNamesToSearch())
            {
                // If this attirubte represents C# CDI data, and we were able to expand it, then indicate that
                // the attribute here is redundant (as a raw view) and shouldn't be included again.
                if (name == k_cSharpCDIAttrName && haveCSharpCDI)
                {
                    continue;
                }

                // Note that despite being defined on ISymbolReader instead of ISymbolMethod, custom
                // attributes are permitted only on method metadata tokens.
                byte[] attrVal = reader.GetSymAttribute(method.Token, name);
                if (attrVal != null)
                {
                    SymAttribute attr = new SymAttribute();
                    attr.name  = name;
                    attr.value = Util.ToHexString(attrVal);
                    attrs.Add(attr);
                }
            }
            return(attrs);
        }
예제 #2
0
        internal void InitializeMethodBody(ModuleDefMD module, MethodDef ownerMethod, CilBody body, uint methodRid)
        {
            Debug.Assert((module == null) == (ownerMethod == null));
            if (reader == null || body == null)
            {
                return;
            }

            var token = new SymbolToken((int)(0x06000000 + methodRid));
            ISymbolMethod method;

#if THREAD_SAFE
            theLock.EnterWriteLock(); try {
#endif
            method = reader.GetMethod(token);
            if (method != null)
            {
                var pdbMethod = new PdbMethod();
                pdbMethod.Scope = CreateScope(module, ownerMethod == null ? new GenericParamContext() : GenericParamContext.Create(ownerMethod), body, method.RootScope);
                AddSequencePoints(body, method);

                var method2 = method as ISymbolMethod2;
                Debug.Assert(method2 != null);
                if (module != null && method2 != null && method2.IsAsyncMethod)
                {
                    pdbMethod.AsyncMethod = CreateAsyncMethod(module, ownerMethod, body, method2);
                }

                if (ownerMethod != null)
                {
                    // Read the custom debug info last so eg. local names have been initialized
                    var cdiData = reader.GetSymAttribute(token, "MD2");
                    if (cdiData != null && cdiData.Length != 0)
                    {
                        PdbCustomDebugInfoReader.Read(ownerMethod, body, pdbMethod.CustomDebugInfos, cdiData);
                    }
                }

                body.PdbMethod = pdbMethod;
            }
#if THREAD_SAFE
        }

        finally { theLock.ExitWriteLock(); }
#endif
        }
예제 #3
0
 private CSharpCDI ReadCSharpCDI(ISymbolReader reader, ISymbolMethod methodSymbol)
 {
     // See if the C# CDI attribute exists
     byte[] attrVal = reader.GetSymAttribute(methodSymbol.Token, k_cSharpCDIAttrName);
     if (attrVal == null)
     {
         return(null);        // No such attribute
     }
     try
     {
         return(CDIReader.ParseCDI(attrVal));
     }
     catch (System.FormatException e)
     {
         Console.WriteLine("WARNING: Error parsing CSharp CDI for method {0}: {1}", Util.AsToken(methodSymbol.Token.GetToken()), e.Message);
         return(null);
     }
 }
예제 #4
0
        private List<SymAttribute> ReadSymAttributes(ISymbolReader reader, ISymbolMethod method, bool haveCSharpCDI)
        {
            List<SymAttribute> attrs = new List<SymAttribute>();
            foreach (string name in AttributeNamesToSearch())
            {
                // If this attirubte represents C# CDI data, and we were able to expand it, then indicate that
                // the attribute here is redundant (as a raw view) and shouldn't be included again.
                if (name == k_cSharpCDIAttrName && haveCSharpCDI)
                    continue;

                // Note that despite being defined on ISymbolReader instead of ISymbolMethod, custom
                // attributes are permitted only on method metadata tokens.
                byte[] attrVal = reader.GetSymAttribute(method.Token, name);
                if (attrVal != null)
                {
                    SymAttribute attr = new SymAttribute();
                    attr.name = name;
                    attr.value = Util.ToHexString(attrVal);
                    attrs.Add(attr);
                }
            }
            return attrs;
        }
예제 #5
0
        private CSharpCDI ReadCSharpCDI(ISymbolReader reader, ISymbolMethod methodSymbol)
        {
            // See if the C# CDI attribute exists
            byte[] attrVal = reader.GetSymAttribute(methodSymbol.Token, k_cSharpCDIAttrName);
            if (attrVal == null)
                return null;        // No such attribute

            try
            {
                return CDIReader.ParseCDI(attrVal);
            }
            catch (System.FormatException e)
            {
                Console.WriteLine("WARNING: Error parsing CSharp CDI for method {0}: {1}", Util.AsToken(methodSymbol.Token.GetToken()), e.Message);
                return null;
            }
        }