See what's going on with flipcode!




This section of the archives stores flipcode's complete Developer Toolbox collection, featuring a variety of mini-articles and source code contributions from our readers.

 

  Advanced MSVC++ Breakpoints
  Submitted by



Most people know how to use standard Location breakpoints (in MSVC) where you put a breakpoint on a given line of code, and when executed, the debugger activates. The problem with Location breakpoints is that you may not always know the general location that a problem is occurring. In that case you can use something called a When breakpoint. A When breakpoint consists of a code statement, which, when it changes or becomes true activates the debugger and shows you exactly where it occurred.

So, for example, let's say you have a memory overflow due to a pointer error where int Var1, which is equal to 235, is being overwritten to some other value. You most likely won't know where in your code this is occurring so you can use a When breakpoint. When the When breakpoint changes or becomes true (depending on how you write it), the debugger will activate and show you the exact line that the memory overflow is happening.

Now, to set a When breakpoint, in MSVC++ simply go to Edit->Breakpoints and switch to the Data tab. Here you can enter the expression to break on. For example, you could just write "Var1" which will break whenever Var1 changes, or you could write "Var1 != 235" which will break when Var1 is not equal to 235. You can also click the arrow button on the right side of the dialog box to set the scope of the breakpoint.

There are all kinds of advanced breakpoints you can set using this technique, so if you need help, just search for "when breakpoints" in the MSVC++ file.

I haven't had to use these very often, but they've definitely saved my life a couple of times. Enjoy stomping those bugs just a little bit easier.


The zip file viewer built into the Developer Toolbox made use of the zlib library, as well as the zlibdll source additions.

 

Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
Please read our Terms, Conditions, and Privacy information.