Imported Upstream version 4.8.0.309

Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-11-10 13:04:39 +00:00
parent ee1447783b
commit 94b2861243
4912 changed files with 390737 additions and 49310 deletions

View File

@@ -24,6 +24,8 @@ namespace Microsoft.Cci.Pdb {
// this.pageSize = pageSize;
//}
const string MAGIC = "Microsoft C/C++ MSF 7.00";
internal PdbFileHeader(Stream reader, BitAccess bits) {
bits.MinCapacity(56);
reader.Seek(0, SeekOrigin.Begin);
@@ -37,15 +39,18 @@ namespace Microsoft.Cci.Pdb {
bits.ReadInt32(out this.directorySize); // 44..47
bits.ReadInt32(out this.zero); // 48..51
if (Magic != MAGIC) {
throw new InvalidOperationException("Magic is wrong.");
}
int directoryPages = ((((directorySize + pageSize - 1) / pageSize) * 4) + pageSize - 1) / pageSize;
this.directoryRoot = new int[directoryPages];
bits.FillBuffer(reader, directoryPages * 4);
bits.ReadInt32(this.directoryRoot);
}
//internal string Magic {
// get { return StringFromBytesUTF8(magic); }
//}
string Magic {
get { return StringFromBytesUTF8(magic, 0, MAGIC.Length); }
}
//internal void Write(Stream writer, BitAccess bits) {
// bits.MinCapacity(pageSize);
@@ -63,18 +68,18 @@ namespace Microsoft.Cci.Pdb {
//////////////////////////////////////////////////// Helper Functions.
//
//internal static string StringFromBytesUTF8(byte[] bytes) {
// return StringFromBytesUTF8(bytes, 0, bytes.Length);
//}
static string StringFromBytesUTF8(byte[] bytes) {
return StringFromBytesUTF8(bytes, 0, bytes.Length);
}
//internal static string StringFromBytesUTF8(byte[] bytes, int offset, int length) {
// for (int i = 0; i < length; i++) {
// if (bytes[offset + i] < ' ') {
// length = i;
// }
// }
// return Encoding.UTF8.GetString(bytes, offset, length);
//}
static string StringFromBytesUTF8(byte[] bytes, int offset, int length) {
for (int i = 0; i < length; i++) {
if (bytes[offset + i] < ' ') {
length = i;
}
}
return Encoding.UTF8.GetString(bytes, offset, length);
}
////////////////////////////////////////////////////////////// Fields.
//