Пример #1
0
        internal PdbScope(BlockSym32 block, BitAccess bits, out uint typind)
        {
            this.segment = block.seg;
            this.address = block.off;
            this.length = block.len;
            typind = 0;

            int scopeCount;
            int slotCount;
            PdbFunction.CountScopesAndSlots(bits, block.end, out scopeCount, out slotCount);
            scopes = new PdbScope[scopeCount];
            slots = new PdbSlot[slotCount];
            int scope = 0;
            int slot = 0;

            while (bits.Position < block.end) {
                ushort siz;
                ushort rec;

                bits.ReadUInt16(out siz);
                int star = bits.Position;
                int stop = bits.Position + siz;
                bits.Position = star;
                bits.ReadUInt16(out rec);

                switch ((SYM)rec) {
                    case SYM.S_BLOCK32: {
                        BlockSym32 sub = new BlockSym32();

                        bits.ReadUInt32(out sub.parent);
                        bits.ReadUInt32(out sub.end);
                        bits.ReadUInt32(out sub.len);
                        bits.ReadUInt32(out sub.off);
                        bits.ReadUInt16(out sub.seg);
                        bits.SkipCString(out sub.name);

                        bits.Position = stop;
                        scopes[scope++] = new PdbScope(sub, bits, out typind);
                        break;
                    }

                    case SYM.S_MANSLOT:
                        slots[slot++] = new PdbSlot(bits, out typind);
                        bits.Position = stop;
                        break;

                    case SYM.S_END:
                    case SYM.S_UNAMESPACE:
                    case SYM.S_MANCONSTANT:
                        bits.Position = stop;
                        break;

                    default:
                        throw new PdbException("Unknown SYM in scope {0}", (SYM)rec);
                        // bits.Position = stop;
                }
            }

            if (bits.Position != block.end) {
                throw new Exception("Not at S_END");
            }

            ushort esiz;
            ushort erec;
            bits.ReadUInt16(out esiz);
            bits.ReadUInt16(out erec);

            if (erec != (ushort)SYM.S_END) {
                throw new Exception("Missing S_END");
            }
        }
Пример #2
0
 public static void Dump(PdbSlot s, int indent)
 {
     string pad = new String(' ', indent);
     Console.WriteLine("            {0}Slot: {1,2} [{2}] addr={3:x4}:{4:x8}",
                       pad, s.slot, s.name, s.segment, s.address);
 }
Пример #3
0
        internal PdbScope(BlockSym32 block, BitAccess bits, out uint typind)
        {
            this.segment = block.seg;
            this.address = block.off;
            this.length  = block.len;
            typind       = 0;

            int scopeCount;
            int slotCount;

            PdbFunction.CountScopesAndSlots(bits, block.end, out scopeCount, out slotCount);
            scopes = new PdbScope[scopeCount];
            slots  = new PdbSlot[slotCount];
            int scope = 0;
            int slot  = 0;

            while (bits.Position < block.end)
            {
                ushort siz;
                ushort rec;

                bits.ReadUInt16(out siz);
                int star = bits.Position;
                int stop = bits.Position + siz;
                bits.Position = star;
                bits.ReadUInt16(out rec);

                switch ((SYM)rec)
                {
                case SYM.S_BLOCK32: {
                    BlockSym32 sub = new BlockSym32();

                    bits.ReadUInt32(out sub.parent);
                    bits.ReadUInt32(out sub.end);
                    bits.ReadUInt32(out sub.len);
                    bits.ReadUInt32(out sub.off);
                    bits.ReadUInt16(out sub.seg);
                    bits.SkipCString(out sub.name);

                    bits.Position   = stop;
                    scopes[scope++] = new PdbScope(sub, bits, out typind);
                    break;
                }

                case SYM.S_MANSLOT:
                    slots[slot++] = new PdbSlot(bits, out typind);
                    bits.Position = stop;
                    break;

                case SYM.S_END:
                case SYM.S_UNAMESPACE:
                case SYM.S_MANCONSTANT:
                    bits.Position = stop;
                    break;

                default:
                    throw new PdbException("Unknown SYM in scope {0}", (SYM)rec);
                    // bits.Position = stop;
                }
            }

            if (bits.Position != block.end)
            {
                throw new Exception("Not at S_END");
            }

            ushort esiz;
            ushort erec;

            bits.ReadUInt16(out esiz);
            bits.ReadUInt16(out erec);

            if (erec != (ushort)SYM.S_END)
            {
                throw new Exception("Missing S_END");
            }
        }