2012-12-10 90 views
2

我在使用gdb在Mac OS Mountain Lion上調試Fortran程序時遇到問題。當我從終端調用Fortran在Mac OS上使用gdb進行調試?

gdb (fortran executable name) 

,得到以下信息:

This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries. 

warning: Could not find object file "/Users/fx/devel/gcc/ibin-462-x86_64/x86_64-apple-darwin11/libgfortran/.libs/backtrace.o" 
- no debug information available for "../../../gcc-4.6.2-RC-20111019/libgfortran/runtime/backtrace.c". ... (an extremely long list of analogous warnings pop up for libgcc and libquadmath libraries) ... 

基本上,GDB正在搜索在路徑一堆對象文件(/用戶/ FX/...)那不存在。

除此之外,調試器似乎工作正常。有誰知道我該如何解決這個問題?

一個便箋,gdb在C程序上正常工作。 C和Fortran編譯器都運行平穩; gcc包含在Xcode命令行工具中,而gfortran是從一個單獨的源(路徑:/ usr/local/bin/gfortran)安裝的。

我試着讀了幾個其他的答案,但沒有人似乎匹配這個問題。

+0

難道你不需要爲gcc-fortran安裝一些調試軟件包嗎? –

回答

0

您可以在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命令都可以工作。您可以更改堆棧幀。你可以設置中斷點,你可以按步驟說明等等,它們都可以正常工作。