Fortran 简明教程
Fortran - Debugging Program
调试工具用于在程序中搜索错误。
A debugger tool is used to search for errors in the programs.
调试程序逐步执行代码,并允许您在程序执行期间检查变量和其他数据对象中的值。
A debugger program steps through the code and allows you to examine the values in the variables and other data objects during execution of the program.
它加载源代码,您需要在调试器中运行该程序。调试器通过以下方式调试程序:
It loads the source code and you are supposed to run the program within the debugger. Debuggers debug a program by −
-
Setting breakpoints,
-
Stepping through the source code,
-
Setting watch points.
断点指定程序应停止的位置,尤其是在关键代码行之后。程序执行会在断点处检查变量之后。
Breakpoints specify where the program should stop, specifically after a critical line of code. Program executions after the variables are checked at a breakpoint.
调试程序按行检查源代码。
Debugger programs also check the source code line by line.
监视点是需要检查某些变量的值的点,特别是在读或写操作之后。
Watch points are the points where the values of some variables are needed to be checked, particularly after a read or write operation.
The gdb Debugger
gdb 调试器,GNU 调试器随 Linux 操作系统提供。对于 X 窗口系统,gdb 带有一个图形界面,程序名为 xxgdb。
The gdb debugger, the GNU debugger comes with Linux operating system. For X windows system, gdb comes with a graphical interface and the program is named xxgdb.
下表提供了一些 gdb 中的命令−
Following table provides some commands in gdb −
Command |
Purpose |
break |
Setting a breakpoint |
run |
Starts execution |
cont |
Continues execution |
next |
Executes only the next line of source code, without stepping into any function call |
step |
Execute the next line of source code by stepping into a function in case of a function call. |
The dbx Debugger
Linux 中还有另一个调试器 dbx 调试器。
There is another debugger, the dbx debugger, for Linux.
下表提供了一些 dbx 中的命令 −
The following table provides some commands in dbx −
Command |
Purpose |
stop[var] |
Sets a breakpoint when the value of variable var changes. |
stop in [proc] |
It stops execution when a procedure proc is entered |
stop at [line] |
It sets a breakpoint at a specified line. |
run |
Starts execution. |
cont |
Continues execution. |
next |
Executes only the next line of source code, without stepping into any function call. |
step |
Execute the next line of source code by stepping into a function in case of a function call. |