Skip to content

Commit 2c68927

Browse files
MarcoRossignoliMarco Rossignoli
and
Marco Rossignoli
authored
Fix mixed module ReadSymbols() (#851)
Fix reading some pdb generated by the C++ compiler for mixed mode assemblies. Co-authored-by: Marco Rossignoli <[email protected]>
1 parent f7b64f7 commit 2c68927

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ static Dictionary<string, int> LoadNameIndex(BitAccess bits, out int age, out Gu
6868

6969
BitSet present = new BitSet(bits);
7070
BitSet deleted = new BitSet(bits);
71-
if (!deleted.IsEmpty) {
72-
throw new PdbDebugException("Unsupported PDB deleted bitset is not empty.");
73-
}
71+
//if (!deleted.IsEmpty) {
72+
// throw new PdbDebugException("Unsupported PDB deleted bitset is not empty.");
73+
//}
7474

7575
int j = 0;
7676
for (int i = 0; i < max; i++) {

symbols/pdb/Test/Mono.Cecil.Tests/PdbTests.cs

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.IO;
22
using System.Linq;
3-
43
using Mono.Cecil.Cil;
54
using Mono.Cecil.Pdb;
65

@@ -56,7 +55,7 @@ .locals init (System.Int32 i, System.Int32 CS$1$0000, System.Boolean CS$4$0001)
5655
IL_0020: ldloc.1
5756
IL_0021: ret
5857
", main);
59-
}, readOnly: !Platform.HasNativePdbSupport, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
58+
}, readOnly: !Platform.HasNativePdbSupport, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider));
6059
}
6160

6261
[Test]
@@ -82,7 +81,7 @@ public void DebuggerHiddenVariable ()
8281

8382
Assert.AreEqual ("i", variables [0].Name);
8483
Assert.IsFalse (variables [0].IsDebuggerHidden);
85-
}, readOnly: !Platform.HasNativePdbSupport, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
84+
}, readOnly: !Platform.HasNativePdbSupport, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider));
8685
}
8786

8887
[Test]
@@ -103,7 +102,7 @@ public void Document ()
103102
Assert.AreEqual (new byte [] { 228, 176, 152, 54, 82, 238, 238, 68, 237, 156, 5, 142, 118, 160, 118, 245 }, document.Hash);
104103
Assert.AreEqual (DocumentLanguage.CSharp, document.Language);
105104
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
106-
}, readOnly: !Platform.HasNativePdbSupport, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
105+
}, readOnly: !Platform.HasNativePdbSupport, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider));
107106
}
108107

109108
[Test]
@@ -124,7 +123,7 @@ public void BasicDocument ()
124123
Assert.AreEqual (new byte [] { 184, 188, 100, 23, 27, 123, 187, 201, 175, 206, 110, 198, 242, 139, 154, 119 }, document.Hash);
125124
Assert.AreEqual (DocumentLanguage.Basic, document.Language);
126125
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
127-
}, readOnly: !Platform.HasNativePdbSupport, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
126+
}, readOnly: !Platform.HasNativePdbSupport, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider));
128127
}
129128

130129
[Test]
@@ -248,7 +247,7 @@ public void LocalConstants ()
248247

249248
constant = scope.Constants [1];
250249
Assert.AreEqual ("c", constant.Name);
251-
Assert.AreEqual ((decimal) 74, constant.Value);
250+
Assert.AreEqual ((decimal)74, constant.Value);
252251
Assert.AreEqual (MetadataType.ValueType, constant.ConstantType.MetadataType);
253252

254253
method = type.GetMethod ("Foo");
@@ -448,7 +447,7 @@ public void CreateMethodFromScratch ()
448447

449448
method.DebugInformation.SequencePoints.Add (sequence_point);
450449

451-
method.DebugInformation.Scope = new ScopeDebugInformation (body.Instructions [0], null) {
450+
method.DebugInformation.Scope = new ScopeDebugInformation (body.Instructions [0], null) {
452451
Variables = { new VariableDebugInformation (temp, "temp") }
453452
};
454453

@@ -476,5 +475,15 @@ public void TypeNameExceedingMaxPdbPath ()
476475
Assert.IsTrue (module.HasSymbols);
477476
}, symbolReaderProvider: typeof (NativePdbReaderProvider), symbolWriterProvider: typeof (NativePdbWriterProvider));
478477
}
478+
479+
[Test]
480+
public void ReadPdbMixedNativeCLIModule ()
481+
{
482+
// MixedNativeCLI.exe was copy/pasted from from https://docs.microsoft.com/en-us/cpp/preprocessor/managed-unmanaged?view=msvc-170#example
483+
TestModule ("MixedNativeCLI.exe", module => {
484+
module.ReadSymbols ();
485+
}, readOnly: true);
486+
}
487+
479488
}
480489
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ImageRuntimeVersion: v4.0.30319
2+
Assembly MixedNativeCLI, Version=0.0.*, Culture=Invariant Language (Invariant Country):
3+
hash=SHA1, flags=PublicKey
4+
Assembly mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089:
5+
hash=None, flags=None
Binary file not shown.

0 commit comments

Comments
 (0)