Some of us are unaware of the relevance of proper symbols files. The symbol file is a deliverable just like the binary. Though it is not required for running the application, it is very important to debug issues which arise in production.

 

What are symbols and symbol files?

Symbols contain the mapping between the compiler-generated machine code and your source code. They help the debugger to "understand" the addresses of functions, parameters and variables and map them back to source code references. Without a proper symbol file, the debugger may present disassembly output which looks like this:

 

            call YourApp+0x11c0d (00411c0d)

 

With proper symbol resolution, the debugger can correctly interpret this machine code as the equivalent function name:

 

            call YourApp!CSampleDlg::OnBtnClicked

 

In the Visual Studio family of products, we use the PDB (Program Database) format for encoding the symbolic information into a file. Given below are the steps to generate the symbol files for various product versions. Please ensure that the PDB files generated are of the same code base as the service EXE/DLLs that are actually used in the testing. Everytime your code is rebuilt, the PDB is re-generated and has to be maintained in sync with your code base and binaries.

 

Private vs. Public symbols

Public symbol files are what you get from Microsoft for the Windows OS and other products. You can obtain public symbols for Microsoft products either by referencing the public symbol server at http://msdl.microsoft.com/download/symbols, or by downloading appropriate symbol packages from http://www.microsoft.com/whdc/devtools/debugging/default.mspx. Public symbols normally just contain:

  • Mapping from addresses to function names

  • Frame pointer omission (FPO) records

Private symbol files are the default kind of files generated by the Visual Studio linkers. These files contain the following details in addition to what the public symbols contain:

  • Line numbers and source file information

  • Parameter names and data types

  • Local variable names and data types

Normally you would want private symbol files for any detailed debugging of your own application. However, it may not be a very good idea to share your private PDB files with your end customers, since some of the information in the private PDB can be viewed as intellectual property.

 

To generate stripped / public PDB files with Visual C++, use the information in http://msdn2.microsoft.com/en-US/library/y87kw2fd.aspx for steps.

 

How to generate symbol files for Visual C++.NET 7/7.1/8.0

In these versions of VC++, a symbol file should automatically be created if you are compiling a debug build. If you are compiling a release build, then you will need to check the steps below to ensure that linker will create symbols. Please perform the symbol generation steps for each and every module in your application. If it loads other DLLs then these steps need to be done for those DLLs also.

  • Open the source code for your project.

  • Open the properties page for the project from Solution Explorer

  • View the Configuration Properties->Linker->Debugging node

  • Make sure "Generate Debug Info" is set to YES

  • Also check that the "Generate Program Database File" is set to a non-blank path

  • Rebuild the project to generate the PDB file

How to generate symbol files for Visual C#.NET 7/7.1/8.0

In VC#, a symbol file should automatically be created if you are compiling a debug build. If you are compiling a release build, the steps are given below.

  • Open the source code for your project.

  • Open the properties page for the project from Solution Explorer

  • View Configuration Properties->Build node

  • Make sure "Generate Debugging Information" is set to True.

  • Rebuild the project to generate the PDB file

How to generate symbol files for Visual Basic.NET 7/7.1/8.0

In VB.NET, a symbol file should automatically be created if you are compiling a debug build. If you are compiling a release build, the steps are given below.

  • Open the source code for your project.

  • Open the properties page for the project from Solution Explorer

  • View Configuration Properties->Build node

  • Make sure "Generate Debugging Information" is checked.

  • Rebuild the project to generate the PDB file

How to generate symbol files for Visual C++ 6.0

Important note: if you are still using VC++ 6.0, be aware that Microsoft Support will not be in a position to support you on issues concerning the product. That is because the end of support lifecycle has been reached for this version of VC++. For more information, review the details at http://support.microsoft.com/lifecycle and plan to upgrade to higher versions of VC++.NET. The information below is provided for reference only, and should not be interpreted as a sign of support!

 

In VC++ 6.0, a symbol file should automatically be created if you are compiling a debug build. If you are compiling a release build, then you will need to follow these steps to create symbols. Please perform the symbol generation steps for each and every module in your application. If it loads other DLLs then these steps need to be done for those DLLs also.

  • Open the source code for your project.

  • Select Settings from the Project menu.

  • In the Link tab, select General from the Category drop-down.

  • Check Generate Debug Info

  • In the C/C++ tab, select General from the Category drop-down.

  • Select Program Database from the Debug Info drop-down.

  • Link with /RELEASE to get a non-zero checksum.

  • Go to the Category drop-down & select Listing Files.

  • In the Listing File drop-down, select 'Assembly, Machine Code, and Source'.

  • Rebuild your project.

How to generate symbol files for Visual Basic 6.0

In VB6, symbols are not created by default. To create symbols for your VB6 applications, follow these steps:

  • Open the source code for your project.

  • Select "<projectname> Properties" from the Project menu.

  • In the Compile tab, check Create Symbolic Debug Info and select No Optimizations

  • Recompile. This will create a .PDB file (the symbols) in the same directory as your .DLL / .EXE / .OCX file.

  • Note: This does *not* break binary compatibility.