Veryfing symbols after upload to SymbolSource

Although with the release of NuGet integration uploading symbols and sources to SymbolSource became a matter of simply invoking one command, it is still possible to mix up packages and end up uploading binaries and symbols that do not match. SymbolSource will of course verify the integrity of an incoming package, but there is no way for it to stop you from uploading a package to with different binaries.

This post will show you how to quickly verify that symbols can be downloaded for a given set of binaries.

You will need to set up a few things first:

  1. Download Debugging Tools from the Windows SDK - run the SDK web installer and select Debugging Tools for Windows under Common Utilities to download and install just the bits that you will need.

  2. Prepare two directories - the first one with all the binaries that you will be verifying (e.g. Z:\Binaries) and a second one as a cache for downloaded symbols (e.g. Z:\Symbols).

    The binary directory will be searched recursively, so you can extract many packages into separate subdirectories. Make sure there are no PDB files present.

  3. Open a command prompt and add Debuggin Tools to your PATH variable to make things easier:

    set PATH=%PATH%;C:\Program Files\Debugging Tools for Windows (x64)

Now you can do the actual verification:

  1. Run symchk.exe on the entire binary directory:
    symchk.exe Z:\Binaries /su "SRV*Z:\Symbols*" /oi /op /r
  2. If everything goes well, this will result in output similar to the following:
    SYMCHK: Orchard.Core.dll          PASSED  - PDB: Orchard.Core.pdb          DBG: <N/A>
    SYMCHK: Orchard.exe               PASSED  - PDB: Orchard.pdb               DBG: <N/A>
    SYMCHK: Orchard.Framework.dll     PASSED  - PDB: Orchard.Framework.pdb     DBG: <N/A>
    SYMCHK: Orchard.WarmupStarter.dll PASSED  - PDB: Orchard.WarmupStarter.pdb DBG: <N/A>
    SYMCHK: FAILED files = 0
    SYMCHK: PASSED + IGNORED files = 4
  3. Most often you will see these two types of errors:
    SYMCHK: FluentNHibernate.dll FAILED  - FluentNHibernate.pdb mismatched or not found
    SYMCHK: FluentNHibernate.xml IGNORED - Not an executable file (file does not have a DOS header)
  4. When you do come across a failure, it's worth investigating with the following command:
    symchk.exe Z:\Binaries\FluentNHibernate.dll /su "SRV*Z:\Symbols*" /v
  5. In verbose mode symchk.exe will output a lot of information about the symbol loading process, among which will be lines like the following:
    DBGHELP: Symbol Search Path: SRV*Z:\Symbols*
    DBGHELP: No header for Z:\Binaries\FluentNHibernate.dll.  Searching for image on disk
    DBGHELP: Z:\Binaries\FluentNHibernate.dll - OK
    SYMSRV:  Z:\Symbols\FluentNHibernate.pdb\01D37CC489F649B89A1122C482A574CB1\FluentNHibernate.pdb not found
    SYMSRV: not found
    This shows clearly that a PDB for the given DLL wasn't found on SymbolSource.

A quick reference to symchk.exe options

The meaning of the symchk.exe switches that were used in the examples is the following:

/suSearch the following symbol path and always update.
/rScan the directory recursively for binaries.
/oiAdditionally list files that were ignored.
/opAdditionally list files that passed verification.
/opVerbose mode. Inform about every action taken.

Ideas for improvements

If you have any ideas how this process could be improved, please share them with us. One possibility is to wrap symcheck.exe and nuget.exe into a script that would just take a package name and version and output a yes/no result. Perhaps there are other ways?

Posted by Marcin Mikołajczak (TripleEmcoder) on Saturday, May 14, 2011

blog comments powered by Disqus