Beispiel #1
0
        static void DumpDbiStream(BitAccess bits,
                                  out int globalsStream,
                                  out int publicsStream,
                                  out int symbolsStream,
                                  out DbiModuleInfo[] modules)
        {
            globalsStream = 0;
            publicsStream = 0;
            symbolsStream = 0;
            DbiHeader dh = new DbiHeader(bits);

            Console.WriteLine("   ** DBI sig={0}, ver={1}, age={2}, vers={3:x4}, "+
                              "pdb={4}, pdb2={5}",
                              dh.sig, dh.ver, dh.age, dh.vers, dh.pdbver, dh.pdbver2);
            if (dh.sig != -1 || dh.ver != 19990903) {
                throw new IOException("Unknown DBI Stream version");
            }

            Console.WriteLine("      mach={0:x4}, flags={1:x4}, globals={2}, publics={3}, symbols={4}",
                              dh.machine,
                              dh.flags,
                              dh.gssymStream,
                              dh.pssymStream,
                              dh.symrecStream);
            Console.WriteLine("      gpmod={0}, seccon={1}, secmap={2}, filinf={3}, ",
                              dh.gpmodiSize,
                              dh.secconSize,
                              dh.secmapSize,
                              dh.filinfSize);
            Console.WriteLine("      tsmap={0}, dbghdr={1}, ecinf={2}, mfc={3}",
                              dh.tsmapSize,
                              dh.dbghdrSize,
                              dh.ecinfoSize,
                              dh.mfcIndex);
            Console.WriteLine("      sizes={0}",
                              bits.Position +
                              dh.gpmodiSize +
                              dh.secconSize +
                              dh.secmapSize +
                              dh.filinfSize +
                              dh.tsmapSize +
                              dh.dbghdrSize +
                              dh.ecinfoSize);

            globalsStream = dh.gssymStream;
            publicsStream = dh.pssymStream;
            symbolsStream = dh.symrecStream;

            // Read gpmod section.
            ArrayList modList = new ArrayList();
            int end = bits.Position + dh.gpmodiSize;
            while (bits.Position < end) {
                DbiModuleInfo mod = new DbiModuleInfo(bits, true);
                Dump(mod);

                modList.Add(mod);
            }
            if (bits.Position != end) {
                throw new Exception("off!");
            }

            // Read seccon section.
            end = bits.Position + dh.secconSize;
            Console.WriteLine("    SecCon:");
            Dump(bits.Buffer, bits.Position, end);
            bits.Position = end;

            // Read secmap section.
            end = bits.Position + dh.secmapSize;
            Console.WriteLine("    SecMap:");
            Dump(bits.Buffer, bits.Position, end);
            bits.Position = end;

            // Read filinf section.
            end = bits.Position + dh.filinfSize;
            Console.WriteLine("    FilInf:");
            Dump(bits.Buffer, bits.Position, end);
            bits.Position = end;

            // Read tsmap section.
            end = bits.Position + dh.tsmapSize;
            Console.WriteLine("    TSMap:");
            Dump(bits.Buffer, bits.Position, end);
            bits.Position = end;

            // Read ecinfo section.
            end = bits.Position + dh.ecinfoSize;
            Console.WriteLine("    ECInfo:");
            Dump(bits.Buffer, bits.Position, end);
            DumpNameStream(bits);
            bits.Position = end;

            // Read dbghdr section.
            end = bits.Position + dh.dbghdrSize;
            Console.WriteLine("    DbgHdr:");
            if (dh.dbghdrSize > 0) {
                int beg = bits.Position;
                Dump(bits.Buffer, bits.Position, end);
                bits.Position = beg;
                DbiDbgHdr ddh = new DbiDbgHdr(bits);
                Console.WriteLine("      sechdr={0}, ridmap={1}",
                                  ddh.snSectionHdr,
                                  ddh.snTokenRidMap);
            }
            bits.Position = end;

            if (modList.Count > 0) {
                modules = (DbiModuleInfo[])modList.ToArray(typeof(DbiModuleInfo));
            }
            else {
                modules = null;
            }
        }
Beispiel #2
0
 static void DumpDbiModule(BitAccess bits,
                           DbiModuleInfo info)
 {
     Console.WriteLine("   ** Module [{0}]", info.moduleName);
     DumpSymbols(bits, 0, info.cbSyms);
     DumpLines(bits,
               info.cbSyms + info.cbOldLines,
               info.cbSyms + info.cbOldLines + info.cbLines);
 }
        static void LoadDbiStream(BitAccess bits,
                                  out DbiModuleInfo[] modules,
                                  out DbiDbgHdr header,
                                  bool readStrings)
        {
            DbiHeader dh = new DbiHeader(bits);
            header = new DbiDbgHdr();

            if (dh.sig != -1 || dh.ver != 19990903) {
                throw new PdbException("Unsupported DBI Stream version, sig={0}, ver={1}",
                                       dh.sig, dh.ver);
            }

            // Read gpmod section.
            ArrayList modList = new ArrayList();
            int end = bits.Position + dh.gpmodiSize;
            while (bits.Position < end) {
                DbiModuleInfo mod = new DbiModuleInfo(bits, readStrings);
                modList.Add(mod);
            }
            if (bits.Position != end) {
                throw new PdbDebugException("Error reading DBI stream, pos={0} != {1}",
                                            bits.Position, end);
            }

            if (modList.Count > 0) {
                modules = (DbiModuleInfo[])modList.ToArray(typeof(DbiModuleInfo));
            }
            else {
                modules = null;
            }

            // Skip the Section Contribution substream.
            bits.Position += dh.secconSize;

            // Skip the Section Map substream.
            bits.Position += dh.secmapSize;

            // Skip the File Info substream.
            bits.Position += dh.filinfSize;

            // Skip the TSM substream.
            bits.Position += dh.tsmapSize;

            // Skip the EC substream.
            bits.Position += dh.ecinfoSize;

            // Read the optional header.
            end = bits.Position + dh.dbghdrSize;
            if (dh.dbghdrSize > 0) {
                header = new DbiDbgHdr(bits);
            }
            bits.Position = end;
        }
Beispiel #4
0
        public static void Dump(DbiModuleInfo s)
        {
            Console.WriteLine("        stream={0,4}. {1,3} [{2}] {3}/{4}",
                              s.stream, s.section.module, s.moduleName,
                              s.cbSyms, s.cbLines);
#if VERBOSE
            Console.WriteLine("          flags={0:x4}, sym={1}, lin={2}, c13={3}, files={4}",
                              s.stream,
                              s.flags,
                              s.cbSyms,
                              s.cbOldLines,
                              s.cbLines,
                              s.files);
            Dump(section);
            Console.WriteLine("          offsets={0:x8}, source={1}, compiler={2}",
                              s.offsets, s.niSource, s.niCompiler);
            Console.WriteLine("          mod=[{0}]", s.moduleName);
            Console.WriteLine("          obj=[{0}]", s.objectName);
#endif
        }
        static void LoadFuncsFromDbiModule(BitAccess bits,
                                           DbiModuleInfo info,
                                           IntHashTable names,
                                           ArrayList funcList,
                                           bool readStrings)
        {
            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,
                                 (uint)(info.cbSyms + info.cbOldLines + info.cbLines));

                for (int i = 0; i < funcs.Length; i++) {
                    funcList.Add(funcs[i]);
                }
            }
        }