# Saturday, 08 July 2006

Conditional breakpoints are cool when you know the value of one variable that is associated with trouble: this only blows up when Xid is 1234. They can also be used to reduce the boredom of single stepping. Say you've got some loop that goes around a few hundred times building up some string or array or something. You don't want to keep going round and round and round... it would be nice to jump ahead to halfway through, for example, and see how things are looking. Now if this is a for loop with a handy named variable, say

for (int i = 0; i<1000; i++)

Then you can use a conditional breakpoint and say "stop when i is 200". Or you could be clever and stop when i % 200 is 0 -- so that's every 200 times. But what if there's no i? What if you're going through a file or a recordset/dataset/resultset and you're going until the end? You don't want to add some fake variable that gets incremented each time through the loop, just so you can set a breakpoint that breaks on certain values of that variable. Instead you want to use the hit count property of the breakpoint. Just right click the red dot and choose Hit Count. There you can set the breakpoint to break whenever it's hit, just the 10th time it's hit, every tenth time (10, 20, 30 etc) or every time after the 10th time Or, of course, whatever number you want instead of 10:

Don't debug the slow way when there are tools to make you so much faster!

Kate

Saturday, 08 July 2006 16:53:13 (Eastern Daylight Time, UTC-04:00)  #    Comments [3]
Sunday, 16 July 2006 10:13:29 (Eastern Daylight Time, UTC-04:00)
In the last few daya I can't read your posts without manually scrolling horizontally on every line of print. I have tried both IE6 and FireFox.
bosco
Sunday, 16 July 2006 11:36:45 (Eastern Daylight Time, UTC-04:00)
The scrolling is because of some wide pictures in a debugging post or two. On my screen the posts just fit but the blue sidebar on the right is scrolled off. If your screen is narrower, I suggest clicking the comments link on an individual post -- the resulting page will show only one post and probably won't include the wide picture.

Kate
Kate
Sunday, 27 July 2008 09:22:11 (Eastern Daylight Time, UTC-04:00)
Hi,
After writing a post on my blog, I came across your post through google. I use hit count breakpoints in far too many ways. My post http://www.technochakra.com/debugging-using-breakpoint-hit-count-for-fun-and-profit/ has some more ways which I thought you may find useful.
Comments are closed.