Visual Studio 2010 debugger build correctly - compiler pdb and linker pdb not in synch?

10,104

Solution 1

Solution is very simple.

  • Just Exclude the file from the project (the one for which checksum issue occured).

  • Include the same file again in project

  • Rebuild whole project

Thast it. I hope this will resolve your problem. SAM

Solution 2

The problem isn't with the pdb it's that the VS isn't correctly detecting when modules should be re-compiled.

More specifically, I have a source-controlled code base that is tested via a suite of unit tests.

The unit tests are keyed off of a main file, say MainTest.cpp, which has the int main(...) function that launches all of the tests. This is just a glue file and rarely changes. The files that change often are the test classes it imports.

Now, all my test classes are "header-less" i.e. all definitions/declarations are contained within one module (such as TestClass1.cpp, TestClass2.cpp, etc...) mainly because they're just tests and I don't want the extra clutter.

The problem is that when I make changes to TestClass1.cpp and build, VS 2010 doesn't deem it necessary to re-build MainTest.cpp saying:

Skipping... (no relevant changes detected) MainTest.cpp

Apparently this is a known issue, see:

http://connect.microsoft.com/VisualStudio/feedback/details/99825/code-change-in-header-does-not-re-compile-correctly

To correctly build, I have to force VS to re-compile MainTest.cpp. As a workaround, I put a "touch MainTest.cpp" in my project's Pre-Build Event.

Some follow-up questions:

  1. Does MS intend to fix this? If so, have they?
  2. Is there a better workaround?

Solution 3

Excluding the file from the project and then including it again collowed by a project compile is the only solution that worked. Thanks to SAM. I am writing so as to document potential solutions and to show this suggestion was the most effective.

The following often suggested solutions did not work:

  1. Manually compiling all the .cpp files in the project using right click in the solution explorer.
  2. Touching Main.cpp (running: touch main.cpp) or any/all of project files, then rebuilding project.
  3. Resetting the project settings (inside tool-> Import and Export Settings) and the recompiling the project.
Share:
10,104
user635242
Author by

user635242

Updated on June 05, 2022

Comments

  • user635242
    user635242 almost 2 years

    I have a solution in MS VS 2010 that compiles and builds properly after a rebuild all (1). However, after I make a change to a source file and begin debugging, VS recognizes the project is out of date and builds the project (2) successfully (as expected).

    The problem is that it seems VS begins debugging the project using obj/pdb/etc.. from (1) above instead of (2). If I break into the debugger and navigate to the module that changed in the file of interest, I'm told "the source file is different from when the module was built". Indicating I don't want to rebuild the source, I'm given the following info below: (Note that in order to get a "good" build I have to rebuild the solution (or delete vc100.pdb)).


    Locating source for "file of interest". Checksum: MD5 {59 96 7d 1 9f b 33 20 63 4c 81 1d d7 c6 94 30}

    Determining whether the checksum matches for the following locations: 1: "file of interest" Checksum: MD5 {61 66 43 cb d1 97 d1 d5 0 dc 9b 60 64 71 b2 b6} Checksum doesn't match. The file "file of interest" exists.

    Looking in script documents for "file of interest"...

    Determining whether the checksum matches for the following locations:

    1: "file of interest" Checksum: MD5 {61 66 43 cb d1 97 d1 d5 0 dc 9b 60 64 71 b2 b6} Checksum doesn't match.

    Looking in the projects for "file of interest".

    The file was not found in a project.

    Looking in directory

    .

    misc directories

    .

    The debugger will ask the user to find the file: "file of interest".

    The user pressed Cancel in the Find Source dialog. The debug source files settings for the active solution have been modified so that the debugger will not ask the user to find the file: "file of interest".

    The debugger could not locate the source file "file of interest".


    At this point the debugger recognizes the pdb hashes are out of synch even though compiler/linker failed to recognize this earlier. Everything works correctly after a rebuild but doesn't seem to build itself correctly after a change to a source file.

    It seems that a "rebuild" properly builds both vc100.pdb and debugger pdb while a "normal" build only only touches the compiler/linker vc100.pdb...but I'm not positive.

    Anyone have any ideas?

    Thanks,

    Paul

  • user635242
    user635242 over 12 years
    I also want to note that VS 2005 detected these conditions correctly. My solution broke after importing to VS 2010.
  • zhangxaochen
    zhangxaochen over 8 years
    This doesn't work for me... is it a bug of vs2010? My No Source Available page info is: codepad.org/g2mul655