Exemple #1
0
        internal static ImmutableArray <SymUnmanagedSequencePoint> GetSequencePoints(this ISymUnmanagedMethod method)
        {
            // NB: method.GetSequencePoints(0, out numAvailable, ...) always returns 0.
            int numAvailable;
            int hr = method.GetSequencePointCount(out numAvailable);

            SymUnmanagedReaderExtensions.ThrowExceptionForHR(hr);
            if (numAvailable == 0)
            {
                return(ImmutableArray <SymUnmanagedSequencePoint> .Empty);
            }

            int[] offsets = new int[numAvailable];
            ISymUnmanagedDocument[] documents = new ISymUnmanagedDocument[numAvailable];
            int[] startLines   = new int[numAvailable];
            int[] startColumns = new int[numAvailable];
            int[] endLines     = new int[numAvailable];
            int[] endColumns   = new int[numAvailable];

            int numRead;

            hr = method.GetSequencePoints(numAvailable, out numRead, offsets, documents, startLines, startColumns, endLines, endColumns);
            SymUnmanagedReaderExtensions.ThrowExceptionForHR(hr);
            if (numRead != numAvailable)
            {
                throw new InvalidOperationException($"Read only {numRead} of {numAvailable} sequence points.");
            }

            var builder = ImmutableArray.CreateBuilder <SymUnmanagedSequencePoint>(numRead);

            for (int i = 0; i < numRead; i++)
            {
                builder.Add(new SymUnmanagedSequencePoint(
                                offsets[i],
                                documents[i],
                                startLines[i],
                                startColumns[i],
                                endLines[i],
                                endColumns[i]));
            }

            return(builder.ToImmutable());
        }
Exemple #2
0
 private static ISymUnmanagedReader3 CreateNativeSymReader(Stream pdbStream)
 {
     try
     {
         object symReader = null;
         var    guid      = default(Guid);
         if (IntPtr.Size == 4)
         {
             CreateSymReader32(ref guid, out symReader);
         }
         else
         {
             CreateSymReader64(ref guid, out symReader);
         }
         var reader = (ISymUnmanagedReader3)symReader;
         var hr     = reader.Initialize(new DummyMetadataImport(), null, null, new ComStreamWrapper(pdbStream));
         SymUnmanagedReaderExtensions.ThrowExceptionForHR(hr);
         return(reader);
     }
     catch (Exception e)
     {
         throw new IOException(e.Message, e);
     }
 }