Show: Delphi C++
Display Preferences

Overview of Debugging

From RAD Studio XE3
Jump to: navigation, search

Go Up to Debugging Applications Index

RAD Studio includes a Win32 Debugger. The IDE automatically uses the appropriate debugger based on the active project type. Cross-platform debugging within a project group is supported and, where possible, the debuggers share a common user interface.

The integrated debuggers let you find and fix both runtime 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.

Contents

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.

Evaluate/Modify

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. The Evaluate/Modify functionality 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

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 available only for the Win32 debugger. 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

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.

Debug Windows

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.

Debug Window Description

Breakpoint List

Displays all of the breakpoints currently set in the Code Editor or CPU window.

Call Stack

Displays the current sequence of function calls.

Watch List

Displays the current value of watch expressions based on the scope of the execution point.

Local Variables

Displays the current function's local variables, enabling you to monitor how your program updates the values of variables as the program runs.

Modules

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.

Threads

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.

Event Log

Displays messages that pertain to process control, breakpoints, output, threads, and module.

CPU Windows Index

Displays the low-level state of your program, including the assembly instructions for each line of source code and the contents of certain registers.

FPU

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 (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.

Remote Debugging

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 old-style 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.

Cross-Platform Debugging

Cross-platform debugging involves the use of a target platform that is not the native 32-bit Windows. You must install and run the Platform Assistant on the target machine and create a working remote profile on the development system. For more details, see Debugging Cross-Platform Applications.

See Also

Personal tools
Previous Versions
In other languages