Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
216 views
in Technique[技术] by (71.8m points)

breakpoints - Why does Visual Studio 2008 skip over my break points?

I am running Visual Studio 2008 with SP1. When I debug an application, it will skip over my break points.

For example, I have two lines of code, each call a method. I will put a break point on both lines. I will run it one time, and it ill stop at the first break point, but not the next one. I will run it again, and it ill hit the second one, not the first one.

I have tried to clean the solution and a rebuild.

I do have multiple projects in the solution.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Symbol file incompatibility

It's possible that your symbol file (.pdb) is out of sync with your source code. A common symptom of this is:

  • Stopping at a breakpoint on a line of code
  • Stepping through the code
  • Seeing the debugging pointer stop at a blank line of code

When debugging, you should never see the debugging pointer stop on a blank line, and this would indicate that you have a symbol/source mismatch somewhere.

This sort of mismatch could also cause breakpoints to be skipped like you are seeing, but cleaning the solution generally fixes it (and it sounds like you have tried this already).

Build configuration

The other option (as suggested by others) is that you aren't building a Debug configuration. While it is possible to debug a Release build, the code is significantly optimised which can make the debugger act strangely, e.g.

  • Stepping through a conditional (i.e. if block) can make it appear that both the if and else cases are running
  • Some bits of code are completely optimised out, and you can't break on them

What are you trying to break on?

One other important thing to note is that breakpoints cannot be set on every line of code. For example, if your code only has a variable initialisation:

long numObjects;

the breakpoint will generally not be set properly (although it will usually move to the next line of "real" code). However, if your line of code initialises the variable:

long numObjects = 5;

the breakpoint can be set.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...