Fix Crossgen2 PDB generator (#70407)
authorTomáš Rylek <trylek@microsoft.com>
Thu, 9 Jun 2022 18:06:07 +0000 (20:06 +0200)
committerGitHub <noreply@github.com>
Thu, 9 Jun 2022 18:06:07 +0000 (20:06 +0200)
commita325e52ecb3b3c970cfb4da4dddeab3eda20df9c
tree695cd4f30cf11efa55e8a61cd015db913057108c
parent9080239fb2b47717126f30d3890c1a48eb100527
Fix Crossgen2 PDB generator (#70407)

* Fix Crossgen2 PDB generator

During my perf investigation work I have found out that PDB emitter
in Crossgen2 is broken. I tracked this down to the change

https://github.com/dotnet/runtime/commit/fdf6485c800ec580656d7491795e10881d493afb#diff-24e48862e3b82f52e7fa04f22700b1c976a012bfeb08a246406f4e5ec579699b

that caused two behavioral changes in the PDB emitter:

1) The logic around QueryPDBNameEx got refactored to use a char[]
instead of a StringBuilder and that silently caused _pdbFilePath
to be set to the string "System.Char[]" instead of the actual path
(cf PdbWriter.cs#221 in the quoted commit).

2) The COM wrapper refactoring ended up bumping the refcount
on the _ngenWriter by one so that it never got actually closed
and properly flushed; due to this the resulting PDB was invalid.

Thanks

Tomas
src/coreclr/tools/aot/ILCompiler.Diagnostics/PdbWriter.cs
src/coreclr/tools/aot/ILCompiler.Diagnostics/SymNgenWriterWrapper.cs