18

When I was about to debug C++ program in VS2005,the program didn't stop at the breakpoints.

The VS said"No symbols are loaded for any call stack frame. The source code cannot be displayed".

What can I do?

Steve Rowe
  • 19,411
  • 9
  • 51
  • 82
MainID
  • 29,070
  • 19
  • 57
  • 70
  • Are you debugging an exe or a dll? – Steve Rowe Feb 12 '09 at 09:01
  • It happened to me after accidentally killing "mspdbsrv.exe". Killing the children of devenv.exe is a method I use sometimes to stop monstruos builds, when "Cancel build" is unresponsive. – Liviu Sep 08 '14 at 13:32
  • 1
    Try to find out if ANOTHER INSTANCE (e.g. Release Version of your application) is running in Background! – Erdinc Ay Apr 21 '15 at 17:09

8 Answers8

20

Thanks to everybody.

Finally,I found a solution here.

To enable debugging:

1) Goto Project->HelloWorld Properties

2) On the left expand "Configuration Properties"

3) Expand "C/C++"

4) On the left, Select "General"

5) On the right, change "Debug Information Format" to "Program Database For Edit And Continue (/ZI)"

5) On the left, Select "Optimization"

6) On the right, change "Optimization" to "Disabled (/Od)"

7) On the left, expand "Linker"

8) On the left, select "Debugging"

9) On the right, change "Generate Debug Info" to "Yes"

10) Click ok

11) Set your breakpoints

12) Rebuild your application

Also when running your application use Ctrl+F5 to build and run it, this keeps the console window open long enough for you to see your output.

MainID
  • 29,070
  • 19
  • 57
  • 70
4

A few steps to try:

  1. Debug->Step Into (this will ensure you stop right after you start)
  2. Debug->Windows->Modules
  3. Look for your foo.exe on the list.
  4. Check Symbol Status. Does it say it is loaded?
  5. If not, go to the path and ensure that: a) there is a file called foo.pdb there b) the timestamp on foo.pdb matches foo.exe (or is really close)
Steve Rowe
  • 19,411
  • 9
  • 51
  • 82
3

For whatever reason you don't have the right symbols (.pdb files) in the symbol path. This could be for several reasons:

1) Your binary was compiled more recently than the .pdb files. Try recompiling everything.

2) You are trying to debug a .dll and forgot to copy the .pdb files. Copy those files too.

It's also possible that your code isn't being executed like you think.

G S
  • 35,511
  • 22
  • 84
  • 118
Steve Rowe
  • 19,411
  • 9
  • 51
  • 82
1

It sounds like you're attaching to a process rather than running a conventional debug session? If you are indeed attaching to a process, it is important to ensure that binaries that you are trying to debug were built with the same source code currently open in your IDE.

jpoh
  • 4,536
  • 4
  • 35
  • 60
  • Wrong source code should still break, just at strange places in the source. If there is no break, it's probably a symbol issue, not a source code issue. – Steve Rowe Feb 12 '09 at 09:00
  • if the sourcecode isn't identical to the source it won't break (i have noticed this behaviour on my own) –  Feb 12 '09 at 09:11
1

Complete clean and rebuild, making sure .pdb's get created?

annakata
  • 74,572
  • 17
  • 113
  • 180
0

Just to add another possibility not yet covered by MainID:

When debugging, I actually started some program that would call into the classes I wanted to debug (it's some sort of add on). The called program is partly written in unmanaged C++. When I checked "Enable unmanaged code debugging" the error would come up (and subsequently the program crashed) because the program did not have any debug information.

mort
  • 12,988
  • 14
  • 52
  • 97
0

I have solved this problem in WP7 by doing this:

  1. Right click the project from Solution Explorer (Ctrl+W+S)
  2. Select Rebuild.
  3. Again, select the project, right click it and choose Deploy.
  4. Start Debugging (F5)

I hope it will help you!

Simon MᶜKenzie
  • 8,344
  • 13
  • 50
  • 77
0

I've experienced this problem (using c# in VS) when trying to debug my unit tests.

You can add the following code that will launch a new instance of the debugger that will allow you yo step through your code like normal:

System.Diagnostics.Debugger.Launch();
System.Diagnostics.Debugger.Break();
Stephen Curial
  • 1,686
  • 15
  • 14