C++Introduction to C++Language FeatureLearn C++

How To Make Use Of The Powerful Watch List in C++ Builder

How To Make Use Of The Powerful Watch List in C++ Builder

What is Debugging? in fact, what is a bug? How can I debug in the C++ compiler? Is there An Example of how to use Watches? How can I see Watch List Window? How can I add a watch to the Watch List?

What is Debugging?

As we mentioned in another article here on debugging: debugging is the process of finding and resolving bugs in your software applications or hardware systems. Bugs are defined as defects or problems that prevent correct operation in a running system or application.

Many programming languages and software development tools also offer programs to aid in debugging, known as debuggers. Many different Integrated Development Editors (IDEs) in C++ provides very professional techniques and methods to debug applications in different conditions. Debugging involves interactive debugging, control flow analysis, unit testing, integration testing, log file analysis, monitoring at the application or system level, memory dumps, and profiling.

RAD Studio, C++ Builder provides an integrated debugging environment that enables you to debug multi-device applications as well as native Win32 applications. In addition, you can use the debugger to debug an application running on a remote machine that does not have RAD Studio installed.

What is the C++ Builder Debug Inspector?

The Debug Inspector enables you to examine various data types such as arrays, classes, constants, functions, pointers, scalar variables, and interfaces. To use the Debug Inspector, select Run > Inspect.

This video demo of the debugger is a helpful overview.

  • Stepping – Step by Step Debugging Through Code
  • Evaluate/Modify – Investigate Expressions
  • Breakpoints – Pause and Check
  • Watches – Tracking Values
  • Exceptions – Displaying the stack trace

Is there a C++ example to test watches?

1. Let’s create a new VCL Windows application in C++ Builder

2. Add two button Button1 and Button2 onto Form

3. Press F12 to switch codes and add int x =0; global variable.

4. Press F12 again and double click to Button1 and double click to Button2 to create OnClick events

5. Modify codes as below

As you see we create a simple application that sets global x variable to 100 when pressed Button1 and to 200 when pressed Button2. Now let’s see how we watch this variable.

How do I track values with the RAD Studio Watch List Windows?

Watches let you track the values of program variables or expressions as you step over or trace into your code. As you step through your program, the value of the watch expression changes if your program updates any of the variables contained in the watch expression. We can monitor your watch items in the Watch List Window.

View > Debug Windows > Watch List

Displays the current value of the watch expression based on the scope of the execution point. The Watch List window is a multi-tabbed view with each tab representing a distinct watch group. Only the watch group on the active tab is evaluated while debugging.

Tip: To enable or disable a watch expression quickly, use the check box  next to the watch.

Note: The in-place editors on the Watch List window are now clickable dropdown lists. In addition to typing new values in the in-place editors (such as Watch Name), you can also select from values that were entered in this field previously or on other Debug windows.

ItemDescription
Watch NameShows the expression entered as a watch.
ValueLists the current value of the expression entered. precedes the value if an external-viewer debugger visualizer is available to display the data. Click the down-arrow to select from the available external-viewer visualizers.

Note: If the execution point moves to a location where any of the variables in an expression is undefined (out of scope), the entire watch expression becomes undefined. If the execution point reenters the scope of the expression, the Watch List window displays the current value of the expression.

Tip: By grouping watches, you can prevent out of scope expressions from slowing down stepping.

  1. If we back to our example we can add a new Watch by the right click in the Watch List Window. If there is no Watch List Window you can make it visible from the View->Debug Windows->Watches … menu or by clicking ctrl+alt+W.
  2. From the menu select “Add Watch…”

Now we can add x variable as below to watch list. Press OK to finish.

4. Now add a break to the end of Button1Click() by clicking the right side of the code line

5. Add another break to the end of Button2Click() by clicking right side of the code line

6. Now you can run your application in the Run with Debug mode by the button or pressing F9.

What other things can we do with the RAD Studio Watch List?

Right-click the Watch List window to display the following commands:

ItemDescription
Edit WatchDisplays the Watch Properties dialog box, on which you can modify the properties of a watch.
Add WatchDisplays the Watch Properties dialog box, on which you can create a watch.
Enable WatchEnables a disabled watch expression.
Disable WatchDisables a watch expression and so that it is not monitored as you step through or run your program. The watch settings remain defined. Disabling watches improves debugger performance.
Delete WatchRemoves a watch expression. This command is not reversible.
Copy Watch ValueCopies the text in the Value column of the selected watch to the clipboard.
Copy Watch NameCopies the text in the Watch Name column of the selected watch to the clipboard.
Enable All WatchesEnables all disabled watch expressions.
Disable All WatchesDisables all enabled watch expressions.
Delete All WatchesRemoves all watch expressions.
Add GroupDisplays a dialog box, allowing you to name a watch group and add it to the watch list as a new tab.
Delete GroupDeletes a watch group from the watch list.
Move Watch to GroupMoves one or more selected watches to another watch group.
InspectDisplays the selected watch item in the Debug Inspector.
Evaluate/ModifyDisplays the selected watch item in the Evaluate/Modify dialog box.
VisualizersEnabled when an external-viewer type debugger visualizer is available to display the selected data in a more human-readable way. To display the visualized data, click a submenu item (such as Show Strings for the TStringList visualizer).
New WatchCreates a new watch item from the selected item. This command is enabled for all items except top-level items.
Stay On TopKeeps the window visible when out of focus.
Show Column HeadersToggles the display of the Watch Name and Value column titles.
DockableEnables drag-and-dock for the Watch List window.

C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, MacOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs.

There is a free C++ Builder Community Edition for students, beginners, and startups; it can be downloaded from here. For professional developers, there are Professional, Architect, or Enterprise versions of C++ Builder and there is a trial version you can download from here.

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++11C++14C++17C++20

What Is The Stack (std::stack) In Modern C++?

C++C++11C++14C++17C++20Learn C++

What Is The Queue (std::queue) In Modern C++?

C++C++11C++14C++17Learn C++SyntaxTemplates

What Are The Logical Operation Metafunctions In Modern C++?

C++C++14C++17C++20Learn C++

What Are The Deprecated C++14 Features In C++17?