xperfview 加载 DLL 符号时出现问题
我一直在竭尽全力地使用 xperf 来获取我正在分析的工具的符号。我在该工具中运行的代码分为 .exe 和 .dll——要分析的重要内容位于 .dll 中。我运行了 xperf:
xperf -on PROC_THREAD+LOADER+INTERRUPT+DPC+PROFILE -stackwalk profile
然后我运行了我的工具一段时间,然后
xperf -d profile.etl
我尝试了 xperfview。我加载了配置文件,打开了“加载符号”,然后打开了汇总表。根本没有任何符号——从字面上看,模块在功能列中出现“未知”。我已经搜索了其他线程,这就是我尝试过的:
- 我设置了环境变量 _NT_SYMBOL_PATH 和 _NT_SYMCACHE
- 我清除了符号缓存并运行 xperf -symbols -i profile_results.etl。
- 我从最新版本的 Windows 调试工具复制了 dbghelp.dll 并重复上述操作。
完成所有这些操作后,我现在可以正确显示大多数不是我自己的代码的模块的函数名称,但我无法显示我的 dll。该 dll 正在发布模式下编译(经过优化),但我专门设置了 Visual Studio 项目来创建 pdb,我已验证该 pdb 是否存在并且位于我的 _NT_SYMBOL_PATH 上的目录中。有谁知道我该如何解决这个问题,或者至少进一步调试它?
I have been fighting tooth and nail with xperf to get symbols for a tool I'm profiling. My code that runs within the tool is split between the .exe and a .dll -- the important stuff to profile being in the .dll. I ran xperf:
xperf -on PROC_THREAD+LOADER+INTERRUPT+DPC+PROFILE -stackwalk profile
And then I ran my tool for a bit, and then
xperf -d profile.etl
Then I tried xperfview. I loaded up the profile, toggled "load symbols" on, and opened the summary table. No symbols at all -- literally module came up "unknown" in the function column. I've scoured other threads on this and here's what I've tried:
- I set my environment variables, _NT_SYMBOL_PATH and _NT_SYMCACHE
- I cleared out my symbol cache and run xperf -symbols -i profile_results.etl.
- I copied over dbghelp.dll from a recent version of Windows Debugging Tools and repeated the above.
After doing all this I now get function names showing up properly for most of the modules that are not my own code, but I can't get my dll to show up. The dll is being compiled in release mode (with optimization) but I set the Visual Studio project specifically to create a pdb, I've verified that the pdb exists and that it is within a directory on my _NT_SYMBOL_PATH. Does anyone know how I can fix this, or at least debug it further?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以设置一些环境变量< /a> 在符号加载期间启用诊断日志记录:
You can set some environment variables to enable diagnostic logging during symbol loading:
我刚刚遇到了同样的问题...尝试了所有相同的步骤...浏览了所有(显然)类似的建议...
此外,我尝试使用相同的
dbghelp.dll 启动
/symchk
我已将symsrv.dll
DLL 复制到我的 WPA“bin”文件夹中,以确保我的 PDB 是可定位的。 (仍然认为我要疯了......)我应该注意:我的 _NT_SYMBOL_PATH 值包含带有 lcl 缓存和服务器的服务器。直接本地位置:
_NT_SYMBOL_PATH=srv*D:\SymbolCache*http://msdl.microsoft.com/download/symbols;D:\GitHub\...
。然后我突然意识到,我的“伙伴”EXE 使用的 DLL 是通过 LoadLibrary()/GetProcAddress() 动态加载的……这可能是 XPerf 的问题吗???
我什至犹豫是否要尝试这个...
我在 DLL 中添加了一个无用的导出,然后直接在 EXE 中调用它(以触发我的 DLL 的导入表条目)所以现在 EXE 取决于 DLL 甚至加载。
事实证明
...........然后 XPerf 加载了所有符号:)。
编辑:我刚刚发现这个URL,有人在 11 年发布了代码,演示了类似(相同?)的问题
编辑:
我最近与一位同事讨论了这个问题,并且据了解,XPerf 将正确“决定”加载以编程方式加载的 DLL 的符号...如果 DLL 保持加载状态直到进程终止。
因此,对于在执行期间加载和卸载以及在终止时卸载的 DLL...XPerf 将跳过加载这些符号的尝试。
I just encountered the same problem... tried all the same steps... browsed all the (apparently) similar advice...
Additionally, I tried launching
symchk
using the samedbghelp.dll
/symsrv.dll
DLLs I had copied into my WPA 'bin' folder, to make sure that my PDB is locatable. (still thinking I'm going crazy...)I should note: my _NT_SYMBOL_PATH value contained servers with lcl cache & straight up local locations:
_NT_SYMBOL_PATH=srv*D:\SymbolCache*http://msdl.microsoft.com/download/symbols;D:\GitHub\...
.Then it dawned on me that my DLL, used by my "partner" EXE, is loaded dynamically via LoadLibrary()/GetProcAddress() ... could this be an issue for XPerf ?????
I hesitated even trying this...
I added a useless export in my DLL, and I invoke it directly in the EXE (to trigger an Import Table entry for my DLL) So now the EXE depends on the DLL to even load.
Turns out...
.............then XPerf loaded all the symbols :).
Edit: I just found this URL on MSDN, where someone posted code back in '11 that demonstrates a similar (the same?) problem
EDIT:
I recently discussed this with a collegue, and learned that XPerf will properly "decide" to load symbols for DLLs loaded programmatically ... IF the DLL remains loaded until the termination of the process.
So, for DLLs that are Loaded and Unloaded during the execution, and are unloaded at termination... XPerf will skip the attempt to load those symbols.
我不确定这是否有帮助,但除了 xperf 无法加载我的 DLL 符号:
对我来说,xperfview 不喜欢映射网络驱动器上的 PDB 文件:因为我正在运行 xperf 和在与构建代码的机器不同的 xperfview 上,我从网络共享获取可执行文件和 PDB 文件,我将其映射到驱动器号以重新创建与构建机器上完全相同的绝对路径 - 不走运。即使将包含 PDB 文件的文件夹添加到符号路径也没有帮助。
一旦我确保 .pdb 文件位于本地文件夹中,一切都会按预期进行。
I'm not sure if this helps, but in here is one more detail I came across today in addition to the Q&A at xperf can't load my DLL's symbols:
For me, xperfview doesn't like PDB files on mapped network drives: as I was running xperf and xperfview on a different machine from where the code was built, I was getting both executables and PDB files off a network share, which I mapped to a drive letter to recreate exactly the same absolute paths as on the build machine - no luck. Even adding the folder with the PDB files to the symbol path didn't help.
Everything worked as expected once I made sure the .pdb file was in a local folder.
尝试使用 wpa 而不是 xperfview。它使用与 xperfview 相同的系统来加载符号,但它还有一个诊断控制台,可让您查看有用的符号加载消息。
另外,您应该告诉我们您将 _NT_SYMBOL_PATH 设置为什么。有很多方法可能会导致其设置错误。
另外,在 _NT_SYMBOL_PATH 中,您应该为 PDB 文件指定本地缓存 - 然后您可以在那里检查 PDB 是否已复制到本地缓存。
您还可以查看 SymCache 路径(由 _NT_SYMCACHE_PATH 指向,默认为 c:\symcache),这是存储 WPT .symcache 文件的位置。 PDB 文件被转换为这种格式,.symcache 文件是 WPA 和 xperfview 最终加载的文件。
有关详细信息,请参阅:
http://randomascii.wordpress.com /2012/10/04/xperf-symbol-loading-陷阱/
Try using wpa instead of xperfview. It uses the same system for loading symbols that xperfview does but it also has a Diagnostic Console which lets you see symbol loading messages which can be helpful.
Also, you should tell us what you have _NT_SYMBOL_PATH set to. There are many ways that it can be incorrectly set.
Also, in _NT_SYMBOL_PATH you should specify a local cache for your PDB files -- you can then check there to see if your PDBs have been copied to the local cache.
You can also look in the SymCache Path (pointed to by _NT_SYMCACHE_PATH, defaults to c:\symcache) which is where the WPT .symcache files are stored. The PDB files are converted to this format and the .symcache files are what are ultimately loaded by WPA and xperfview.
For more information see:
http://randomascii.wordpress.com/2012/10/04/xperf-symbol-loading-pitfalls/