pdb调试符号在热载期间未加载

发布于 2025-02-12 06:36:32 字数 1186 浏览 0 评论 0 原文

我正在尝试针对动态加载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.

DLL A

DLL B

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.

Not loaded message

Why does MSVC not load the PDB associated with the second DLL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柒夜笙歌凉 2025-02-19 06:36:36

供您参考:为什么Visual Studio需要调试器符号文件与恰好与它们构建的二进制文件匹配?

内部时间戳记将有所不同。但是甚至不忽视这一点,
代码的实际布局可能是
不同。

For your reference: Why does Visual Studio require debugger symbol files to exactly match the binary files that they were built with?

an internal time-stamp will be different. But even disregarding that,
the actual layout of the code could be
different.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文