Visible to Intel only — GUID: GUID-85CD2951-F0C6-4BCB-961F-9CA3A315BB6E
Visible to Intel only — GUID: GUID-85CD2951-F0C6-4BCB-961F-9CA3A315BB6E
Use Breakpoints in the Debugger
This topic applies to Fortran applications for Windows only.
This topic describes how to use the Microsoft Visual Studio* debugger to set file and data breakpoints. Information is organized as follows:
In addition to file and data breakpoints, the Visual Studio* debugger supports the following:
Address breakpoints
Function breakpoints
Tracepoints
For information on these additional features, see the Microsoft documentation for your version of Visual Studio*.
View All Current Breakpoints
You can view all currently set breakpoints in the Breakpoints window. To view all set breakpoints using the Breakpoints window:
In the Debug menu, select Windows > Breakpoints.
Scroll up or down in the Breakpoints list to view the breakpoints. Enabled breakpoints have a check mark in the check box and disabled breakpoints have an empty check box. The window displays all types of breakpoints.
Use File Breakpoints
Use a file breakpoint to interrupt program execution when the program reaches a specified location within a file. Several symbols are used to show the status of file breakpoints; these appear in the left margin of the Source window:
Enabled file breakpoints are identified as a red circle. |
|
Disabled file breakpoints are identified as a hollow circle in the left margin. |
|
During debugging, a currently active breakpoint appears as a red circle containing a yellow arrow in the left margin of the Source window. |
For a walk-through of a sample debugging session using file breakpoints, see Debugging the Squares Example Program.
To set (enable) a file breakpoint:
Open the desired source file in the solution.
In the Source window, click the line at which you want to enable a file breakpoint.
Do one of the following:
Click in the left margin of the line or press the F9 key. When you set a breakpoint, it is enabled by default.
Right click on the desired line and select Insert Breakpoint from the pop-up menu.
To disable a file breakpoint:
In the Source window, click the line containing the file breakpoint you want to disable.
Do one of the following:
Right click on that line, and select Disable Breakpoint from the pop-up menu.
In the Debug menu, select Windows > Breakpoints, which opens the Breakpoints window. Select the check box for that breakpoint so it is unchecked (disabled).
To remove a file breakpoint:
In the Source window, click the line containing the file breakpoint you want to remove.
Do one of the following:
Click in the left margin of the line or press the F9 key. If the breakpoint was originally disabled, press F9 again to remove it.
Right click on that line, and select Delete Breakpoint from the pop-up menu.
In the Debug menu, select Windows > Breakpoints. In the Breakpoints window, select the breakpoint in the Name column and click the Delete button (which looks like an "X").
To view the source code where a file breakpoint is set:
In the Debug menu, select Windows > Breakpoints.
In the Breakpoints window, click a file breakpoint.
Click the Go To Source Code button.
This action takes you to the source code for a breakpoint set at a line number or function (or subroutine) name. In the case of function (or subroutine) names, the debugger must be running for this to work.
To remove all breakpoints (including data breakpoints):
In the Debug menu, select Delete All Breakpoints.
Add Conditions to File Breakpoints
When you associate a condition with a file breakpoint, the program executes until that location is reached and the specified condition is met, such as when the value of an array element is greater than 1.
To add a condition to a breakpoint:
Set a file breakpoint.
Right-click in the associated line and select Breakpoint > Condition....
The Breakpoint Condition dialog box appears.
The condition that you specify in the Breakpoint Condition dialog box must relate to a local variable within the breakpoint's scoping unit, or to a global variable. You must apply proper Fortran syntax in the Condition field in order for the specified condition to be properly detected. Consider the following examples:
To break when the local variable RecNum reaches a value of 7520, enter the following condition:
RecNum == 7520
You can also specify joint conditions. To break when RecNum reaches at least 7520 and the variable Var2 is equal to 90, enter the following condition:
RecNum >= 7520 .and. Var2 == 90
You can also specify an or condition. For example:
Var1 == 3.14 .or. Var2 < 500.0
If the condition that you specify occurs at the chosen location when the program is run, a message box appears. If the breakpoint is set in part of a loop, continuing execution proceeds until the debugger detects another specified condition. If no such condition is detected, the debugger continues to the next breakpoint or, if no more breakpoints are set, until the end of the loop.
To disable, enable, or remove a file breakpoint with a defined condition, follow the general procedures for a file breakpoint. Use the checkbox for the Condition field to enable or disable the condition setting.
Use Data Breakpoints
Use a data breakpoint to interrupt program execution when the value of a certain variable changes. A data breakpoint displays a message box when the value of a variable changes, or, if a condition has been defined, when a condition is met. Unlike a file breakpoint, data breakpoints are not associated with a specific source location.
Use Visual C++ Data Breakpoint Support
The Visual Studio* IDE does not provide data breakpoint support specifically for Fortran, but you can still use data breakpoints in a Fortran program; they are handled using the existing mechanism provided by Microsoft Visual C++*. This means that you must use Visual C++* syntax; you cannot enter the variable name or condition using Fortran syntax. The following guidelines apply:
For scalar variables, enter the variable name in upper case. This allows Visual C++* to find the variable in the debug information and apply the correct breakpoint.
For arrays and types, use the Fortran LOC intrinsic function in a Watch window or the Immediate window to obtain the address of the variable. Use this address in the variable name edit box.
For example, to prepare to set a data breakpoint at an array element a(5), do the following:
Select Debug > Windows > Immediate.
Enter loc(a(5)) in the immediate window and press Enter.
The result displayed is the address of the array element. The address may be displayed as a decimal number or a hexadecimal number, depending upon your current display mode. For a decimal number, you will enter it in the Address: field. For a hexadecimal number, you will use the Visual C++* hexadecimal syntax (0xnnnnnnnn) rather than the Fortran syntax (#nnnnnnnn) in the fields.
The following procedure applies to debugging the current routine (current scope).
To set a data breakpoint:
Start debugging.
In the Debug menu, select New Breakpoint > New Data Breakpoint...
Enter the desired address. Also enter the Byte Count and Language (specify C++).
If you want to associate a condition with this breakpoint, right-click on the breakpoint in the Breakpoints window and choose Condition...
To disable, enable, or remove a data breakpoint:
In the Debug menu, select Windows > Breakpoints.
To disable or enable the data breakpoint, use the check box to the left of the data breakpoint (check indicates enabled).
To remove a data breakpoint, select the data breakpoint and click the Delete button.
Under certain conditions, the debugger may disable a data breakpoint. In this case, you should either try to enable it or remove and set it again.
To remove all breakpoints (including file breakpoints):
In the Debug menu, select Delete All Breakpoints.