gpt4 book ai didi

debugging - 如何在WinDbg中设置符号?

转载 作者:行者123 更新时间:2023-12-03 02:02:12 25 4
gpt4 key购买 nike

我正在使用Debugging Tools for Windows启动 WinDbg/cdb 或 ntsd 时收到以下错误消息:

Symbol search path is: *** Invalid ***
****************************************************************************
* Symbol loading may be unreliable without a symbol search path. *
* Use .symfix to have the debugger choose a symbol path. *
* After setting your symbol path, use .reload to refresh symbol locations. *
****************************************************************************

执行任意命令时,我也会收到错误消息

*** ERROR: Module load completed but symbols could not be loaded for <module>.<ext>

以下内容似乎相关:

*********************************************************************
* Symbols can not be loaded because symbol path is not initialized. *
* *
* The Symbol Path can be set by: *
* using the _NT_SYMBOL_PATH environment variable. *
* using the -y <symbol_path> argument when starting the debugger. *
* using .sympath and .sympath+ *
*********************************************************************

!analyze -v 中我也看到了

DEFAULT_BUCKET_ID:  WRONG_SYMBOLS

*************************************************************************
*** ***
*** Either you specified an unqualified symbol, or your debugger ***
*** doesn't have full symbol information. Unqualified symbol ***
*** resolution is turned off by default. Please either specify a ***
*** fully qualified symbol module!symbolname, or enable resolution ***
*** of unqualified symbols by typing ".symopt- 100". Note that ***
*** enabling unqualified symbol resolution with network symbol ***
*** server shares in the symbol path may cause the debugger to ***
*** appear to hang for long periods of time when an incorrect ***
*** symbol name is typed or the network symbol server is down. ***
*** ***
*** For some commands to work properly, your symbol path ***
*** must point to .pdb files that have full type information. ***
*** ***
*** Certain .pdb files (such as the public OS symbols) do not ***
*** contain the required information. Contact the group that ***
*** provided you with these symbols if you need this command to ***
*** work. ***
*** ***
*************************************************************************

如何设置 WinDbg 来查找符号?

免责声明:这是对 中所有错误符号帖子的规范问题。 .

最佳答案

可以通过各种不同的方式正确设置符号。

警告:此处的示例使用 \\server\symbols,它通常是不可用的网络存储。将其适应您的本地服务器,或者如果您没有本地服务器,则完全忽略该部分。不存在的服务器可能会导致延迟等。

适用于 80% 情况的 TLDR 版本

为 Microsoft 提供的符号创建一个新文件夹 c:\symbols。然后输入

.symfix+ c:\symbols
.reload

(或如果需要的话reload -f)

确保您有 Internet 连接,因为这将联系一些 Microsoft 服务器并从那里下载符号。

在 80% 以上的情况下,这可能已经解决了您的符号问题。如果没有,请继续阅读。

通过命令修复符号

WinDbg 将按照符号在符号路径中出现的顺序查找符号。因此,最好先放置本地符号,然后是一些公司本地网络共享,然后从 Internet 下载符号并在本地存储副本。

.sympath c:\mysymbols ; *** Symbols of your application, locally, flat list of PDB files
.sympath+ cache*c:\symbolcache ; *** (optional) Create a cache for everything
.sympath+ \\server\symbols ; *** Symbols provided from a network share
.symfix+ c:\symbols ; *** Microsoft symbols

通过菜单修复符号

在 WinDbg(但不是命令行等效项)中,您可以通过 File/Symbol File Path... 或按 Ctrl+S 设置符号路径。您按以下格式输入

c:\mysymbols;cache*c:\symbolcache;\\server\symbols;SRV*c:\symbols*http://msdl.microsoft.com/download/symbols

通过命令行修复符号

如果您希望使用具有不同符号路径设置的不同桌面链接,WinDbg 还可以使用 -y 命令行开关。

WinDbg -y "<symbol path>"

请注意,您需要此处的完整路径,其形式如下

c:\mysymbols;cache*c:\symbolcache;\\server\symbols;SRV*c:\symbols*http://msdl.microsoft.com/download/symbols

通过环境变量修复符号

有一个名为_NT_SYMBOL_PATH的环境变量,它也可以设置为符号路径。使用以下语法:

c:\mysymbols;cache*c:\symbolcache;\\server\symbols;SRV*c:\symbols*http://msdl.microsoft.com/download/symbols

请注意,不仅 WinDbg 会评估此变量,Visual Studio、Process Explorer、Process Monitor 和其他可能的软件也会评估此变量。设置此环境变量可能会影响性能。

将符号路径保存为工作空间的一部分

如果您有一个相当复杂的符​​号设置,其中包括多个路径,请熟悉 concept of WinDbg workspaces .

工作区允许您保存符号路径,因此您不必在每个调试 session 中重新输入所有命令。

一旦您对工作区感到满意,请为 WinDbg 创建一个包含 -Q 的链接,这意味着“抑制烦人的“保存工作区?”问题”。

到目前为止,我很高兴将符号保存为 Base 工作区的一部分。

延迟符号

延迟符号(在 lm 命令期间如此指示)不是问题。 WinDbg 将在需要时加载它们。要强制加载所有内容,请输入

ld*

调试符号问题

如果符号 (PDB) 未按预期工作,请使用

!sym noisy

获取有关 WinDbg 在解析符号时具体执行的操作的更多信息。

找到解决方案后,将其关闭

!sym quiet

要检查各个符号的正确性,可以使用 WinDbg 附带的 symchk 工具。

Symchk /if <exe> /s <symbol path> /av /od /pf
/if = input is a file
/s = symbol file path
/od = all details
/av = verify
/pf = check if private symbols are available

或获取ChkMatch这更容易使用一点

ChkMatch -c <exe file> <pdb file>

如果您在从网络共享访问符号时遇到问题,请确保您之前已登录到网络共享。 AFAIR,WinDbg 不要求凭据。

官方文档

Use the Microsoft Symbol Server to obtain debug symbol files (应该 redirect here 但重定向当前已损坏)

Symbol path for Windows debuggers

关于debugging - 如何在WinDbg中设置符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30019889/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com