April 27th, 2005

Setting up Visual Studio 2005 to Download Debug Symbols

Heath Stewart
Principal Software Engineer

In Getting Debug Symbols even for Retail Builds I detailed how to set up your machine and Visual Studio .NET to download public symbols from Microsoft’s symbol server. This process has changed for Visual Studio 2005 Beta 2.

When debugging your projects it’s often helpful or even necessary to see the functions in the call stack. Without symbols, a simple application using EnumWindows might yield the following call stack:

enumwins.exe!EnumWindowsProc(HWND__ * hwnd=0x00490098, long lParam=0)
user32.dll!77d4ccd1()
[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]
user32.dll!77d4cdad()
enumwins.exe!main(int argc=1, char * * argv=0x00850d88)
enumwins.exe!mainCRTStartup()
kernel32.dll!7c816d4f()
kernel32.dll!7c8399f3()

When symbols are loaded along with their respective modules, the call stack is more helpful:

enumwins.exe!EnumWindowsProc(HWND__ * hwnd=0x00490098, long lParam=0)
user32.dll!_InternalEnumWindows@24()
user32.dll!_EnumWindows@8()
enumwins.exe!main(int argc=1, char * * argv=0x00850d88)
enumwins.exe!mainCRTStartup()
kernel32.dll!_BaseProcessStart@4()

In Visual Studio .NET 2002 and 2003 you would configure each Visual C++ project using the project properties dialog with a semi-colon-delimited list of symbol paths. In Visual Studio 2005 you configure this in the global options dialog.

  1. Click the Tools menu.
  2. Click the Options… menu item.
  3. Expand the Debugging node.
  4. Click on the Symbols node.
  5. Use the familiar Add toolbar button to add a location which may include URLs, shares, and symbol server locations.

You can configure multiple symbol paths and manage them – including enabling and disabling paths – from this property page. Check “Load symbols using the updated settings when this dialog is closed” (checked by default) to immediately load symbols for loaded modules when you click the OK button. Note that in windbg.exe, this is equivalent to using .reload /f.

For all of Visual Studio .NET 2002 and 2003, and Visual Studio 2005 you can also tell the debugger to resolve function addresses to DLL exports by clicking on the Native node instead of the Symbols node in step 4 above, and checking “Load DLL exports”. This is disabled by default because of overhead when reading the DLL export table. This will only work for exported functions, however, which makes symbols a richer option.

Author

Heath Stewart
Principal Software Engineer

Heath is an application architect and developer, looking to help educate others to learn professional development. Besides designing and developing applications he enjoys writing about intermediate and advanced topics. Heath also consults for deployment packages and scenarios within Microsoft and for external customers.

0 comments

Discussion are closed.