Ejemplo n.º 1
0
        internal void Read(PdbStreamHelper reader, int position,
                           byte[] bytes, int offset, int data)
        {
            if (position + data > _contentSize)
            {
                throw new PdbException("DataStream can't read off end of stream. " +
                                       "(pos={0},siz={1})",
                                       position, data);
            }
            if (position == _contentSize)
            {
                return;
            }

            int left = data;
            int page = position / reader.PageSize;
            int rema = position % reader.PageSize;

            // First get remained of first page.
            if (rema != 0)
            {
                int todo = reader.PageSize - rema;
                if (todo > left)
                {
                    todo = left;
                }

                reader.Seek(_pages[page], rema);
                reader.Read(bytes, offset, todo);

                offset += todo;
                left   -= todo;
                page++;
            }

            // Now get the remaining pages.
            while (left > 0)
            {
                int todo = reader.PageSize;
                if (todo > left)
                {
                    todo = left;
                }

                reader.Seek(_pages[page], 0);
                reader.Read(bytes, offset, todo);

                offset += todo;
                left   -= todo;
                page++;
            }
        }
Ejemplo n.º 2
0
        internal void Read(PdbStreamHelper reader, int position,
                         byte[] bytes, int offset, int data)
        {
            if (position + data > _contentSize)
            {
                throw new PdbException("DataStream can't read off end of stream. " +
                                               "(pos={0},siz={1})",
                                       position, data);
            }
            if (position == _contentSize)
            {
                return;
            }

            int left = data;
            int page = position / reader.PageSize;
            int rema = position % reader.PageSize;

            // First get remained of first page.
            if (rema != 0)
            {
                int todo = reader.PageSize - rema;
                if (todo > left)
                {
                    todo = left;
                }

                reader.Seek(_pages[page], rema);
                reader.Read(bytes, offset, todo);

                offset += todo;
                left -= todo;
                page++;
            }

            // Now get the remaining pages.
            while (left > 0)
            {
                int todo = reader.PageSize;
                if (todo > left)
                {
                    todo = left;
                }

                reader.Seek(_pages[page], 0);
                reader.Read(bytes, offset, todo);

                offset += todo;
                left -= todo;
                page++;
            }
        }
Ejemplo n.º 3
0
        internal MsfDirectory(PdbStreamHelper reader, PdbFileHeader head, BitAccess bits)
        {
            int pages = reader.PagesFromSize(head.DirectorySize);

            // 0..n in page of directory pages.
            bits.MinCapacity(head.DirectorySize);
            int directoryRootPages = head.DirectoryRoot.Length;
            int pagesPerPage       = head.PageSize / 4;
            int pagesToGo          = pages;

            for (int i = 0; i < directoryRootPages; i++)
            {
                int pagesInThisPage = pagesToGo <= pagesPerPage ? pagesToGo : pagesPerPage;
                reader.Seek(head.DirectoryRoot[i], 0);
                bits.Append(reader.Reader, pagesInThisPage * 4);
                pagesToGo -= pagesInThisPage;
            }
            bits.Position = 0;

            DataStream stream = new DataStream(head.DirectorySize, bits, pages);

            bits.MinCapacity(head.DirectorySize);
            stream.Read(reader, bits);

            // 0..3 in directory pages
            int count;

            bits.ReadInt32(out count);

            // 4..n
            int[] sizes = new int[count];
            bits.ReadInt32(sizes);

            // n..m
            _streams = new DataStream[count];
            for (int i = 0; i < count; i++)
            {
                if (sizes[i] <= 0)
                {
                    _streams[i] = new DataStream();
                }
                else
                {
                    _streams[i] = new DataStream(sizes[i], bits,
                                                 reader.PagesFromSize(sizes[i]));
                }
            }
        }
Ejemplo n.º 4
0
        private static void LoadFuncsFromDbiModule(
            BitAccess bits,
            DbiModuleInfo info,
            Dictionary <int, string> names,
            List <PdbFunction> funcList,
            bool readStrings,
            MsfDirectory dir,
            Dictionary <string, int> nameIndex,
            PdbStreamHelper reader,
            Dictionary <string, PdbSource> sources)
        {
            PdbFunction[] funcs = null;
            bits.Position = 0;
            int sig;

            bits.ReadInt32(out sig);
            if (sig != 4)
            {
                throw new PdbDebugException("Invalid signature. (sig={0})", sig);
            }

            bits.Position = 4;
            // Console.WriteLine("{0}:", info.moduleName);
            funcs = PdbFunction.LoadManagedFunctions( /*info.moduleName,*/
                bits,
                (uint)info.cbSyms,
                readStrings);
            if (funcs != null)
            {
                bits.Position = info.cbSyms + info.cbOldLines;
                LoadManagedLines(
                    funcs,
                    names,
                    bits,
                    dir,
                    nameIndex,
                    reader,
                    (uint)(info.cbSyms + info.cbOldLines + info.cbLines),
                    sources);

                for (int i = 0; i < funcs.Length; i++)
                {
                    funcList.Add(funcs[i]);
                }
            }
        }
Ejemplo n.º 5
0
        internal MsfDirectory(PdbStreamHelper reader, PdbFileHeader head, BitAccess bits)
        {
            int pages = reader.PagesFromSize(head.DirectorySize);

            // 0..n in page of directory pages.
            bits.MinCapacity(head.DirectorySize);
            int directoryRootPages = head.DirectoryRoot.Length;
            int pagesPerPage = head.PageSize / 4;
            int pagesToGo = pages;
            for (int i = 0; i < directoryRootPages; i++)
            {
                int pagesInThisPage = pagesToGo <= pagesPerPage ? pagesToGo : pagesPerPage;
                reader.Seek(head.DirectoryRoot[i], 0);
                bits.Append(reader.Reader, pagesInThisPage * 4);
                pagesToGo -= pagesInThisPage;
            }
            bits.Position = 0;

            DataStream stream = new DataStream(head.DirectorySize, bits, pages);
            bits.MinCapacity(head.DirectorySize);
            stream.Read(reader, bits);

            // 0..3 in directory pages
            int count;
            bits.ReadInt32(out count);

            // 4..n
            int[] sizes = new int[count];
            bits.ReadInt32(sizes);

            // n..m
            _streams = new DataStream[count];
            for (int i = 0; i < count; i++)
            {
                if (sizes[i] <= 0)
                {
                    _streams[i] = new DataStream();
                }
                else
                {
                    _streams[i] = new DataStream(sizes[i], bits,
                                                reader.PagesFromSize(sizes[i]));
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets the properties of a given pdb.  Throws IOException on error.
        /// </summary>
        /// <param name="pdbFile">The pdb file to load.</param>
        /// <param name="signature">The signature of pdbFile.</param>
        /// <param name="age">The age of pdbFile.</param>
        public static void GetPdbProperties(string pdbFile, out Guid signature, out int age)
        {
            BitAccess bits = new BitAccess(512 * 1024);
            using (FileStream pdbStream = File.OpenRead(pdbFile))
            {
                PdbFileHeader header = new PdbFileHeader(pdbStream, bits);
                PdbStreamHelper reader = new PdbStreamHelper(pdbStream, header.PageSize);
                MsfDirectory dir = new MsfDirectory(reader, header, bits);

                dir._streams[1].Read(reader, bits);

                int ver, sig;
                bits.ReadInt32(out ver);    //  0..3  Version
                bits.ReadInt32(out sig);    //  4..7  Signature
                bits.ReadInt32(out age);    //  8..11 Age
                bits.ReadGuid(out signature);       // 12..27 GUID
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets the properties of a given pdb.  Throws IOException on error.
        /// </summary>
        /// <param name="pdbFile">The pdb file to load.</param>
        /// <param name="signature">The signature of pdbFile.</param>
        /// <param name="age">The age of pdbFile.</param>
        public static void GetPdbProperties(string pdbFile, out Guid signature, out int age)
        {
            BitAccess bits = new BitAccess(512 * 1024);

            using (FileStream pdbStream = File.OpenRead(pdbFile))
            {
                PdbFileHeader   header = new PdbFileHeader(pdbStream, bits);
                PdbStreamHelper reader = new PdbStreamHelper(pdbStream, header.PageSize);
                MsfDirectory    dir    = new MsfDirectory(reader, header, bits);

                dir._streams[1].Read(reader, bits);

                int ver, sig;
                bits.ReadInt32(out ver);      //  0..3  Version
                bits.ReadInt32(out sig);      //  4..7  Signature
                bits.ReadInt32(out age);      //  8..11 Age
                bits.ReadGuid(out signature); // 12..27 GUID
            }
        }
Ejemplo n.º 8
0
        internal static PdbFunction[] LoadFunctions(
            Stream read,
            BitAccess bits,
            bool readAllStrings,
            out int ver,
            out int sig,
            out int age,
            out Guid guid,
            out IEnumerable <PdbSource> sources)
        {
            sources = null;
            PdbFileHeader   head   = new PdbFileHeader(read, bits);
            PdbStreamHelper reader = new PdbStreamHelper(read, head.PageSize);
            MsfDirectory    dir    = new MsfDirectory(reader, head, bits);

            DbiModuleInfo[] modules = null;
            DbiDbgHdr       header;

            dir._streams[1].Read(reader, bits);
            Dictionary <string, int> nameIndex = LoadNameIndex(bits, out ver, out sig, out age, out guid);
            int nameStream;

            if (!nameIndex.TryGetValue("/NAMES", out nameStream))
            {
                throw new PdbException("No `name' stream");
            }

            dir._streams[nameStream].Read(reader, bits);
            Dictionary <int, string> names = LoadNameStream(bits);

            dir._streams[3].Read(reader, bits);
            LoadDbiStream(bits, out modules, out header, readAllStrings);

            List <PdbFunction>             funcList         = new List <PdbFunction>();
            Dictionary <string, PdbSource> sourceDictionary = new Dictionary <string, PdbSource>();

            if (modules != null)
            {
                for (int m = 0; m < modules.Length; m++)
                {
                    if (modules[m].stream > 0)
                    {
                        dir._streams[modules[m].stream].Read(reader, bits);
                        LoadFuncsFromDbiModule(
                            bits,
                            modules[m],
                            names,
                            funcList,
                            readAllStrings,
                            dir,
                            nameIndex,
                            reader,
                            sourceDictionary);
                    }
                }
            }

            PdbFunction[] funcs = funcList.ToArray();
            sources = sourceDictionary.Values;

            // After reading the functions, apply the token remapping table if it exists.
            if (header.snTokenRidMap != 0 && header.snTokenRidMap != 0xffff)
            {
                dir._streams[header.snTokenRidMap].Read(reader, bits);
                uint[] ridMap = new uint[dir._streams[header.snTokenRidMap].Length / 4];
                bits.ReadUInt32(ridMap);

                foreach (PdbFunction func in funcs)
                {
                    func.Token = 0x06000000 | ridMap[func.Token & 0xffffff];
                }
            }

            //
            Array.Sort(funcs, PdbFunction.byAddressAndToken);
            //Array.Sort(funcs, PdbFunction.byToken);
            return(funcs);
        }
Ejemplo n.º 9
0
        private static void LoadManagedLines(
            PdbFunction[] funcs,
            Dictionary <int, string> names,
            BitAccess bits,
            MsfDirectory dir,
            Dictionary <string, int> nameIndex,
            PdbStreamHelper reader,
            uint limit,
            Dictionary <string, PdbSource> sources)
        {
            Array.Sort(funcs, PdbFunction.byAddressAndToken);

            Dictionary <int, PdbSource> checks = new Dictionary <int, PdbSource>();

            // Read the files first
            int begin = bits.Position;

            while (bits.Position < limit)
            {
                int sig;
                int siz;
                bits.ReadInt32(out sig);
                bits.ReadInt32(out siz);
                int place  = bits.Position;
                int endSym = bits.Position + siz;

                switch ((DEBUG_S_SUBSECTION)sig)
                {
                case DEBUG_S_SUBSECTION.FILECHKSMS:
                    while (bits.Position < endSym)
                    {
                        CV_FileCheckSum chk;

                        int ni = bits.Position - place;
                        bits.ReadUInt32(out chk.name);
                        bits.ReadUInt8(out chk.len);
                        bits.ReadUInt8(out chk.type);

                        string    name = names[(int)chk.name];
                        PdbSource src;
                        if (!sources.TryGetValue(name.ToUpperInvariant(), out src))
                        {
                            int    guidStream;
                            Guid   doctypeGuid  = Guid.Empty;
                            Guid   languageGuid = Guid.Empty;
                            Guid   vendorGuid   = Guid.Empty;
                            Guid   algorithmId  = Guid.Empty;
                            byte[] checksum     = null;
                            byte[] source       = null;

                            if (nameIndex.TryGetValue("/SRC/FILES/" + name.ToUpperInvariant(), out guidStream))
                            {
                                BitAccess guidBits = new BitAccess(0x100);
                                dir._streams[guidStream].Read(reader, guidBits);
                                LoadGuidStream(guidBits, out doctypeGuid, out languageGuid, out vendorGuid, out algorithmId, out checksum, out source);
                            }

                            src = new PdbSource(/*(uint)ni,*/ name, doctypeGuid, languageGuid, vendorGuid, algorithmId, checksum, source);
                            sources.Add(name.ToUpperInvariant(), src);
                        }

                        checks.Add(ni, src);
                        bits.Position += chk.len;
                        bits.Align(4);
                    }

                    bits.Position = endSym;
                    break;

                default:
                    bits.Position = endSym;
                    break;
                }
            }

            // Read the lines next.
            bits.Position = begin;
            while (bits.Position < limit)
            {
                int sig;
                int siz;
                bits.ReadInt32(out sig);
                bits.ReadInt32(out siz);
                int endSym = bits.Position + siz;

                switch ((DEBUG_S_SUBSECTION)sig)
                {
                case DEBUG_S_SUBSECTION.LINES:
                {
                    CV_LineSection sec;

                    bits.ReadUInt32(out sec.off);
                    bits.ReadUInt16(out sec.sec);
                    bits.ReadUInt16(out sec.flags);
                    bits.ReadUInt32(out sec.cod);
                    int funcIndex = FindFunction(funcs, sec.sec, sec.off);
                    if (funcIndex < 0)
                    {
                        break;
                    }

                    PdbFunction func = funcs[funcIndex];
                    if (func.SequencePoints == null)
                    {
                        while (funcIndex > 0)
                        {
                            PdbFunction f = funcs[funcIndex - 1];
                            if (f.SequencePoints != null || f.Segment != sec.sec || f.Address != sec.off)
                            {
                                break;
                            }

                            func = f;
                            funcIndex--;
                        }
                    }
                    else
                    {
                        while (funcIndex < funcs.Length - 1 && func.SequencePoints != null)
                        {
                            PdbFunction f = funcs[funcIndex + 1];
                            if (f.Segment != sec.sec || f.Address != sec.off)
                            {
                                break;
                            }

                            func = f;
                            funcIndex++;
                        }
                    }

                    if (func.SequencePoints != null)
                    {
                        break;
                    }

                    // Count the line blocks.
                    int begSym = bits.Position;
                    int blocks = 0;
                    while (bits.Position < endSym)
                    {
                        CV_SourceFile file;
                        bits.ReadUInt32(out file.index);
                        bits.ReadUInt32(out file.count);
                        bits.ReadUInt32(out file.linsiz);     // Size of payload.
                        int linsiz = (int)file.count * (8 + ((sec.flags & 1) != 0 ? 4 : 0));
                        bits.Position += linsiz;
                        blocks++;
                    }

                    func.SequencePoints = new PdbSequencePointCollection[blocks];
                    int block = 0;

                    bits.Position = begSym;
                    while (bits.Position < endSym)
                    {
                        CV_SourceFile file;
                        bits.ReadUInt32(out file.index);
                        bits.ReadUInt32(out file.count);
                        bits.ReadUInt32(out file.linsiz);     // Size of payload.

                        PdbSource src = checks[(int)file.index];
                        PdbSequencePointCollection tmp = new PdbSequencePointCollection(src, file.count);
                        func.SequencePoints[block++] = tmp;
                        PdbSequencePoint[] lines = tmp.Lines;

                        int plin = bits.Position;
                        int pcol = bits.Position + 8 * (int)file.count;

                        for (int i = 0; i < file.count; i++)
                        {
                            CV_Line   line;
                            CV_Column column = new CV_Column();

                            bits.Position = plin + 8 * i;
                            bits.ReadUInt32(out line.offset);
                            bits.ReadUInt32(out line.flags);

                            uint lineBegin = line.flags & (uint)CV_Line_Flags.linenumStart;
                            uint delta     = (line.flags & (uint)CV_Line_Flags.deltaLineEnd) >> 24;
                            //bool statement = ((line.flags & (uint)CV_Line_Flags.fStatement) == 0);
                            if ((sec.flags & 1) != 0)
                            {
                                bits.Position = pcol + 4 * i;
                                bits.ReadUInt16(out column.offColumnStart);
                                bits.ReadUInt16(out column.offColumnEnd);
                            }

                            lines[i] = new PdbSequencePoint(
                                line.offset,
                                lineBegin,
                                column.offColumnStart,
                                lineBegin + delta,
                                column.offColumnEnd);
                        }
                    }

                    break;
                }
                }

                bits.Position = endSym;
            }
        }
Ejemplo n.º 10
0
        internal static PdbFunction[] LoadFunctions(Stream read,
                                                    BitAccess bits,
                                                    bool readAllStrings,
                                                    out int ver,
                                                    out int sig,
                                                    out int age,
                                                    out Guid guid,
                                                    out IEnumerable<PdbSource> sources)
        {
            sources = null;
            PdbFileHeader head = new PdbFileHeader(read, bits);
            PdbStreamHelper reader = new PdbStreamHelper(read, head.PageSize);
            MsfDirectory dir = new MsfDirectory(reader, head, bits);
            DbiModuleInfo[] modules = null;
            DbiDbgHdr header;

            dir._streams[1].Read(reader, bits);
            Dictionary<string, int> nameIndex = LoadNameIndex(bits, out ver, out sig, out age, out guid);
            int nameStream;
            if (!nameIndex.TryGetValue("/NAMES", out nameStream))
            {
                throw new PdbException("No `name' stream");
            }

            dir._streams[nameStream].Read(reader, bits);
            Dictionary<int, string> names = LoadNameStream(bits);

            dir._streams[3].Read(reader, bits);
            LoadDbiStream(bits, out modules, out header, readAllStrings);

            List<PdbFunction> funcList = new List<PdbFunction>();
            Dictionary<string, PdbSource> sourceDictionary = new Dictionary<string, PdbSource>();
            if (modules != null)
            {
                for (int m = 0; m < modules.Length; m++)
                {
                    if (modules[m].stream > 0)
                    {
                        dir._streams[modules[m].stream].Read(reader, bits);
                        LoadFuncsFromDbiModule(bits, modules[m], names, funcList,
                                               readAllStrings, dir, nameIndex, reader, sourceDictionary);
                    }
                }
            }

            PdbFunction[] funcs = funcList.ToArray();
            sources = sourceDictionary.Values;

            // After reading the functions, apply the token remapping table if it exists.
            if (header.snTokenRidMap != 0 && header.snTokenRidMap != 0xffff)
            {
                dir._streams[header.snTokenRidMap].Read(reader, bits);
                uint[] ridMap = new uint[dir._streams[header.snTokenRidMap].Length / 4];
                bits.ReadUInt32(ridMap);

                foreach (PdbFunction func in funcs)
                {
                    func.Token = 0x06000000 | ridMap[func.Token & 0xffffff];
                }
            }

            //
            Array.Sort(funcs, PdbFunction.byAddressAndToken);
            //Array.Sort(funcs, PdbFunction.byToken);
            return funcs;
        }
Ejemplo n.º 11
0
        private static void LoadFuncsFromDbiModule(BitAccess bits,
                                           DbiModuleInfo info,
                                           Dictionary<int, string> names,
                                           List<PdbFunction> funcList,
                                           bool readStrings,
                                           MsfDirectory dir,
                                           Dictionary<string, int> nameIndex,
                                           PdbStreamHelper reader,
                                           Dictionary<string, PdbSource> sources)
        {
            PdbFunction[] funcs = null;
            bits.Position = 0;
            int sig;
            bits.ReadInt32(out sig);
            if (sig != 4)
            {
                throw new PdbDebugException("Invalid signature. (sig={0})", sig);
            }

            bits.Position = 4;
            // Console.WriteLine("{0}:", info.moduleName);
            funcs = PdbFunction.LoadManagedFunctions(/*info.moduleName,*/
                                                     bits, (uint)info.cbSyms,
                                                     readStrings);
            if (funcs != null)
            {
                bits.Position = info.cbSyms + info.cbOldLines;
                LoadManagedLines(funcs, names, bits, dir, nameIndex, reader,
                                 (uint)(info.cbSyms + info.cbOldLines + info.cbLines), sources);

                for (int i = 0; i < funcs.Length; i++)
                {
                    funcList.Add(funcs[i]);
                }
            }
        }
Ejemplo n.º 12
0
        private static void LoadManagedLines(PdbFunction[] funcs,
                                     Dictionary<int, string> names,
                                     BitAccess bits,
                                     MsfDirectory dir,
                                     Dictionary<string, int> nameIndex,
                                     PdbStreamHelper reader,
                                     uint limit,
                                     Dictionary<string, PdbSource> sources)
        {
            Array.Sort(funcs, PdbFunction.byAddressAndToken);

            Dictionary<int, PdbSource> checks = new Dictionary<int, PdbSource>();

            // Read the files first
            int begin = bits.Position;
            while (bits.Position < limit)
            {
                int sig;
                int siz;
                bits.ReadInt32(out sig);
                bits.ReadInt32(out siz);
                int place = bits.Position;
                int endSym = bits.Position + siz;

                switch ((DEBUG_S_SUBSECTION)sig)
                {
                    case DEBUG_S_SUBSECTION.FILECHKSMS:
                        while (bits.Position < endSym)
                        {
                            CV_FileCheckSum chk;

                            int ni = bits.Position - place;
                            bits.ReadUInt32(out chk.name);
                            bits.ReadUInt8(out chk.len);
                            bits.ReadUInt8(out chk.type);

                            string name = names[(int)chk.name];
                            PdbSource src;
                            if (!sources.TryGetValue(name.ToUpperInvariant(), out src))
                            {
                                int guidStream;
                                Guid doctypeGuid = Guid.Empty;
                                Guid languageGuid = Guid.Empty;
                                Guid vendorGuid = Guid.Empty;
                                Guid algorithmId = Guid.Empty;
                                byte[] checksum = null;
                                byte[] source = null;

                                if (nameIndex.TryGetValue("/SRC/FILES/" + name.ToUpperInvariant(), out guidStream))
                                {
                                    var guidBits = new BitAccess(0x100);
                                    dir._streams[guidStream].Read(reader, guidBits);
                                    LoadGuidStream(guidBits, out doctypeGuid, out languageGuid, out vendorGuid, out algorithmId, out checksum, out source);
                                }

                                src = new PdbSource(/*(uint)ni,*/ name, doctypeGuid, languageGuid, vendorGuid, algorithmId, checksum, source);
                                sources.Add(name.ToUpperInvariant(), src);
                            }
                            checks.Add(ni, src);
                            bits.Position += chk.len;
                            bits.Align(4);
                        }
                        bits.Position = endSym;
                        break;

                    default:
                        bits.Position = endSym;
                        break;
                }
            }

            // Read the lines next.
            bits.Position = begin;
            while (bits.Position < limit)
            {
                int sig;
                int siz;
                bits.ReadInt32(out sig);
                bits.ReadInt32(out siz);
                int endSym = bits.Position + siz;

                switch ((DEBUG_S_SUBSECTION)sig)
                {
                    case DEBUG_S_SUBSECTION.LINES:
                        {
                            CV_LineSection sec;

                            bits.ReadUInt32(out sec.off);
                            bits.ReadUInt16(out sec.sec);
                            bits.ReadUInt16(out sec.flags);
                            bits.ReadUInt32(out sec.cod);
                            int funcIndex = FindFunction(funcs, sec.sec, sec.off);
                            if (funcIndex < 0) break;
                            var func = funcs[funcIndex];
                            if (func.SequencePoints == null)
                            {
                                while (funcIndex > 0)
                                {
                                    var f = funcs[funcIndex - 1];
                                    if (f.SequencePoints != null || f.Segment != sec.sec || f.Address != sec.off) break;
                                    func = f;
                                    funcIndex--;
                                }
                            }
                            else
                            {
                                while (funcIndex < funcs.Length - 1 && func.SequencePoints != null)
                                {
                                    var f = funcs[funcIndex + 1];
                                    if (f.Segment != sec.sec || f.Address != sec.off) break;
                                    func = f;
                                    funcIndex++;
                                }
                            }
                            if (func.SequencePoints != null) break;

                            // Count the line blocks.
                            int begSym = bits.Position;
                            int blocks = 0;
                            while (bits.Position < endSym)
                            {
                                CV_SourceFile file;
                                bits.ReadUInt32(out file.index);
                                bits.ReadUInt32(out file.count);
                                bits.ReadUInt32(out file.linsiz);   // Size of payload.
                                int linsiz = (int)file.count * (8 + ((sec.flags & 1) != 0 ? 4 : 0));
                                bits.Position += linsiz;
                                blocks++;
                            }

                            func.SequencePoints = new PdbSequencePointCollection[blocks];
                            int block = 0;

                            bits.Position = begSym;
                            while (bits.Position < endSym)
                            {
                                CV_SourceFile file;
                                bits.ReadUInt32(out file.index);
                                bits.ReadUInt32(out file.count);
                                bits.ReadUInt32(out file.linsiz);   // Size of payload.

                                PdbSource src = (PdbSource)checks[(int)file.index];
                                PdbSequencePointCollection tmp = new PdbSequencePointCollection(src, file.count);
                                func.SequencePoints[block++] = tmp;
                                PdbSequencePoint[] lines = tmp.Lines;

                                int plin = bits.Position;
                                int pcol = bits.Position + 8 * (int)file.count;

                                for (int i = 0; i < file.count; i++)
                                {
                                    CV_Line line;
                                    CV_Column column = new CV_Column();

                                    bits.Position = plin + 8 * i;
                                    bits.ReadUInt32(out line.offset);
                                    bits.ReadUInt32(out line.flags);

                                    uint lineBegin = line.flags & (uint)CV_Line_Flags.linenumStart;
                                    uint delta = (line.flags & (uint)CV_Line_Flags.deltaLineEnd) >> 24;
                                    //bool statement = ((line.flags & (uint)CV_Line_Flags.fStatement) == 0);
                                    if ((sec.flags & 1) != 0)
                                    {
                                        bits.Position = pcol + 4 * i;
                                        bits.ReadUInt16(out column.offColumnStart);
                                        bits.ReadUInt16(out column.offColumnEnd);
                                    }

                                    lines[i] = new PdbSequencePoint(line.offset,
                                                           lineBegin,
                                                           column.offColumnStart,
                                                           lineBegin + delta,
                                                           column.offColumnEnd);
                                }
                            }
                            break;
                        }
                }
                bits.Position = endSym;
            }
        }
Ejemplo n.º 13
0
 internal void Read(PdbStreamHelper reader, BitAccess bits)
 {
     bits.MinCapacity(_contentSize);
     Read(reader, 0, bits.Buffer, 0, _contentSize);
 }
Ejemplo n.º 14
0
 internal void Read(PdbStreamHelper reader, BitAccess bits)
 {
     bits.MinCapacity(_contentSize);
     Read(reader, 0, bits.Buffer, 0, _contentSize);
 }