Пример #1
0
        private static void GetSourceLineInfoInner(List <DbiModuleInfo> modules, MsfDirectory dir, PageAwarePdbReader reader, Dictionary <int, string> names, uint token, uint iloffset, out string sourceFile, out int sourceLine, out int sourceColumn)
        {
            sourceFile   = null;
            sourceLine   = 0;
            sourceColumn = 0;

            for (int m = 0; m < modules.Count; ++m)
            {
                var module = modules[m];
                if (module.stream > 0)
                {
                    byte[] bits = default;
                    try
                    {
                        var stream = dir.Streams[module.stream];
                        bits = ArrayPool <byte> .Shared.Rent(stream.Length);

                        stream.Read(reader, bits);

                        if (TryGetManProcSym(bits, ref module, token, out ManProcSym sym))
                        {
                            GetLineNumberInformation(bits, ref module, sym.off + iloffset, names, out sourceFile, out sourceLine, out sourceColumn);
                        }
                    }
                    finally
                    {
                        if (bits != null)
                        {
                            ArrayPool <byte> .Shared.Return(bits);
                        }
                    }
                }
            }
        }
Пример #2
0
        // @@BPerfIgnoreAllocation@@ -- directoryRoot (not poolable due to MemoryMarshal), pageAwarePdbReader (elidable per escape analysis), msf (elidable per future escape analysis), nameIndexStreamData (poolable), namesStreamData (poolable), dbiStreamData (poolable)
        private static bool GetSourceLineInfo(Stream fs, uint token, uint iloffset, out int age, out Guid guid, out string sourceFile, out int sourceLine, out int sourceColumn)
        {
            if (ReadPdbHeader(fs, out var pageSize, out var freePageMap, out var pagesUsed, out var directorySize, out var zero))
            {
                int directoryPages = ((directorySize + pageSize - 1) / pageSize * 4 + pageSize - 1) / pageSize;

                var directoryRoot = new int[directoryPages];
                fs.Read(MemoryMarshal.Cast <int, byte>(directoryRoot));

                var pageAwarePdbReader = new PageAwarePdbReader(fs, pageSize);
                var msf = new MsfDirectory(pageAwarePdbReader, pageSize, directorySize, directoryRoot);

                var nameIndexStream     = msf.Streams[1];
                var nameIndexStreamData = new byte[nameIndexStream.Length];
                nameIndexStream.Read(pageAwarePdbReader, nameIndexStreamData);

                var nameIndex = LoadNameIndex(nameIndexStreamData, out age, out guid);
                if (nameIndex.TryGetValue("/NAMES", out var namesStreamIndex))
                {
                    var namesStream     = msf.Streams[namesStreamIndex];
                    var namesStreamData = new byte[namesStream.Length];
                    namesStream.Read(pageAwarePdbReader, namesStreamData);

                    var names = LoadNameStream(namesStreamData);

                    var dbiStream     = msf.Streams[3];
                    var dbiStreamData = new byte[dbiStream.Length];
                    dbiStream.Read(pageAwarePdbReader, dbiStreamData);

                    var modules = LoadModules(dbiStreamData, out DbiDbgHdr header);
                    GetSourceLineInfoInner(modules, msf, pageAwarePdbReader, names, token, iloffset, out sourceFile, out sourceLine, out sourceColumn);

                    return(true);
                }
            }

            age          = 0;
            guid         = Guid.Empty;
            sourceFile   = null;
            sourceLine   = 0;
            sourceColumn = 0;

            return(false);
        }
Пример #3
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);
                    }
                }
            }
        }