Overview of Debugging
Go Up to Debugging Applications Index
RAD Studio 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.
The integrated debuggers let you find and fix both run-time errors and logic errors in your RAD Studio 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.
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 Through Code
Stepping through code lets you run your program one line of code at a time. After each step, you can examine the state of the program, view the program output, modify program data values, and continue executing the next line of code. The next line of code does not execute until you tell the debugger to continue.
The Run Menu provides the Trace Into and Step Over commands. Both commands tell the debugger to execute the next line of code. However, if the line contains a function call, Trace Into executes the function and stops at the first line of code inside the function. Step Over executes the function, then stops at the first line after the function.
The Evaluate/Modify functionality allows you to evaluate an expression. You can also modify a value for a variable and insert that value into the variable. Evaluate/Modify is customized for the language you are using:
- For a C++ project, the Evaluate/Modify dialog accepts only C++ expressions.
- For a Delphi project, the Evaluate/Modify dialog accepts only Delphi expressions.
Breakpoints pause program execution at a certain point in the program or when a particular condition occurs. You can then use the debugger to view the state of your program, or step over or trace into your code one line or machine instruction at a time. The debugger supports four types of breakpoints:
- Source breakpoints pause execution at a specified location in your source code.
- Address breakpoints pause execution at a specified memory address.
- Data breakpoints allow you to pause execution when memory at a particular address changes. Data breakpoints are automatically disabled when a debugging session ends, because the address of a variable can change from one debug session to the next. To re-use a data breakpoint during a subsequent debugging session, you need to re-enable the data breakpoint after your debugging session begins.
- Module load breakpoints pause execution when the specified module loads.
For information about creating, modifying and persisting breakpoints, see Setting and Modifying Breakpoints.
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.
You can monitor your watch items in the Watch List Window.
The following debug windows are available to help you debug your program. By default, most of the windows are displayed automatically when you start a debugging session. You can also view the windows individually by selecting View > Debug Windows.
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.
Displays all of the breakpoints currently set in the Code Editor or CPU window.
Displays the current sequence of function calls.
Displays the current value of watch expressions based on the scope of the execution point.
Displays the current function's local variables, enabling you to monitor how your program updates the values of variables as the program runs.
Displays 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.
Displays 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.
Displays messages that pertain to process control, breakpoints, output, threads, and module.
Displays the low-level state of your program, including the assembly instructions for each line of source code and the contents of certain registers.
Displays the contents of the Floating-point Unit and SSE registers in the CPU.
Set 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:
- Choose either of the following:
- In the Set Debug Desktop dialog box, click the down-arrow and select the layout you want to be the Debug Desktop.
- Click OK.
Remote debugging lets you debug an application running on a remote computer. Your computer must be connected to the remote computer through TCP/IP.
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.
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.
- 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.
For more details, see Debugging Multi-Device Applications.
- Debugger Options
- Debugging Multi-Device Applications
- Overview of Remote Debugging
- Starting the Debugger
- Preparing a Project for Debugging
- Setting and Modifying Breakpoints
- Adding a Watch
- Modifying Variable Expressions
- Inspecting and Changing the Value of Data Elements
- Debugging Remote Applications
- Attaching to a Running Process
- Ending a Debug Session