Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix mixed module ReadSymbols() #851

Merged
merged 4 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ static Dictionary<string, int> LoadNameIndex(BitAccess bits, out int age, out Gu

BitSet present = new BitSet(bits);
BitSet deleted = new BitSet(bits);
if (!deleted.IsEmpty) {
throw new PdbDebugException("Unsupported PDB deleted bitset is not empty.");
}
//if (!deleted.IsEmpty) {
// throw new PdbDebugException("Unsupported PDB deleted bitset is not empty.");
//}

int j = 0;
for (int i = 0; i < max; i++) {
Expand Down
23 changes: 16 additions & 7 deletions symbols/pdb/Test/Mono.Cecil.Tests/PdbTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.IO;
using System.Linq;

using Mono.Cecil.Cil;
using Mono.Cecil.Pdb;

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

[Test]
Expand All @@ -82,7 +81,7 @@ public void DebuggerHiddenVariable ()

Assert.AreEqual ("i", variables [0].Name);
Assert.IsFalse (variables [0].IsDebuggerHidden);
}, readOnly: !Platform.HasNativePdbSupport, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
}, readOnly: !Platform.HasNativePdbSupport, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider));
}

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

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

[Test]
Expand Down Expand Up @@ -248,7 +247,7 @@ public void LocalConstants ()

constant = scope.Constants [1];
Assert.AreEqual ("c", constant.Name);
Assert.AreEqual ((decimal) 74, constant.Value);
Assert.AreEqual ((decimal)74, constant.Value);
Assert.AreEqual (MetadataType.ValueType, constant.ConstantType.MetadataType);

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

method.DebugInformation.SequencePoints.Add (sequence_point);

method.DebugInformation.Scope = new ScopeDebugInformation (body.Instructions [0], null) {
method.DebugInformation.Scope = new ScopeDebugInformation (body.Instructions [0], null) {
Variables = { new VariableDebugInformation (temp, "temp") }
};

Expand Down Expand Up @@ -476,5 +475,15 @@ public void TypeNameExceedingMaxPdbPath ()
Assert.IsTrue (module.HasSymbols);
}, symbolReaderProvider: typeof (NativePdbReaderProvider), symbolWriterProvider: typeof (NativePdbWriterProvider));
}

[Test]
public void ReadPdbMixedNativeCLIModule ()
{
// MixedNativeCLI.exe was copy/pasted from from https://docs.microsoft.com/en-us/cpp/preprocessor/managed-unmanaged?view=msvc-170#example
TestModule ("MixedNativeCLI.exe", module => {
module.ReadSymbols ();
}, readOnly: true);
}

}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ImageRuntimeVersion: v4.0.30319
Assembly MixedNativeCLI, Version=0.0.*, Culture=Invariant Language (Invariant Country):
hash=SHA1, flags=PublicKey
Assembly mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089:
hash=None, flags=None
Binary file not shown.