Does That PDB File Match the Binary?

4 Comments June 28, 2011

While you should always have your PDB files in symbol servers, there are times when you’re doing private (aka local) builds and moving those builds around hither and yon in a test environment where you can accidentally forget to copy over a binary’s PDB file. That leads to the common question: short of starting a debugger, how can I check that a PDB file matches a particular binary?

Obviously you can always take an educated guess if a PDB file matches a binary from the timestamp. That will work in most cases, but to completely check, you’ll need to rely on SYMCHK.EXE, a command line tool that comes with the Debugging Tools for Windows (AKA WinDBG). The trick is to tell SYMCHK.EXE to use the PDB file directory as your symbol server. In the following example, I’m running the SYMCHK.EXE command from the same directory where my binary, RinjPlay.exe is located.

symchk RinjPlay.exe /s .\

If the PDB matches the binary, you’ll see the following output.

SYMCHK: FAILED files = 0

SYMCHK: PASSED + IGNORED files = 1

If the PDB does not match, your output will look like the following.

SYMCHK: RinjPlay.exe        FAILED   - RinjPlay.pdb mismatched or not found

SYMCHK: FAILED files = 1

SYMCHK: PASSED + IGNORED files = 0

As with any SYMCHK.EXE command, you can pass /v to get detailed output about your binary and PDB file matching.


4 Comments

  • Gravatar Image
    Jason Haley June 28, 2011 6:54 AM

    Interesting Finds: June 28, 2011

  • Gravatar Image
    zenwalker June 28, 2011 9:45 AM

    Wow really good info there. Thanks :)

  • Gravatar Image
    Dave Black July 28, 2011 9:39 AM

    Hi John,
    I've written an assembly and .pdb inspector that extracts the GUIDS (among many other things), that allows you to visually compare the PDB GUID to see if it matches. Hopefully, I'll have it "polished enough" for posting on my blog and probably on CodePlex in the next month or two. If you're interested, I'll ping you back and give you the URL.
    Let me know.

  • Gravatar Image
    Andrei Zavidei September 28, 2011 10:54 AM

    Hi John,
    Thanks for your posts about debugging! I think they are really helpful.
    Wanted to share another method of how to detect PDB file mismatch. It is possible to do with 'dumpbin.exe' utility that comes with Visual Studio. The trick is simple: use /PDBPATH option (http://msdn.microsoft.com/en-us/library/44wx0fef.aspx) with dumpbin utility in the same folder where binary and PDB reside. The result will be like this:
    >> dumpbin /PDBPATH:VERBOSE wargame.exe
    Microsoft (R) COFF/PE Dumper Version 8.00.50727.762
    Copyright (C) Microsoft Corporation. All rights reserved.
    Dump of file wargame.exe
    File Type: EXECUTABLE IMAGE
    PDB file 'C:\Users\Andrew\Development\EclipseWorkspace\wg2k\dist\wargame.pdb' checked. (PDB age mismatch)
    p.s.
    I have also found another utility that can do the trick:
    http://www.debuginfo.com/tools/chkmatch.html
    Best Regards,
    Andrei

Have a Comment?

Archives