简体   繁体   English

如何使dbghelp从自定义符号存储中加载符号?

[英]How to make dbghelp to load symbols from custom sym store?

Is there any way for SymInitialize and SymFromAddr methods to automatically load symbols from a custom symbol store. SymInitialize和SymFromAddr方法有什么方法可以从自定义符号存储区自动加载符号。 I'm trying to resolve an address to a readable function name using SymFromAddr(). 我正在尝试使用SymFromAddr()将地址解析为可读的函数名称。 It seems to work fine if I have symbols for the given module stored locally, however I'd like it to automatically download them from the path given to SymInitialize, just like WinDbg does it. 如果将给定模块的符号存储在本地,这似乎很好用,但是我希望它可以像从WinDbg一样,从提供给SymInitialize的路径中自动下载它们。 I call SymInitialize like that: 我这样称呼SymInitialize:

SymInitialize(procHandle, "SRV*c:\\symbols*http://msdl.microsoft.com/download/symbols;http://mycustomstore.com/symbols", TRUE);

SymFromAddr returns error 487 "Attempt to access invalid address." SymFromAddr返回错误487“试图访问无效地址。” as it can't find the symbol since it has never even attempted to download it. 因为它从未尝试下载该符号,所以找不到该符号。

Is there any way to force download them? 有什么方法可以强制下载它们?

As it turned out dbghelp.dll needs symsrv.dll in order to load symbols. 事实证明,dbghelp.dll需要symsrv.dll才能加载符号。 It was struggling to find it, so needed a bit of help. 很难找到它,因此需要一些帮助。 I've used dbghelp logging to help track down the issue https://msdn.microsoft.com/en-us/library/ms680687.aspx 我使用dbghelp日志记录来帮助跟踪问题https://msdn.microsoft.com/zh-cn/library/ms680687.aspx

If you want to use a HTTP symbol store, you define it with 如果要使用HTTP符号存储,请使用

.sympath SRV*c:\mysymbols*http://example.com/symbols

To add the Microsoft symbol path, use 要添加Microsoft符号路径,请使用

.symfix+ c:\microsoftsymbols

Looking at the WinDbg symbol path now gives you: 现在查看WinDbg符号路径将为您提供:

0:000> .sympath
srv*c:\mysymbols*http://example.com/symbols;SRV*c:\microsoftsymbols*http://msdl.microsoft.com/download/symbols

which tells us that your symbol path was not correct, since it didn't have the second SRV*...* part but just http://... . 告诉我们您的符号路径不正确,因为它没有第二个SRV*...*部分,而只有http://... If you copy/paste the symbol path from your code to WinDbg, it probably wouldn't work as well. 如果将符号路径从代码复制/粘贴到WinDbg,则可能无法正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM