How to set up symbols in WinDbg?

Symbols can be set up correctly in various different ways.

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.

TLDR version for 80% of the cases

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

.symfix+ c:\symbols
.reload

(or reload -f if necessary)

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

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

Fixing symbols by commands

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

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

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

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

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.

Saving the symbol path as part of a workspace

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.

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

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

Deferred symbols

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*

Debugging symbol issues

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

!sym noisy

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

When you found the solution, turn it off with

!sym quiet

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

or get ChkMatch which is a bit easier to use

ChkMatch -c <exe file> <pdb file>

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.

Official documentation

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

Symbol path for Windows debuggers

Leave a Comment