/// <summary> /// Gets methods(described by metadata token) sequence points from <c>ISymUnmanagedReader</c>. /// </summary> /// <param name="reader">Reader for getting debugging symbols.</param> /// <param name="mToken">Metadata token of the method.</param> /// <returns><c>List</c> of SequencePoint.</returns> public static List <SequencePoint> GetMethodSequencePoints(ISymUnmanagedReader reader, uint mToken) { ISymUnmanagedMethod pMethod = reader.__GetMethod(mToken); uint seqCount = pMethod.__GetSequencePointCount(); uint[] lines = new uint[seqCount]; uint[] offsets = new uint[seqCount]; uint[] columns = new uint[seqCount]; uint[] endLines = new uint[seqCount]; uint[] endColumns = new uint[seqCount]; ISymUnmanagedDocument[] documents = new ISymUnmanagedDocument[seqCount]; ISymUnmanagedDocumentWriter[] docWriters = new ISymUnmanagedDocumentWriter[seqCount]; uint cCount; pMethod.__GetSequencePoints(seqCount, out cCount, offsets, documents, lines, columns, endLines, endColumns); List <SequencePoint> store = new List <SequencePoint>(); for (int i = 0; i < offsets.Length; i++) { SequencePoint point; point.Column = columns[i]; point.Offset = offsets[i]; point.Line = lines[i]; point.EndColumn = endColumns[i]; point.EndLine = endLines[i]; store.Add(point); } return(store); }
/// <summary> /// Creates symbols for method identified by <c>oldToken</c> by translating symbols /// from new version of method identified by <c>newToken</c>. /// </summary> /// <param name="newToken">Identifies new version of method.</param> /// <param name="oldToken">Identifies old version of method.</param> /// <param name="placeholder">Translation definition for local variables.</param> public List <SequencePoint> EmitMethod(uint oldToken, uint newToken, Dictionary <int, int> placeholder = null) { if (State != WriterState.Building) { throw new TranslatingException("ISym* interfaces were not initializde. (EnC)"); } int bla = ((IMetaDataImport)manager.MetadataManager.OldEmitter.CorMetaDataEmit).IsValidToken(oldToken); ISymUnmanagedMethod smMethod = mReader.__GetMethod(newToken); mWriter.__OpenMethod(oldToken); uint seqCount = smMethod.__GetSequencePointCount(); uint[] lines = new uint[seqCount]; uint[] offsets = new uint[seqCount]; uint[] columns = new uint[seqCount]; uint[] endLines = new uint[seqCount]; uint[] endColumns = new uint[seqCount]; ISymUnmanagedDocument[] documents = new ISymUnmanagedDocument[seqCount]; ISymUnmanagedDocumentWriter[] docWriters = new ISymUnmanagedDocumentWriter[seqCount]; uint cCount; smMethod.__GetSequencePoints(seqCount, out cCount, offsets, documents, lines, columns, endLines, endColumns); for (int i = 0; i < seqCount; i++) { docWriters[i] = DefineDocument(documents[i]); mWriter.__DefineSequencePoints(docWriters[i], 1, ref offsets[i], ref lines[i], ref columns[i], ref endLines[i], ref endColumns[i]); } mWriter.__SetMethodSourceRange(docWriters[0], lines[0], columns[0], docWriters[seqCount - 1], endLines[seqCount - 1], endColumns[seqCount - 1]); EmitScope(smMethod.__GetRootScope(), placeholder); // try{ mWriter.__CloseMethod(); } catch (COMException) { } return(SequencePoint.StoreSequencePoints(offsets, lines, columns, endLines, endColumns)); }
public static void GetSequencePoints(this ISymUnmanagedMethod instance, uint cPoints, out uint pcPoints, uint[] offsets, ISymUnmanagedDocument[] documents, uint[] lines, uint[] columns, uint[] endLines, uint[] endColumns) { instance.__GetSequencePoints(cPoints, out pcPoints, offsets, documents, lines, columns, endLines, endColumns); ProcessOutParameter(documents); }