コード例 #1
0
        private static void GetSourceLineInfoInner(IReadOnlyList <DbiModuleInfo> modules, MsfDirectory dir, PdbReader reader, IReadOnlyDictionary <int, string> names, uint token, uint iloffset, out string sourceFile, out int sourceLine, out int sourceColumn)
        {
            sourceFile   = string.Empty;
            sourceLine   = 0;
            sourceColumn = 0;

            foreach (DbiModuleInfo module in modules)
            {
                if (module.stream > 0)
                {
                    DataStream stream = dir.Streams[module.stream];

                    using var bitsPool = new SafeArrayPool <byte>(stream.Length);
                    byte[] bits = bitsPool.Array;
                    stream.Read(reader, bits);

                    if (TryGetManProcSym(bits, in module, token, out ManProcSym sym))
                    {
                        GetLineNumberInformation(bits, in module, sym.off + iloffset, names, out sourceFile, out sourceLine, out sourceColumn);
                    }
                }
            }
        }
コード例 #2
0
        public MsfDirectory(PdbReader reader, int pageSize, int directorySize, int[] directoryRoot)
        {
            var numPages = reader.PagesFromSize(directorySize);

            var         pages = new int[numPages];
            Span <byte> buf   = MemoryMarshal.Cast <int, byte>(pages);

            var offset       = 0;
            var pagesPerPage = pageSize / 4;
            var pagesToGo    = numPages;

            foreach (var t in directoryRoot)
            {
                var pagesInThisPage = pagesToGo <= pagesPerPage ? pagesToGo : pagesPerPage;
                reader.Seek(t, 0);
                reader.Stream.Read(buf.Slice(offset, pagesInThisPage * 4));
                pagesToGo -= pagesInThisPage;
            }

            using var buffer = new SafeArrayPool <byte>(directorySize);
            var stream = new DataStream(directorySize, pages);

            stream.Read(reader, buffer.Array);

            offset = 0;
            var count = InterpretInt32(buffer.Array, ref offset);

            using var sizesPool = new SafeArrayPool <int>(count);
            int[] sizes = sizesPool.Array;

            for (var i = 0; i < count; ++i)
            {
                sizes[i] = InterpretInt32(buffer.Array, ref offset);
            }

            this.streams = new DataStream[count];

            for (var i = 0; i < count; ++i)
            {
                if (sizes[i] <= 0)
                {
                    this.streams[i] = new DataStream();
                }
                else
                {
                    var dsPagesCount = reader.PagesFromSize(sizes[i]);
                    if (dsPagesCount > 0)
                    {
                        var dsPages = new int[dsPagesCount];

                        for (var j = 0; j < dsPagesCount; ++j)
                        {
                            dsPages[j] = InterpretInt32(buffer.Array, ref offset);
                        }

                        this.streams[i] = new DataStream(sizes[i], dsPages);
                    }
                    else
                    {
                        this.streams[i] = new DataStream(sizes[i], Array.Empty <int>());
                    }
                }
            }
        }