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

查看:354
本文介绍了如何在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?

免责声明:这是针对发布的标准问题rel =tag> windbg

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.

警告:这里的示例使用 \\server\symbols 通常是不可用的网络存储。将其适配到您的本地服务器,或者如果没有,请将其完全保留。不存在的服务器可能会导致延迟等。

WARNING: The examples here use \\server\symbols 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.

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

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

.symfix+ c:\symbols
.reload

(或 reload -f 如有需要)

确保您有互联网连接,因为这将联系一些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+ \\server\symbols ; *** Symbols provided from a network share
.symfix+ c:\symbols ; *** Microsoft symbols



按菜单修正符号



在WinDbg(但不是等效命令行)中,您可以通过文件/符号文件路径... 或按 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;\\server\symbols;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;\\server\symbols;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;\\server\symbols;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 workspace。

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.

当您找到解决方案时,请使用

When you found the solution, turn it off with

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

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 Symbol Server获取调试符号文件(应该重定向到这里,但重定向是目前已损坏)

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

Windows调试器的符号路径

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

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