Ejemplo n.º 1
0
 public SymbolMethod(ISymUnmanagedMethod unmanagedMethod)
 {
     if (unmanagedMethod == null)
     {
         throw new ArgumentNullException("unmanagedMethod");
     }
     this.unmanagedMethod = unmanagedMethod;
 }
Ejemplo n.º 2
0
        public SymMethod(ISymUnmanagedMethod unmanagedMethod)
        {
            // We should not wrap null instances
            if (unmanagedMethod == null)
                throw new ArgumentNullException("unmanagedMethod");

            m_unmanagedMethod = unmanagedMethod;
        }
 public int GetMethodByVersionPreRemap(
     int methodToken,
     int version,
     out ISymUnmanagedMethod retVal
     )
 {
     retVal = null;
     return(HResult.E_NOTIMPL);
 }
		public static ISymUnmanagedMethod[] GetMethodsFromDocumentPosition(this CorSymReader_SxSClass instance, ISymUnmanagedDocument document, uint line, uint column)
		{
			uint count;
			instance.__GetMethodsFromDocumentPosition(document, line, column, 0, out count, new ISymUnmanagedMethod[0]);
			var methods = new ISymUnmanagedMethod[count];
			instance.__GetMethodsFromDocumentPosition(document, line, column, count, out count, methods);
			ProcessOutParameter(methods);
			return methods;
		}
Ejemplo n.º 5
0
        public int GetMethodByVersion(int methodToken, int version, out ISymUnmanagedMethod retVal)
        {
            // Versions are 1-based.
            Debug.Assert(version >= 1);
            var reader = _readerVersions[version - 1];

            version = _readerVersions.Length > 1 ? 1 : version;
            return(reader.GetMethodByVersion(methodToken, version, out retVal));
        }
Ejemplo n.º 6
0
 public int GetMethodFromDocumentPosition(
     ISymUnmanagedDocument document,
     int line,
     int column,
     out ISymUnmanagedMethod method
     )
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 7
0
        public ISymbolMethod GetMethodFromDocumentPosition(ISymbolDocument document,
                                                           int line,
                                                           int column)
        {
            ISymUnmanagedMethod unmanagedMethod = null;

            m_reader.GetMethodFromDocumentPosition(((SymbolDocument)document).InternalDocument, line, column, out unmanagedMethod);
            return(new SymMethod(unmanagedMethod));
        }
Ejemplo n.º 8
0
 internal static void GetAllScopes(
     this ISymUnmanagedMethod method,
     ArrayBuilder <ISymUnmanagedScope> allScopes,
     ArrayBuilder <ISymUnmanagedScope> containingScopes,
     int offset,
     bool isScopeEndInclusive)
 {
     GetAllScopes(method.GetRootScope(), allScopes, containingScopes, offset, isScopeEndInclusive);
 }
Ejemplo n.º 9
0
 public int GetMethodByVersion(SymbolToken methodToken, int version, out ISymUnmanagedMethod retVal)
 {
     var hr = _reader.GetMethodByVersion(methodToken, version, out retVal);
     if (retVal != null)
     {
         retVal = new SymMethod(this, retVal);
     }
     return hr;
 }
Ejemplo n.º 10
0
        public SymbolMethod(ISymUnmanagedMethod unmanaged)
        {
            if (unmanaged == null)
            {
                throw new ArgumentNullException("unmanaged");
            }

            _unmanaged = unmanaged;
        }
Ejemplo n.º 11
0
        public SymMethod(ISymUnmanagedMethod unmanagedMethod)
        {
            // We should not wrap null instances
            if (unmanagedMethod == null)
            {
                throw new ArgumentNullException("unmanagedMethod");
            }

            m_unmanagedMethod = unmanagedMethod;
        }
Ejemplo n.º 12
0
        /// <remarks>
        /// Test helper.
        /// </remarks>
        internal static void GetAllScopes(
            this ISymUnmanagedMethod method,
            ArrayBuilder <ISymUnmanagedScope> builder
            )
        {
            var unused = ArrayBuilder <ISymUnmanagedScope> .GetInstance();

            GetAllScopes(method, builder, unused, offset: -1, isScopeEndInclusive: false);
            unused.Free();
        }
Ejemplo n.º 13
0
        public int GetMethodByVersion(int methodToken, int version, out ISymUnmanagedMethod retVal)
        {
            var hr = _reader.GetMethodByVersion(methodToken, version, out retVal);

            if (retVal != null)
            {
                retVal = new SymMethod(this, retVal);
            }
            return(hr);
        }
        public static int GetToken(this ISymUnmanagedMethod method)
        {
            if (method == null)
            {
                throw new ArgumentNullException(nameof(method));
            }

            ThrowExceptionForHR(method.GetToken(out int token));
            return(token);
        }
        public static ISymUnmanagedScope GetRootScope(this ISymUnmanagedMethod method)
        {
            if (method == null)
            {
                throw new ArgumentNullException(nameof(method));
            }

            ThrowExceptionForHR(method.GetRootScope(out var scope));
            return(scope);
        }
 public int GetMethodFromDocumentPosition(
     ISymUnmanagedDocument document,
     int line,
     int column,
     out ISymUnmanagedMethod retVal
     )
 {
     retVal = null;
     return(HResult.E_NOTIMPL);
 }
        public static ISymUnmanagedDocument[] GetDocumentsForMethod(this ISymUnmanagedMethod method)
        {
            if (method == null)
            {
                throw new ArgumentNullException(nameof(method));
            }

            return(NullToEmpty(GetItems((ISymEncUnmanagedMethod)method,
                                        (ISymEncUnmanagedMethod a, out int b) => a.GetDocumentsForMethodCount(out b),
                                        (ISymEncUnmanagedMethod a, int b, out int c, ISymUnmanagedDocument[] d) => a.GetDocumentsForMethod(b, out c, d))));
        }
        public static ISymUnmanagedMethod[] GetMethodsFromDocumentPosition(this CorSymReader_SxSClass instance, ISymUnmanagedDocument document, uint line, uint column)
        {
            uint count;

            instance.__GetMethodsFromDocumentPosition(document, line, column, 0, out count, new ISymUnmanagedMethod[0]);
            var methods = new ISymUnmanagedMethod[count];

            instance.__GetMethodsFromDocumentPosition(document, line, column, count, out count, methods);
            ProcessOutParameter(methods);
            return(methods);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Get a string representing the source location for the given IL offset and method
        /// </summary>
        /// <param name="method">The method of interest</param>
        /// <param name="ilOffset">The offset into the IL</param>
        /// <returns>A string of the format [filepath]:[line] (eg. "C:\temp\foo.cs:123"), or null
        /// if a matching PDB couldn't be found</returns>
        /// <remarks>Thows various COMExceptions (from DIA SDK error values) if a PDB couldn't be opened/read</remarks>
        public SourceLoc GetSourceLoc(MethodBase method, int ilOffset)
        {
            // Get the symbol reader corresponding to the module of the supplied method
            string modulePath             = method.Module.FullyQualifiedName;
            ISymUnmanagedReader symReader = GetSymbolReaderForFile(modulePath);

            if (symReader == null)
            {
                return(null);    // no PDBs
            }
            ISymUnmanagedMethod symMethod = symReader.GetMethod(new SymbolToken(method.MetadataToken));

            // Get all the sequence points for the method
            int count = symMethod.GetSequencePointCount();

            ISymUnmanagedDocument[] docs = new ISymUnmanagedDocument[count];
            int[] startLines             = new int[count];
            int[] ilOffsets = new int[count];
            int[] endLines  = new int[count];
            int[] startCols = new int[count];
            int[] endCols   = new int[count];
            int   outPoints;

            symMethod.GetSequencePoints(count, out outPoints, ilOffsets, docs, startLines, startCols, endLines, endCols);

            // Find the closest sequence point to the requested offset
            // Sequence points are returned sorted by offset so we're looking for the last one with
            // an offset less than or equal to the requested offset.
            // Note that this won't necessarily match the real source location exactly if
            // the code was jit-compiled with optimizations.
            int i;

            for (i = 0; i < count; i++)
            {
                if (ilOffsets[i] > ilOffset)
                {
                    break;
                }
            }
            // Found the first mismatch, back up if it wasn't the first
            if (i > 0)
            {
                i--;
            }

            // Now return the source file and line number for this sequence point
            StringBuilder url = new StringBuilder(512);
            int           len;

            docs[i].GetURL(url.Capacity, out len, url);

            return(new SourceLoc(url.ToString(), startLines[i], endLines[i], startCols[i], endCols[i]));
        }
        public static int GetMethodVersion(this ISymUnmanagedReader reader, ISymUnmanagedMethod method)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            int version;

            ThrowExceptionForHR(reader.GetMethodVersion(method, out version));
            return(version);
        }
Ejemplo n.º 21
0
        public int GetMethodVersion(ISymUnmanagedMethod method, out int version)
        {
            var symMethod = AsSymMethod(method);

            if (symMethod == null)
            {
                version = 0;
                return(HResult.E_INVALIDARG);
            }

            version = symMethod.PdbReader.Version;
            return(HResult.S_OK);
        }
Ejemplo n.º 22
0
            private static bool TryGetDocsAndLines(
                ISymUnmanagedMethod methodSymbols,
                CompetitionState competitionState,
                out ISymUnmanagedDocument[] documents,
                out int[] startLines)
            {
                documents  = Array <ISymUnmanagedDocument> .Empty;
                startLines = Array <int> .Empty;
                try
                {
                    int numAvailable;
                    var hr = methodSymbols.GetSequencePointCount(out numAvailable);
                    ThrowExceptionForHR(hr);

                    documents  = new ISymUnmanagedDocument[numAvailable];
                    startLines = new int[numAvailable];

                    if (numAvailable > 0)
                    {
                        var offsets      = new int[numAvailable];
                        var startColumns = new int[numAvailable];
                        var endLines     = new int[numAvailable];
                        var endColumns   = new int[numAvailable];

                        int numRead;
                        hr = methodSymbols.GetSequencePoints(
                            numAvailable, out numRead,
                            offsets, documents,
                            startLines, startColumns,
                            endLines, endColumns);
                        ThrowExceptionForHR(hr);

                        if (numRead != numAvailable)
                        {
                            throw new COMException($"Read only {numRead} of {numAvailable} sequence points.");
                        }
                    }
                }
                catch (COMException ex)
                {
                    // ReSharper disable once PossibleNullReferenceException
                    competitionState.WriteExceptionMessage(
                        MessageSource.Analyser, MessageSeverity.ExecutionError,
                        "Could not parse method symbols.", ex);

                    return(false);
                }

                return(startLines.Length > 0);
            }
Ejemplo n.º 23
0
        public int GetMethodFromDocumentPosition(
            ISymUnmanagedDocument document,
            int line,
            int column,
            [MarshalAs(UnmanagedType.Interface)] out ISymUnmanagedMethod method)
        {
            var symDocument = AsSymDocument(document);

            if (symDocument == null)
            {
                method = null;
                return(HResult.E_INVALIDARG);
            }

            var methodExtents = GetMethodExtents();
            var methods       = methodExtents.GetMethodsContainingLine(symDocument.GetId(), line);

            if (methods == null)
            {
                method = null;
                return(HResult.E_FAIL);
            }

            var candidate = default((MethodId Id, int Version));

            foreach (var(methodId, version) in methods)
            {
                if (candidate.Id.IsDefault || methodId < candidate.Id)
                {
                    candidate = (methodId, version);
                }
            }

            if (candidate.Id.IsDefault)
            {
                method = null;
                return(HResult.E_FAIL);
            }

            var pdbReader = GetReader(candidate.Version);

            if (!pdbReader.TryGetMethodHandle(candidate.Id, out var handle))
            {
                method = null;
                return(HResult.E_FAIL);
            }

            method = new SymMethod(pdbReader, handle);
            return(HResult.S_OK);
        }
Ejemplo n.º 24
0
        public int GetMethodByVersion(int methodToken, int version, out ISymUnmanagedMethod retVal)
        {
            Assert.Equal(1, version);

            MethodDebugInfoBytes info;

            if (!_methodDebugInfoMap.TryGetValue(methodToken, out info))
            {
                retVal = null;
                return(HResult.E_FAIL);
            }

            Assert.NotNull(info);
            retVal = info.Method;
            return(HResult.S_OK);
        }
Ejemplo n.º 25
0
            public Builder(string[][] importStringGroups = null, bool suppressUsingInfo = false, ISymUnmanagedConstant[] constants = null)
            {
                _bytesBuilder = ArrayBuilder<byte>.GetInstance();
                if (importStringGroups != null && !suppressUsingInfo)
                {
                    var groupSizes = importStringGroups.Select(g => (short)g.Length).ToArray();
                    AddUsingInfo(groupSizes);
                }

                var namespaces = importStringGroups == null
                    ? default(ImmutableArray<ISymUnmanagedNamespace>)
                    : importStringGroups.SelectMany(names => names.Select(name => (ISymUnmanagedNamespace)new MockSymUnmanagedNamespace(name))).ToImmutableArray();
                var childScope = new MockSymUnmanagedScope(default(ImmutableArray<ISymUnmanagedScope>), namespaces, constants);
                var rootScope = new MockSymUnmanagedScope(ImmutableArray.Create<ISymUnmanagedScope>(childScope), default(ImmutableArray<ISymUnmanagedNamespace>));
                _method = new MockSymUnmanagedMethod(rootScope);
            }
Ejemplo n.º 26
0
        public static ISymUnmanagedMethod GetMethodByVersion(this ISymUnmanagedReader reader, int methodToken, int methodVersion)
        {
            ISymUnmanagedMethod method = null;
            int hr = reader.GetMethodByVersion(new SymbolToken(methodToken), methodVersion, out method);

            ThrowExceptionForHR(hr);

            if (hr < 0)
            {
                // method has no symbol info
                return(null);
            }

            Debug.Assert(method != null);
            return(method);
        }
        public static ISymUnmanagedMethod GetMethodByVersion(this ISymUnmanagedReader reader, int methodToken, int methodVersion)
        {
            ISymUnmanagedMethod method = null;
            int hr = reader.GetMethodByVersion(new SymbolToken(methodToken), methodVersion, out method);

            ThrowExceptionForHR(hr);

            if (hr < 0)
            {
                // method has no symbol info
                Debug.WriteLine(string.Format("Invalid method token '0x{0:x8}' or version '{1}' (hresult = 0x{2:x8})", methodToken, methodVersion, hr));
                return(null);
            }

            Debug.Assert(method != null);
            return(method);
        }
Ejemplo n.º 28
0
        public ISymbolMethod GetMethod(SymbolToken method, int version)
        {
            ISymUnmanagedMethod unmanagedMethod = null;
            int hr = m_reader.GetMethodByVersion(method, version, out unmanagedMethod);

            if (hr == (int)HResult.E_FAIL)
            {
                // This means that the method has no symbol info because it's probably empty
                // This can happen for virtual methods with no IL
                return(null);
            }
            else
            {
                Marshal.ThrowExceptionForHR(hr);
            }
            return(new SymMethod(unmanagedMethod));
        }
Ejemplo n.º 29
0
        internal static ISymUnmanagedMethod[] GetMethodsFromDocumentPosition(
            ISymUnmanagedReader symReader,
            ISymUnmanagedDocument symDocument,
            int line,
            int column)
        {
            Assert.True(line >= 1);
            Assert.True(column >= 0);

            Assert.Equal(HResult.S_OK, symReader.GetMethodsFromDocumentPosition(symDocument, line, column, 0, out int count, null));

            var methods = new ISymUnmanagedMethod[count];

            Assert.Equal(HResult.S_OK, symReader.GetMethodsFromDocumentPosition(symDocument, line, column, count, out int count2, methods));
            Assert.Equal(count, count2);
            return(methods);
        }
        // ISymUnmanagedMethod

        public static SequencePoint[] GetSequencePoints(this ISymUnmanagedMethod symMethod, int codesize)
        {
            uint count = symMethod.GetSequencePointCount();

            ISymUnmanagedDocument[] documents = new ISymUnmanagedDocument[count];
            uint[] offsets    = new uint[count];
            uint[] lines      = new uint[count];
            uint[] columns    = new uint[count];
            uint[] endLines   = new uint[count];
            uint[] endColumns = new uint[count];

            symMethod.GetSequencePoints(
                count,
                out count,
                offsets,
                documents,
                lines,
                columns,
                endLines,
                endColumns
                );

            var sequencePoints = new SequencePoint[count];
            var urls           = documents.Distinct().ToDictionary(d => d, d => d.GetURL());
            var sums           = documents.Distinct().ToDictionary(d => d, d => d.GetCheckSum());

            uint token = symMethod.GetToken();

            for (int i = 0; i < count; i++)
            {
                sequencePoints[i] = new SequencePoint()
                {
                    MethodDefToken = token,
                    ILRanges       = new [] { new ILRange((int)offsets[i], i + 1 < count ? (int)offsets[i + 1] : codesize) },
                    Filename       = urls[documents[i]],
                    FileCheckSum   = sums[documents[i]],
                    StartLine      = (int)lines[i],
                    StartColumn    = (int)columns[i],
                    EndLine        = (int)endLines[i],
                    EndColumn      = (int)endColumns[i]
                };
            }

            return(sequencePoints);
        }
Ejemplo n.º 31
0
        public int GetMethodByVersion(int methodToken, int version, out ISymUnmanagedMethod retVal)
        {
            // Versions are 1-based.
            Debug.Assert(version >= 1);
            var reader = _readerVersions[version - 1];

            version = _readerVersions.Length > 1 ? 1 : version;
            var hr = reader.GetMethodByVersion(methodToken, version, out retVal);

            if (retVal != null)
            {
                var asyncMethod = retVal as ISymUnmanagedAsyncMethod;
                retVal = asyncMethod == null
                    ? (ISymUnmanagedMethod) new SymMethod(this, retVal)
                    : new SymAsyncMethod(this, asyncMethod);
            }
            return(hr);
        }
Ejemplo n.º 32
0
        public ISymbolMethod[] GetMethodsFromDocumentPosition(ISymbolDocument document, int line, int column)
        {
            ISymUnmanagedMethod[] unmanagedMethods;
            ISymbolMethod[]       methods;
            int  count;
            uint i;

            unmanagedReader.GetMethodsFromDocumentPosition(((SymbolDocument)document).InternalDocument, line, column, 0, out count, null);
            unmanagedMethods = new ISymUnmanagedMethod[count];
            unmanagedReader.GetMethodsFromDocumentPosition(((SymbolDocument)document).InternalDocument, line, column, count, out count, unmanagedMethods);
            methods = new ISymbolMethod[count];

            for (i = 0; i < count; i++)
            {
                methods[i] = new SymbolMethod(unmanagedMethods[i]);
            }
            return(methods);
        }
Ejemplo n.º 33
0
        internal static ISymUnmanagedMethod GetBaselineMethod(this ISymUnmanagedReader reader, int methodToken)
        {
            ISymUnmanagedMethod method = null;
            int hr = reader.GetMethodByVersion(methodToken, 1, out method);

            if (hr == E_FAIL)
            {
                // method has no symbol info
                return(null);
            }
            else if (hr != 0)
            {
                throw new ArgumentException(string.Format("Invalid method token '0x{0:x8}' (hresult = 0x{1:x8})", methodToken, hr), "methodToken");
            }

            Debug.Assert(method != null);
            return(method);
        }
Ejemplo n.º 34
0
            public Builder(string[][] importStringGroups = null, bool suppressUsingInfo = false, ISymUnmanagedConstant[] constants = null)
            {
                _bytesBuilder = ArrayBuilder <byte> .GetInstance();

                if (importStringGroups != null && !suppressUsingInfo)
                {
                    var groupSizes = importStringGroups.Select(g => (short)g.Length).ToArray();
                    AddUsingInfo(groupSizes);
                }

                var namespaces = importStringGroups == null
                    ? default(ImmutableArray <ISymUnmanagedNamespace>)
                    : importStringGroups.SelectMany(names => names.Select(name => (ISymUnmanagedNamespace) new MockSymUnmanagedNamespace(name))).ToImmutableArray();
                var childScope = new MockSymUnmanagedScope(default(ImmutableArray <ISymUnmanagedScope>), namespaces, constants);
                var rootScope  = new MockSymUnmanagedScope(ImmutableArray.Create <ISymUnmanagedScope>(childScope), default(ImmutableArray <ISymUnmanagedNamespace>));

                _method = new MockSymUnmanagedMethod(rootScope);
            }
Ejemplo n.º 35
0
        // Write the sequence points for the given method
        // Sequence points are the map between IL offsets and source lines.
        // A single method could span multiple files (use C#'s #line directive to see for yourself).
        private void WriteSequencePoints(ISymUnmanagedMethod method)
        {
            writer.WriteStartElement("sequencePoints");

            var sequencePoints = method.GetSequencePoints();

            // Write out sequence points
            foreach (var sequencePoint in sequencePoints)
            {
                writer.WriteStartElement("entry");
                writer.WriteAttributeString("offset", AsILOffset(sequencePoint.Offset));

                // If it's a special 0xFeeFee sequence point (eg, "hidden"),
                // place an attribute on it to make it very easy for tools to recognize.
                // See http://blogs.msdn.com/jmstall/archive/2005/06/19/FeeFee_SequencePoints.aspx
                if (sequencePoint.IsHidden)
                {
                    if (sequencePoint.StartLine != sequencePoint.EndLine || sequencePoint.StartColumn != 0 || sequencePoint.EndColumn != 0)
                    {
                        writer.WriteAttributeString("hidden", "invalid");
                    }
                    else
                    {
                        writer.WriteAttributeString("hidden", XmlConvert.ToString(true));
                    }
                }
                else
                {
                    writer.WriteAttributeString("startLine", CultureInvariantToString(sequencePoint.StartLine));
                    writer.WriteAttributeString("startColumn", CultureInvariantToString(sequencePoint.StartColumn));
                    writer.WriteAttributeString("endLine", CultureInvariantToString(sequencePoint.EndLine));
                    writer.WriteAttributeString("endColumn", CultureInvariantToString(sequencePoint.EndColumn));
                }

                //EDMAURER allow there to be PDBs generated for sources that don't have a name (document).
                int fileRefVal = -1;
                this.m_fileMapping.TryGetValue(sequencePoint.Document.GetName(), out fileRefVal);
                writer.WriteAttributeString("document", CultureInvariantToString(fileRefVal));

                writer.WriteEndElement();
            }

            writer.WriteEndElement(); // sequencepoints
        }
Ejemplo n.º 36
0
        private int[] GetMethodTokensFromDocumentPosition(
            ISymUnmanagedReader symReader,
            ISymUnmanagedDocument symDocument,
            int zeroBasedLine,
            int zeroBasedColumn)
        {
            int count;
            Assert.Equal(HResult.S_OK, symReader.GetMethodsFromDocumentPosition(symDocument, zeroBasedLine, zeroBasedColumn, 0, out count, null));

            var methods = new ISymUnmanagedMethod[count];
            int count2;
            Assert.Equal(HResult.S_OK, symReader.GetMethodsFromDocumentPosition(symDocument, zeroBasedLine, zeroBasedColumn, count, out count2, methods));
            Assert.Equal(count, count2);

            return methods.Select(m =>
            {
                int token;
                Assert.Equal(HResult.S_OK, m.GetToken(out token));
                return token;
            }).ToArray();
        }
Ejemplo n.º 37
0
 public MethodDebugInfoBytes(ImmutableArray<byte> bytes, ISymUnmanagedMethod method)
 {
     this.Bytes = bytes;
     this.Method = method;
 }
 public int GetMethodVersion(ISymUnmanagedMethod pMethod, out int version)
 {
     version = 0;
     return SymUnmanagedReaderExtensions.E_NOTIMPL;
 }
 internal MethodSymbols(RuntimeFunction function, ISymUnmanagedMethod symMethod)
 {
     Function = function;
     SymMethod = symMethod;
 }
Ejemplo n.º 40
0
 internal void RecordSequencePoints(ISymUnmanagedMethod methodInfo)
 {
     if(methodInfo == null || this.contextForOffset != null)
         return;
     this.contextForOffset = new TrivialHashtable();
     uint count = methodInfo.GetSequencePointCount();
     IntPtr[] docPtrs = new IntPtr[count];
     uint[] startLines = new uint[count];
     uint[] startCols = new uint[count];
     uint[] endLines = new uint[count];
     uint[] endCols = new uint[count];
     uint[] offsets = new uint[count];
     uint numPoints;
     methodInfo.GetSequencePoints(count, out numPoints, offsets, docPtrs, startLines, startCols, endLines, endCols);
     Debug.Assert(count == numPoints);
     for(int i = 0; i < count; i++)
     {
         //The magic hex constant below works around weird data reported from GetSequencePoints.
         //The constant comes from ILDASM's source code, which performs essentially the same test.
         const uint Magic = 0xFEEFEE;
         if(startLines[i] >= Magic || endLines[i] >= Magic)
             continue;
         UnmanagedDocument doc = new UnmanagedDocument(docPtrs[i]);
         this.contextForOffset[(int)offsets[i] + 1] = new SourceContext(doc,
             doc.GetOffset(startLines[i], startCols[i]), doc.GetOffset(endLines[i], endCols[i]));
     }
     for(int i = 0; i < count; i++)
         System.Runtime.InteropServices.Marshal.Release(docPtrs[i]);
 }
Ejemplo n.º 41
0
 internal SymbolMethod(ISymUnmanagedMethod unMeth)
 {
     private_method = unMeth;
 }
		public static int GetMethodVersion(this CorSymReader_SxSClass instance, ISymUnmanagedMethod pMethod)
		{
			int version;
			instance.__GetMethodVersion(pMethod, out version);
			return version;
		}
Ejemplo n.º 43
0
        private static ISymUnmanagedMethod[] GetMethodsInDocument(ISymUnmanagedReader2 symReader, ISymUnmanagedDocument symDocument)
        {
            int count;
            symReader.GetMethodsInDocument(symDocument, 0, out count, null);

            var result = new ISymUnmanagedMethod[count];
            symReader.GetMethodsInDocument(symDocument, count, out count, result);

            return result;
        }
 public int GetMethodFromDocumentPosition(ISymUnmanagedDocument document, int line, int column, out ISymUnmanagedMethod retVal)
 {
     retVal = null;
     return SymUnmanagedReaderExtensions.E_NOTIMPL;
 }
Ejemplo n.º 45
0
        internal static int[] GetMethodTokensFromDocumentPosition(
            ISymUnmanagedReader symReader,
            ISymUnmanagedDocument symDocument,
            int line,
            int column)
        {
            Assert.True(line >= 1);
            Assert.True(column >= 0);

            int count;
            Assert.Equal(HResult.S_OK, symReader.GetMethodsFromDocumentPosition(symDocument, line, column, 0, out count, null));

            var methods = new ISymUnmanagedMethod[count];
            int count2;
            Assert.Equal(HResult.S_OK, symReader.GetMethodsFromDocumentPosition(symDocument, line, column, count, out count2, methods));
            Assert.Equal(count, count2);

            return methods.Select(m =>
            {
                int token;
                Assert.Equal(HResult.S_OK, m.GetToken(out token));
                return token;
            }).ToArray();
        }
Ejemplo n.º 46
0
 public int GetMethod(SymbolToken methodToken, out ISymUnmanagedMethod retVal)
 {
     // The EE should never be calling ISymUnmanagedReader.GetMethod.  In order to account
     // for EnC updates, it should always be calling GetMethodByVersion instead.
     throw ExceptionUtilities.Unreachable;
 }
 public int GetMethodsInDocument(ISymUnmanagedDocument document, int cMethod, out int pcMethod, ISymUnmanagedMethod[] methods)
 {
     pcMethod = 0;
     return SymUnmanagedReaderExtensions.E_NOTIMPL;
 }
Ejemplo n.º 48
0
 public int GetMethodFromDocumentPosition(ISymUnmanagedDocument document, int line, int column, out ISymUnmanagedMethod retVal)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 49
0
		public SymbolMethod(ISymUnmanagedMethod method) {
			this.method = method;
		}
Ejemplo n.º 50
0
        public ISymbolMethod[] GetMethodsFromDocumentPosition(
				ISymbolDocument document, int line, int column)
        {
            ISymUnmanagedMethod[] unmanagedMethods;
            ISymbolMethod[] methods;
            int count = 0;
            uint i;
            m_reader.GetMethodsFromDocumentPosition(((SymbolDocument)document).InternalDocument, line, column, 0, out count, null);
            unmanagedMethods = new ISymUnmanagedMethod[count];
            m_reader.GetMethodsFromDocumentPosition(((SymbolDocument)document).InternalDocument, line, column, count, out count, unmanagedMethods);
            methods = new ISymbolMethod[count];

            for (i = 0; i < count; i++)
            {
                methods[i] = new SymMethod(unmanagedMethods[i]);
            }
            return methods;
        }
Ejemplo n.º 51
0
 public int GetMethodsFromDocumentPosition(ISymUnmanagedDocument document, int line, int column, int cMethod, out int pcMethod, ISymUnmanagedMethod[] pRetVal)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 52
0
 public int GetMethodVersion(ISymUnmanagedMethod pMethod, out int version)
 {
     throw new NotImplementedException();
 }
 public int GetMethodsFromDocumentPosition(ISymUnmanagedDocument document, int line, int column, int cMethod, out int pcMethod, ISymUnmanagedMethod[] pRetVal)
 {
     pcMethod = 0;
     return SymUnmanagedReaderExtensions.E_NOTIMPL;
 }
Ejemplo n.º 54
0
 public int GetMethod(out ISymUnmanagedMethod pRetVal)
 {
     throw new NotImplementedException();
 }
 public SymMethod(ISymUnmanagedMethod unmanagedMethod)
 {
     m_unmanagedMethod = unmanagedMethod;
 }
Ejemplo n.º 56
0
 internal SymMethod(SymReader reader, ISymUnmanagedMethod method)
 {
     _reader = reader;
     _method = method;
 }
Ejemplo n.º 57
0
 // Write all the locals in the given method out to an XML file.
 // Since the symbol store represents the locals in a recursive scope structure, we need to walk a tree.
 // Although the locals are technically a hierarchy (based off nested scopes), it's easiest for clients
 // if we present them as a linear list. We will provide the range for each local's scope so that somebody
 // could reconstruct an approximation of the scope tree. The reconstruction may not be exact.
 // (Note this would still break down if you had an empty scope nested in another scope.
 private void WriteLocals(ISymUnmanagedMethod method, Dictionary<int, ImmutableArray<string>> slotNames)
 {
     writer.WriteStartElement("locals");
     {
         // If there are no locals, then this element will just be empty.
         WriteLocalsHelper(method.GetRootScope(), slotNames, includeChildScopes: true);
     }
     writer.WriteEndElement();
 }
Ejemplo n.º 58
0
 public int GetMethodVersion(ISymUnmanagedMethod method, out int version)
 {
     version = _version;
     return HResult.S_OK;
 }
Ejemplo n.º 59
0
	}; // class SequencePointComparer

	// Constructors.
	public unsafe SymMethod(ISymUnmanagedMethod *pMethod)
			{
				this.pMethod = pMethod;
			}
		public static int GetMethodVersion(this ISymUnmanagedReader instance, ISymUnmanagedMethod pMethod)
		{
			int version;
			instance.__GetMethodVersion(pMethod, out version);
			return version;
		}