This repository has been archived by the owner on Nov 15, 2021. It is now read-only.
PDB/MDB loading fails if the symbol file is found in a different directory #833
Closed
4 of 25 tasks
Milestone
Please provide the following information when submitting an issue.
My Framework
My Environment
I have already...
My issue is related to (check only those which apply):
Expected Behavior
If option
--searchdirs
is set and the PDB file is found, then the symbols should be loaded regardless of the symbol file location.Actual Behavior
If the symbol file is in a different directory than the image file, then the symbols are not loaded and the assembly cannot be instrumented.
Steps to reproduce the problem:
Move the PDB file somewhere else and point
--searchdirs
to its directory.Explanation of the bug:
Source directory:
OpenCover.FrameWork.Symbols
CecilSymbolManager.LoadSourceAssembly()
first tries to load the assembly assuming the PDB file is in the same directory as the module file. OtherwiseFileNotFoundException
is thrown and resolved usingCecilSymbolManager.SearchForSymbolsAndLoad()
.Here,
SymbolFileHelper.FindSymbolFolder(...)
will find the symbols file evaluating--searchdirs
.Also
ReaderParameters
is correctly initialized with the file stream of the symbols file.The line
_sourceAssembly = AssemblyDefinition.ReadAssembly(ModulePath, parameters);
reads the assembly including the symbols according to the settings in
parameters
.Then however, the symbols are loaded again:
The problem is that function
GetSymbolReader
is called with the module file name.Mono.Cecil
then looks for the symbol file in the same directory as the module file.GetSymbolReader
has a different overload with a symbol stream as argument that fixes the issue:.GetSymbolReader(_sourceAssembly.MainModule, parameters.SymbolStream);
The purpose of the second symbol loading eludes me. Removing the whole
if
block quoted above works as well.Fix suggestion:
Removal of the
if
block at the end of methodCecilSymbolManager.SearchForSymbolsAndLoad()
after
ReadAssembly()
.Best regards
Heiko
The text was updated successfully, but these errors were encountered: