Adding Breakpoints & Watchpoint
A breakpoint can be set on an executable line of the program. If the breakpoint is enabled when you debug, the execution will suspend before the code of that line is executed.
To add a breakpoint point, you could double-click the marker bar located in the left margin of the C/C++ Editor beside the line of code where you want to add a breakpoint. A dot will display in the marker bar and in the Breakpoints View, along with the name of the associated file.
A watchpoint is a special breakpoint that stops the execution of the program whenever the value of a given expression changes, without specifying where it might occur. Unlike breakpoints (which are line-specific), watchpoints are associated with files. They take effect whenever a specified condition is true, regardless of when or where it occurred. You can set a watchpoint on a global variable by highlighting the variable in the editor.
To set a watchpoint on a global variable, you could do as follows:
- 1. Highlight the variable in the editor.
- 2. Click Debug > Toggle Watchpoint.
- 3. Do one of the follows:
- To stop execution when the watch expression is read, select the Read check box;
- To stop execution when the watch expression is written to, select the Write check box;
- 4. The watchpoint will appear in the Breakpoints View list.