Click here to Skip to main content
Click here to Skip to main content
Go to top

How to use symbol server? (and why you really like to do it...)

, 13 Jan 2012
Rate this:
Please Sign up or sign in to vote.
How to setup .NET symbol server and enable production debugging without source code

Introduction

While working on some project, we ran into a problem when some infrastructure code was separated from our solution and encapsulated into a sort of 3rd party dll. The problem was that when trying to debug this external dll, the debugger tried to look for the source code in a specific path – the path where the original source code was at the time of the compilation.

This is obviously a big problem –
1. When working with teams in different geographies, where each team is working on the same code but, but each team using a different development server
2. In production – you want to be able to debug you application with source code, without relying on the initial location of the source code

This post will concentrate on how to create PDB objects, objects used by the compiler to debug and find the source code, in a way it will look for the source code from a source control (TFS) instead of source files. You will see that these steps are really easy to follow (especially if you have already TFS and build configuration), so you can implement them in your project immediately.

This post is a compilation of many other interesting posts about this topic (see resources section at the end). it's intended to be short and to the point, to help your projects to become more "debuggable" with the least of efforts.

Thanks a lost for all the articles' authors - John Robbins, Cameron Skinner, and Ed Blankenship.

Background

John Robbins did already a great work on describing what is a PDB file and how the debugger looks for PDB files in his must-read post.

To sum up, a PDB consists of information used by the debugger to perform it work. A .NET PDB contains two pieces of information, the source file names and their lines and the local variable names. The rest of the data, is already in the .NET metadata (e.g. public, private and static addresses, global variable names and addressses and more).

The debugger uses the name of the file and a GUID that's embedded in both the PDB file and the binary to look for the correct PDB version.

Using the code

In order to enable source control PDB, you need to follow these steps:

  1. Create a public build definition for you project (I won’t go on the general details of public build definition in post, but you can look for it here (look for the Build support section).
  2. Create a shared folder to be used as a drop folder. Drop folder is where the DLL’s and PDB’s will be placed by the public build. These DLL’s will be referenced in your code.
  3. Create a shared folder that will be used as you symbol server. A symbol server is a centralized place where your PDB’s will reside along with the required source information.
  4. Update the definition to use the drop location folder:
    drop_folder.png
  5. Update the definition and set the path to publish symbols. This step does two things – both set the PDB location in the symbol server, AND, does something called source indexing, which create the mapping between the source code and source version. In order to do that, simply copy your symbol server UNC here:symbol_server.png
  6. That’s it – you are done with the definition of your public build. Now you need to actually build it, and prepare your client to work with the symbol server.

Now, How to debug with a symbol server?

  1. Make sure to reference the DLL’s from the drop location. You don’t have to reference the drop location directly, you can copy them to any folder you like. Make sure to check-in the external DLL’s and PDB’s along with your solution.
  2. In VS, go to DebugàOptions and Settings .... this will open the debugging sections in the setting dialog box.
  3. Go to the “Symbols” option, and add your symbol server (please note you may have several, each for each project , or one centralized). To do that, simply click the folder icon right in the top of the screen. At the end, it should look like:
    symbol_server_vs_setup.png
  4. Go to the “general” option, and make sure to enable source server support:
    enable_source_server_setup.png
  5. Now, you are ready to go and debug your third party code without having access to the source code. When you debug, you will face the following dialog when stepping in the 3rd party code:


The message above will appear for every new file the debugger need to source. If you don’t like that, create a file called SRCSRV.ini, place it in the <Visual Studio Install Directory>\Common7\IDE folder, and fill it with the following text:

[trusted commands]
tf.exe=<Visual Studio Install Directory>\Common7\IDE\tf.exe  

And that's it!

Points of Interest

Please note that if you follow these steps, you don't need to actually deploy the PDB files along with your code. TFS embed a unique GUID in the DLL file and the matching PDB file. Using the symbol server the information above, the debugger knows to lookup the correct PDB.

Pretty slick, ha?

Resources

What a developer need to know on PDB:
http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/05/11/pdb-files-what-every-developer-must-know.aspx

How to configure your own symbol server, and how to debug in production:
http://blogs.msdn.com/b/camerons/archive/2011/04/06/debugging-series-symbols-server-and-your-symbols.aspx
http://blogs.msdn.com/b/camerons/archive/2011/04/01/debugging-series-symbol-server.aspx

How to set symbol server in VS:
http://www.visualstudiotutor.com/2011/02/configure-setup-symbol-server-with-visual-studio/

How to disable the dialog box of source files
http://www.wintellect.com/CS/blogs/jrobbins/archive/2011/02/12/disabling-the-visual-studio-source-server-security-warning-dialog.aspx

PDB, TFS, and retention policy
http://www.edsquared.com/2011/02/12/Source+Server+And+Symbol+Server+Support+In+TFS+2010.aspx

Hard core symbol servers
http://msdn.microsoft.com/en-us/magazine/cc301459.aspx

History

January 12 - First revision.
January 13 - Added resources

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

baruchl
Team Leader Intel
Israel Israel
I've been around at Intel for about 13 years, developing and leading SW information system projects.
 
I have extended experience in .NET (C#) and SQL development.
 
I'm currently located at OR for a 2Y assignmentOur current development environment is .NET 4.0 and SQL2008, we are using WPF 4.0 for UI, EF4 for data manipulation and WCF 4.0 for communicating from the client to the server.
 
Love design patterns and cool looking code.
 
Motto: "Are we having fun or what?"

Comments and Discussions

 
GeneralMy vote of 5 Pinmemberjawed.ace23-May-13 18:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 13 Jan 2012
Article Copyright 2012 by baruchl
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid