您可以在Fortran中使用lldb。舉一個例子程序。
PROGRAM test
IMPLICIT NONE
INTEGER :: i
INTEGER, DIMENSION(10) :: array
DO i = 1, 10
array(i) = i
END DO
END PROGRAM
可以在LLDB
$ lldb -- test
(lldb) target create "test"
Current executable set to 'test' (x86_64).
(lldb) b test.f:9
Breakpoint 1: where = test`test + 17 at test.f:9, address = 0x0000000100000eac
(lldb) run
Process 869 launched: '/Users/mark/Desktop/test' (x86_64)
Process 869 stopped
* thread #1: tid = 0xb5f5, 0x0000000100000eac test`test + 17 at test.f:9, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100000eac test`test + 17 at test.f:9
6 INTEGER, DIMENSION(10) :: array
7
8 DO i = 1, 10
-> 9 array(i) = i
10 END DO
11
12 END PROGRAM
(lldb) c
Process 869 resuming
Process 869 stopped
* thread #1: tid = 0xb5f5, 0x0000000100000eac test`test + 17 at test.f:9, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100000eac test`test + 17 at test.f:9
6 INTEGER, DIMENSION(10) :: array
7
8 DO i = 1, 10
-> 9 array(i) = i
10 END DO
11
12 END PROGRAM
(lldb) c
Process 869 resuming
Process 869 stopped
* thread #1: tid = 0xb5f5, 0x0000000100000eac test`test + 17 at test.f:9, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100000eac test`test + 17 at test.f:9
6 INTEGER, DIMENSION(10) :: array
7
8 DO i = 1, 10
-> 9 array(i) = i
10 END DO
11
12 END PROGRAM
(lldb) c
Process 869 resuming
Process 869 stopped
* thread #1: tid = 0xb5f5, 0x0000000100000eac test`test + 17 at test.f:9, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100000eac test`test + 17 at test.f:9
6 INTEGER, DIMENSION(10) :: array
7
8 DO i = 1, 10
-> 9 array(i) = i
10 END DO
11
12 END PROGRAM
(lldb) p array
(int [11]) $0 = ([0] = 1, [1] = 2, [2] = 3, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0, [10] = 0)
(lldb)
運行此有一點需要注意。 lldb本身並不理解Fortran,但仍然可以使用C等價物。例如,如果你想檢查FORTRAN數組索引array(3)
你需要使用C相當於具有C或C++相當於將工作
(lldb) p array[2]
(int) $1 = 3
(lldb)
一切的。派生類型將像結構體一樣行事...所有常規的lldb命令都可以工作。您可以更改堆棧幀。你可以設置中斷點,你可以按步驟說明等等,它們都可以正常工作。
難道你不需要爲gcc-fortran安裝一些調試軟件包嗎? –