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

This Is How to Debug C++ Builder Mobile And Desktop Projects

This Is How to Debug C++ Builder Projects

What is Debugging? What is a bug? How can I debug in C++ Builder?

What is Debugging?

Debugging is the process of finding and resolving bugs – unwanted or unplanned behavior – in your software applications or hardware systems. Bugs are defined as defects or problems that prevent the correct or intended 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++ provide very professional methods to debug applications. 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.

RAD Studio, C++ Builder includes integrated debuggers for every supported target platform. The IDE automatically uses the appropriate debugger based on the active project type. Debugging is supported for multi-device applications within a project and, where possible, the debuggers share a common user interface.

What does an integrated debugger do?

The integrated debuggers let you find and fix both run-time errors and logic errors in your RAD Studio C++ or Delphi application. Using the debuggers, you can step through code, set breakpoints and watches, and inspect and modify program values. As you debug your application, the debug windows are available to help you manage the debug session and provide information about the state of your application. There is a very detailed debugging methods are officially released here.

What is the difference between debug and release mode?

When applications that you develop can be compiled in two different types, Release and Debug mode. Debug mode is used when we develop application. Release mode is generally used only when we release and deploy the final executable application. A professional programmer mostly develops in debug mode although, for some big changes they will often swap to test the final application in release mode. Debug mode adds extra code and data to allow the debugger to do its work and map parts of the executable application’s internal runtime compiled output to lines of your program. It also includes in extra checks and balances to help detect difficult to find bugs such as ‘stack overflow’ errors and similar. Debug mode programs are optimized to help make the debugging process as powerful and useful as possible. Release mode doesn’t include the extra data to make the debugger work and is optimized for size and pure execution speed to ensure the final release of your programs is as fast and efficient as possible.

All this means that a program compiled in Debug should not normally be the version you finally send to your users except under quite narrow sets of circumstances such as trying to get the customer to reproduce a bug or crash which will then display additional helpful information from the extra debug release’s information.

How can I debug my programs in C++ Builder?

To debug your application first be sure that your application is set Build Configuration in Projects Window to Debug mode. This will allow you debug your application in details.

Now, we can use debug configuration, we should just run with debugging mode by pressing this Run with Debugging button or press F9 key.

Note that your projects options changes in Release and Debug configurations. Generally most options are same in Release and Debug configurations, although the two sets of project options – release and debug – can be completely different if you want them to be. Be sure that your project options are suitable to your debugging setup.

What is the 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

What are the RAD Studio Debug Windows and how can I use them?

Each window provides one or more right-click context menus. The F1 Help for each window provides detailed information about the window and the context menus.

Debug WindowDescription
Breakpoint ListDisplays all of the breakpoints currently set in the Code Editor or CPU window.
Call StackDisplays the current sequence of function calls.
Watch ListDisplays the current value of watch expressions based on the scope of the execution point.
Local VariablesDisplays the current function’s local variables, enabling you to monitor how your program updates the values of variables as the program runs.
ModulesDisplays processes under control of the debugger and the modules currently loaded by each process. It also provides a hierarchical view of the namespaces, classes, and methods used in the application.
Thread StatusDisplays the status of all processes and threads of execution that are executing in each application being debugged. This is helpful when debugging multi-threaded applications. For Windows Vista, the Threads Status includes a Wait Chain column that lists thread blockages and deadlocks.
Event LogDisplays messages that pertain to process control, breakpoints, output, threads, and module.
CPU Windows IndexDisplays the low-level state of your program, including the assembly instructions for each line of source code and the contents of certain registers.
FPUDisplays the contents of the Floating-point Unit and SSE registers in the CPU.

What is the Debug Desktop?

The Debug Desktop is the layout that the IDE uses when you are running your application in Debug mode (by pressing F9 in the default key mapping). There is a default Debug Desktop, but you can alternatively select any of the saved desktops to be the Debug Desktop.

To set the Debug desktop:

  1. Choose either of the following:
  2. In the Set Debug Desktop dialog box, click the down-arrow and select the layout you want to be the Debug Desktop.
  3. Click OK.

What is remote debugging?

Remote debugging lets you debug an application running on a remote computer – a different one to the computer on which you are running RAD Studio. Your computer must be connected to the remote computer through a TCP/IP network connection.

Two remote debugging solutions are now available:

  • The new remote debugging solution is also used for multi-device debugging.
  • The old-style remote debugging solution required that you install a remote debugger on the remote machine. After you create and copy the required application files to the remote computer, you can connect to the remote computer and begin debugging.

Note: The old-style debugging solution does not apply to multi-device applications.

What is Multi-Device debugging?

Multi-device debugging involves the use of a target platform that is not the native 32-bit Windows. Your interaction with the debugger is virtually the same with multi-device debugging as it is with Windows debugging.

How do I debug macOS, iOS and Android mobile apps?

  • For the macOS and iOS platforms, you must install and run the Platform Assistant on the target machine and create a working connection profile on the development system.
  • For Android applications, you do not use the Platform Assistant or a connection profile, but you must download the USB driver for your Android device, enable USB debugging, and add an Android SDK to RAD Studio.

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.

close

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

33+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux and some other operating systems. Dr. Yilmaz Yoru was born in 1974, Eskisehir-Turkey. He graduated from the department of Mechanical Engineering of Eskisehir Osmangazi University in 1997. One year later he started to work in the same university as an assistant. He received his MSc and PhD degrees from the same department of the same university. He has married and he is a father of a son. Some of his interests are Programming, Thermodynamics, Fluid Mechanics and Artificial Intelligence. He also likes the graphical 2D & 3D design and high-end innovations.
Related posts
Artificial Intelligence TechC++Introduction to C++Learn C++

How To Make A Simple But Powerful Chat Bot In C++

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

How To Operate On The Words In A String In C++

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

What Is The Best C++ Compiler for Windows 10?

C++Language FeatureLearn C++

How To Make An MSIX Windows Installer Package

en_USEnglish