我正在尝试针对动态加载DLL的C ++应用程序进行热加载。
当应用程序运行(在调试模式下)时,它将将DLL和关联的PDB复制到中间目录,并加载该DLL。
因此,在随后的编译中,可以覆盖原始文件。
由于DLLS将其PDB的路径存储在DLL标题中,因此该应用程序对DLL标头进行修补以指向正确的PDB。
为了确保DLL大小保持完全相同,我仅覆盖PDB名称的1个字符。
编译DLL时,我将PDB路径设置为以下内容(使用/PDBALTPATH
linker flag):
z:/ngen/stage/stage/tage/tmp/thename._。pdb
然后,将DLL复制到TMP目录时,我将名称修补为类似的内容:
z:/ngen/stage/tmp/thename.a.pdb
z:/ngen/stage/tmp/thename.b.pdb
我验证了dlls是否具有正确的复制后修补的PDB名称,使用 dumpbin
程序。

现在,当我第一次运行应用程序时,这正常运行;调试符号已正确加载。但是,当我重建DLL(在MSVC的另一个实例中)并加载新DLL时,MSVC不会加载新DLL的调试符号。
相反,我收到一条消息,即已经加载了符号的不同版本。
为什么MSVC不加载与第二个DLL关联的PDB?
I'm trying to implement hot reloading for a C++ app that loads a DLL dynamically.
When the app runs (in debug mode), it will copy the DLL and associated PDB to an intermediate directory, and load that.
This is so that in subsequent compiles, the original files can be overwritten.
Since DLLs store the path to their PDB in the DLL header, the app patches the DLL header to point to the correct PDB.
To make sure the DLL size remains exactly the same, I only override 1 character of the PDB name.
When compiling the DLL, I set the PDB path to something like the following (using the /PDBALTPATH
linker flag):
Z:/NGEN/Stage/Tmp/TheName._.pdb
Then, when copying the DLL to the Tmp directory, I patch the name to something like:
Z:/NGEN/Stage/Tmp/TheName.a.pdb
Z:/NGEN/Stage/Tmp/TheName.b.pdb
I verified that the DLLs have the correct patched PDB name after copying, using the dumpbin
program.


Now, this works fine when I first run the app; the debug symbols are loaded correctly. However, when I rebuild the DLL (in another instance of MSVC) and the app loads the new DLL, MSVC doesn't load the debug symbol of the new DLL.
Instead, I get a message that different versions of the symbols have already been loaded.

Why does MSVC not load the PDB associated with the second DLL?
发布评论
评论(1)
供您参考:为什么Visual Studio需要调试器符号文件与恰好与它们构建的二进制文件匹配?
For your reference: Why does Visual Studio require debugger symbol files to exactly match the binary files that they were built with?