如何在 WinDbg 中设置符号? [英] How to set up symbols in WinDbg?

查看:46
本文介绍了如何在 WinDbg 中设置符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Windows 调试工具,但出现以下错误启动 WinDbg/cdb 或 ntsd 时的消息:

I am using Debugging Tools for Windows and I get the following error message when starting WinDbg / cdb or 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. *
****************************************************************************

在执行任意命令时,我也收到错误信息

When executing arbitrary commands, I also get the error message

*** 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 来查找符号?

How do I set up WinDbg to find the symbols?

免责声明:这是对.

Disclaimer: This is intended to be a canonical question to all the wrong symbols posts in windbg.

推荐答案

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

Symbols can be set up correctly in various different ways.

警告:此处的示例使用 \serversymbols,它通常是不可用的网络存储.将其调整到您的本地服务器,或者如果您没有,则完全保留该部分.不存在的服务器可能会导致延迟等.

WARNING: The examples here use \serversymbols which is typically a network storage that is not available. Adapt it to your local server or leave that part out completely if you don't have one. A non-existent server may cause delays etc.

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

Create a new folder c:symbols for symbols provided by Microsoft. Then type

.symfix+ c:symbols
.reload

(或 reload -f 如有必要)

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

Make sure you have an Internet connection, since this will contact some Microsoft servers and download symbols from there.

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

In 80+% of the cases, this might already solve your symbols problem. If not, read on.

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

WinDbg will look for symbols in the order they appear in the symbol path. Therefore it's a good idea to put your local symbols first, then some company local network share and then download symbols from the Internet and store a copy locally.

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

通过菜单修复符号

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

Fixing symbols by menu

In WinDbg (but not the command line equivalents) you can set a symbol path by File/Symbol File Path... or pressing Ctrl+S. You enter it in the following format

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

通过命令行修复符号

WinDbg 还采用 -y 命令行开关,如果您更喜欢使用不同符号路径设置的不同桌面链接.

Fixing symbols by command line

WinDbg also takes the -y command line switch if you prefer having different desktop links with different symbol path setups.

WinDbg -y "<symbol path>"

注意这里需要完整的路径,格式类似于

Note that you need the complete path here, which is in a form like

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

通过环境变量修复符号

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

Fixing symbols by environment variable

There is a environment variable called _NT_SYMBOL_PATH which can be set to a symbol path as well. Use the following syntax:

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

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

Note that not only WinDbg evaluates this variable, but also Visual Studio, Process Explorer, Process Monitor and potentially other software. You may experience performance impact setting this environment variable.

如果您有一个相当复杂的符​​号设置,其中包括多个路径,请熟悉 WinDbg 工作区的概念.

If you have a rather complex symbol setup which includes several paths, become familiar with the concept of WinDbg workspaces.

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

Workspaces allow you to save the symbol path so you don't have to re-type all the commands in every debugging session.

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

Once you're satisfied with the workspace, create a link for WinDbg to include -Q which means " Suppress the annoying "Save workspace?" question".

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

So far I'm very happy having save the symbols as part of the Base workspace.

延迟符号(在 lm 命令中如此表示)不是问题.WinDbg 将在需要时加载它们.要强制加载所有这些,请键入

Deferred symbols (indicated as such during a lm command) are not a problem. WinDbg will load them whenever needed. To force loading all of them, type

ld*

调试符号问题

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

Debugging symbol issues

If the symbols (PDBs) do not work as expected, use the

!sym noisy

获取有关解析符号时 WinDbg 究竟在做什么的更多信息.

to get more information about what WinDbg is exactly doing when resolving symbols.

找到解决方案后,使用

!sym quiet

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

To check individual symbols for correctness, you can use the symchk tool which comes with WinDbg.

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,它更容易使用

or get ChkMatch which is a bit easier to use

ChkMatch -c <exe file> <pdb file>

如果您无法从网络共享访问符号,请确保您之前登录到网络共享.AFAIR,WinDbg 不要求提供凭据.

If you have trouble accessing symbols from a network share, make sure you logged on to the network share before. AFAIR, WinDbg does not ask for credentials.

使用 Microsoft 符号服务器获取调试符号文件(应该 重定向到这里但重定向目前已被破坏)

Use the Microsoft Symbol Server to obtain debug symbol files (should redirect here but redirection is currently broken)

Windows 调试器的符号路径

这篇关于如何在 WinDbg 中设置符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆