Chapter 3. Stopping and Inspecting Your Code

In This Chapter

  • Setting, enabling, and disabling breakpoints

  • Temporarily setting or disabling a breakpoint

  • Inspecting a variable

  • Watching all the local variables

  • Watching any variable

Sometimes, things break. But what we're talking about here is the code. Now this is one of those instances when a word or phrase has lots of different meanings. Programmers talk about breaking the code. This phrase usually means one of two things: It may mean that the programmer made a mistake and the code no longer works. But in this chapter, we're using a different definition for the term. When you're debugging a program, you can have the program run until it gets to a certain line in the code. The debugger then stops at that line, and you can look at the values of variables, inspect things about the code, or even change the variables. When the program stops, that's called breaking. The reason it stops on that particular line is because you put a breakpoint on that line.

In this chapter, we talk about setting and manipulating breakpoints in your code (if nothing else in your code is broken) and inspecting and modifying various aspects of your code, such as variables, after your code stops at a breakpoint.

Tip

In the examples in this chapter, we use the debugger supplied with the CodeBlocks IDE. If you use a different product, the debugger will probably work about the same but not precisely the same. For example, everything we show you how to do here you can do ...

Get C++ All-In-One For Dummies®, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.