On Windows 8 or higher, when sampling managed applications, you may have noticed that samples in native images created through NGEN (these images are generated ahead of time from .NET assemblies in order to avoid the cost of JIT compilation) appear as “[<name>.ni.dll]” instead of being resolved to useful function names.
Back in 2012, we posted an explanation of why this occurs and provided some manual steps on how you can generate PDB files for these images in order to be able to resolve symbols for them.
We recognized at the time that this wasn’t an ideal solution and began working on improving this experience. That’s why in Visual Studio 2013, when using the CPU Sampling tool from the Performance and Diagnostics hub (or the new CPU Usage tool that was released in VS 2013 Update 2), we automatically generate these PDBs after your profiling session.
PDBs generated this way contain function names and some other basic information about the symbols in the corresponding images, but don’t contain detailed information such as source line numbers for functions. This is because we perform the PDB generation using only the native images themselves as input rather than requiring additional information like the original PDBs that were created with the .NET assemblies (which may not be available). Thus, you won’t be able to use the navigate-to-source functionality for functions in your profiling reports which come from NGEN’d modules. If this is important to you, the solution is to continue generating PDBs manually for NGEN’d images using the instructions mentioned in the blog post (be sure to follow the steps under the “If you do need to get back to source” section).
If you’re not on VS 2013 or above, or are not using either the CPU Sampling or CPU Usage tool in the Performance and Diagnostics hub, you won’t be able to benefit from automatic NGEN PDB generation. Profiling sessions started via the Performance Wizard or Performance Explorer will continue to require manual PDB generation for NGEN’d images, if desired. Here’s a tip, though: John Robbins has a PowerShell script that will enumerate the GAC and generate PDBs for all the .NET Framework NGEN’d binaries (or all NGEN’d binaries if desired). Find out more by reading John’s blog post about it.