public static void Dump(BitSet bits) { uint word; for (int i = 0; bits.GetWord(i, out word); i++) { Console.Write("{0:x8}", word); } }
static void DumpPdbStream(BitAccess bits, out int linkStream, out int nameStream, out int srchStream) { linkStream = 0; nameStream = 0; srchStream = 0; int ver; int sig; int age; Guid guid; bits.ReadInt32(out ver); // 0..3 Version bits.ReadInt32(out sig); // 4..7 Signature bits.ReadInt32(out age); // 8..11 Age bits.ReadGuid(out guid); // 12..27 GUID // Read string buffer. int buf; bits.ReadInt32(out buf); // 28..31 Bytes of Strings Console.WriteLine(" ** PDB ver={0,8} sig={1:x8} age={2} guid={3}", ver, sig, age, guid); int beg = bits.Position; int nxt = bits.Position + buf; bits.Position = nxt; // Read map index. int cnt; // n+0..3 hash size. int max; // n+4..7 maximum ni. bits.ReadInt32(out cnt); bits.ReadInt32(out max); Console.WriteLine(" cnt={0}, max={1}", cnt, max); BitSet present = new BitSet(bits); BitSet deleted = new BitSet(bits); if (!deleted.IsEmpty) { Console.Write(" deleted: "); Dump(deleted); Console.WriteLine(); } int j = 0; for (int i = 0; i < max; i++) { if (present.IsSet(i)) { int ns; int ni; bits.ReadInt32(out ns); bits.ReadInt32(out ni); string name; int saved = bits.Position; bits.Position = beg + ns; bits.ReadCString(out name); bits.Position = saved; if (name == "/names") { nameStream = ni; } else if (name == "/src/headerblock") { srchStream = ni; } else if (name == "/LinkInfo") { linkStream = ni; } Console.WriteLine(" {0,4}: [{1}]", ni, name); j++; } } if (j != cnt) { throw new PdbDebugException("Count mismatch. ({0} != {1})", j, cnt); } // Read maxni. int maxni; bits.ReadInt32(out maxni); Console.WriteLine(" maxni={0}", maxni); }
static int LoadPdbStream(BitAccess bits) { int nameStream = -1; int ver; int sig; int age; Guid guid; bits.ReadInt32(out ver); // 0..3 Version bits.ReadInt32(out sig); // 4..7 Signature bits.ReadInt32(out age); // 8..11 Age bits.ReadGuid(out guid); // 12..27 GUID if (ver != 20000404) { throw new PdbDebugException("Unsupported PDB Stream version {0}", ver); } // Read string buffer. int buf; bits.ReadInt32(out buf); // 28..31 Bytes of Strings int beg = bits.Position; int nxt = bits.Position + buf; bits.Position = nxt; // Read map index. int cnt; // n+0..3 hash size. int max; // n+4..7 maximum ni. bits.ReadInt32(out cnt); bits.ReadInt32(out max); BitSet present = new BitSet(bits); BitSet deleted = new BitSet(bits); if (!deleted.IsEmpty) { throw new PdbDebugException("Unsupported PDB deleted bitset is not empty."); } int j = 0; for (int i = 0; i < max; i++) { if (present.IsSet(i)) { int ns; int ni; bits.ReadInt32(out ns); bits.ReadInt32(out ni); string name; int saved = bits.Position; bits.Position = beg + ns; bits.ReadCString(out name); bits.Position = saved; if (name == "/names") { nameStream = ni; } else if (name == "/src/headerblock") { // srchStream = ni; } else if (name == "/LinkInfo") { // linkStream = ni; } j++; } } if (j != cnt) { throw new PdbDebugException("Count mismatch. ({0} != {1})", j, cnt); } return nameStream; }