For many types of errors, using the Debugger can help you isolate the cause of errors. This section discusses the following topics:
Be aware that your program must use compiler options that allow the debugger to catch the appropriate error conditions:
In most cases, your program will automatically stop at the point where the exception occurs, allowing you to view the source code and values of variables. If the error is related to an I/O statement, see Viewing the Call Stack and Using the Context Menu.
Debugging an ExceptionYou can request that the program always stop when a certain type of exception occurs. Certain exceptions are caught by default by the Visual Fortran run-time library, so your program stops in the run-time library code. In most cases, you want the program to instead stop in your program's source code.
To change how an exception
is handled in the debugger:
For machine exceptions, you can use the just-in-time debugging feature to debug your programs as they run outside of the visual development environment, if both of the following items have been set:
Viewing the Call Stack and Using the Context Menu
If you want to view where in the hierarchy of routines your program in currently executing, such as after your program stops at the point where an exception occurs, you can view the Call Stack window and Context menu in the debugger:A severe unhandled I/O programming error (such as an End-of-File condition) can occur while the program is executing in the debugger. When this occurs, the Fortran run-time system will raise a debug event automatically to stop program execution, allowing display of the Call Stack Display.
When the severe unhandled I/O error occurs in the debugger:
User breakpoint called from code at 0xnnnnnnn
Click OK to dismiss the information box.
Scanning down the Call Stack display, there will be a few frames from NTDLL and the Fortran run-time system displayed, and then the actual Fortran routine with the I/O statement that caused the error. In the Context menu, select the Fortran routine to display the Fortran code. The green arrow points to the I/O statement that caused the error.
You can view the Context menu (after Context:
) to help locate the source code
line that executed the I/O statement. The Context menu appears in the top of the
Variables window (see Debugging the Squares Example Program).
Use the Context menu to select the viewing context for the routine (use the arrow
at the right to display selections).
This action all occurs after the error message and traceback information has been displayed. The error message and traceback information is available in the program output window. To view the program output window, either iconize (minimize) the visual development environment or click the icon for the output window in the task bar. You should not need the stack dump because you have the Call Stack window in the visual development environment, but the error message with the file name might be useful to see.
For more information: