Our application has some add-ons in the form of DLLs in nested directories. We are running tests with an instance of DbgView running in the background via which we get our logs. The problem is we run the tests on a different computer from the one we built the build on. This causes the Debug Directory entries in the PE header (extracted via the Dumpbin tool) to be pretty much invalid.
We don't have a symbol server nothing like that. All the PDB files however are placed next to the binaries in the debug build with the proper names so we hoped that they would be found without a problem.
The add-ons are loaded via the LoadLibrary Windows function, and then the SymLoadModule64 function is used to load the symbol table. According to the return values goes right, but when we check what PDB was actually loaded using the SymGetModuleInfo64 it shows that actually nothing. This is also evident from the original problem which led us to dive into fixing this part of our application which is that the call-stacks in the aforementioned debug logs, more precisely their parts which address the add-ons are messed up.
Tried various versions of the functions, and checked the DbgHelp library's version too, to no avail.
Attaching from VS shows that VS can indeed find the PDBs, while our symbol loading mechanism and the logs in the Output window still show the problematic behaviour. All VS can fix is the messed up call stacks.
The Symbol loading of DbgHelp is initialized with the root directory of the application as the "SymSearchPath" and with DEFERRED_LOAD enabled. The latter we needed to remove and the former being set to include the directories of the add-ons. A different solution was to move the PDB files up to this root directory.
According to the reference of the SymInitialize on MSDN the "SymSearchPath" is searched recursively for the PDB files, but really it isn't. The other thing is that every time I browsed the web for an order, method of how PDB files are found, it read either as 1st or 2nd in line that the directory from which the binary is loaded is searched for the PDB files, but as I've explained above this does not happen that way either.
All in all, while the problem seems to be solved, there is a lot of things confusing here.
So..
1. If anyone knows the TRUE way PDB files are loaded it would be much enlightening. .. ?
2. Is DbgHelp fundamentally buggy?
3. Why is the "SymSearchPath" not searched recursively when it is said so on MSDN?
Also, if you have Anything else to add, that would be welcome as well.
Thanks for reading such a long post.