runtime: crossgen2 `--pdb` does not work when the output PDB is not named the way MSDiaReader expects
Description
Specifying --pdb on the crossgen2 command line results in an error after writing the new DLL(s):
2>System.Runtime.InteropServices.COMException (0x80004005)
2> at ILCompiler.Diagnostics.PdbWriter.CreateNGenPdbWriter(String, String, IntPtr&) + 0xce
2> at ILCompiler.Diagnostics.PdbWriter.WritePDBDataHelper(String, IEnumerable`1) + 0x195
2> at ILCompiler.Diagnostics.PdbWriter.WritePDBData(String, IEnumerable`1) + 0x1b
2> at ILCompiler.DependencyAnalysis.ReadyToRunObjectWriter.EmitPortableExecutable() + 0x9ce
2> at ILCompiler.ReadyToRunCodegenCompilation.Compile(String) + 0x18d
2> at ILCompiler.Program.RunSingleCompilation(Dictionary`2, InstructionSetSupport, String, Dictionary`2, HashSet`1, CompilerTypeSystemContext) + 0x17b0
2> at ILCompiler.Program.Run(String[]) + 0xd6b
2> at ILCompiler.Program.Main(String[]) + 0x32
Reproduction Steps
Add --pdb to your crossgen2 command line args
Expected behavior
It works
Actual behavior
It does not work
Regression?
No; this was also bugged in .NET 6
Known Workarounds
I need the PDBs so that plugin developers can set breakpoints and do debugging. For now, they can set DOTNET_ReadyToRun=0.
Configuration
No response
Other information
No response
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 15 (15 by maintainers)
I have clarified the naming of this issue to avoid its confusion with the recent regression in overall PDB generation tracked under https://github.com/dotnet/runtime/issues/96917.
Thanks Jakob and Rick for sharing your additional findings. While in theory this bit of code is supposed to handle this case,
https://github.com/dotnet/runtime/blob/28cf1719704d33a677990cf487af5719b6389f2a/src/coreclr/tools/aot/ILCompiler.Diagnostics/PdbWriter.cs#L194
for some reason it’s apparently not kicking in. I’ll self-assign this issue and I’ll investigate what the problem is.