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

我怕爱的太早我们不能终老 提交于 2020-01-04 05:29:05

问题


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


回答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




回答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?



回答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.



回答4:


I`ve found how to reproduce it

if Intermediate Directory is set to something like

$(TMP)\Build\$(SolutionName) - $(Platform).$(Configuration) - $(ProjectName)\

then linker will not see changes, but if you set it to

S:\Build\$(SolutionName) - $(Platform).$(Configuration) - $(ProjectName)\

then linking will be ok




回答5:


the problem is with th PDB file. make Clean on the project before rebuild it




回答6:


Problem occurs because of the PDB file. Clean the project and rebuild it. Or remove the file from the project and include it again and rebuild it.



来源:https://stackoverflow.com/questions/6905012/visual-studio-2010-debugger-build-correctly-compiler-pdb-and-linker-pdb-not-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!