在Mac OS上使用gdb进行Fortran调试? [英] Fortran debugging with gdb on Mac OS?

查看:556
本文介绍了在Mac OS上使用gdb进行Fortran调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题调试Fortran程序在Mac OS Mountain Lion与gdb。当我调用

I have problems debugging Fortran programs on Mac OS Mountain Lion with gdb. When I invoke

gdb (fortran executable name)

从终端,我收到以下消息:

from a terminal, I get the following message:

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正在路径(/ Users / fx / ...)中搜索一堆不存在的对象文件。

Basically, gdb is searching for a bunch of object files in paths (/Users/fx/...) that do not exist.

除此之外,调试器似乎工作正常。有人知道如何解决这个问题?

Other than that, the debugger seems to be working fine. Does anyone know how can I fix this?

一个附注,gdb在C程序上工作正常。 C和Fortran编译器运行平稳; gcc被包含在Xcode命令行工具中,而gfortran是从单独的源(路径:/ usr / local / bin / gfortran)安装的。

A a side note, gdb works fine on C programs. Both C and Fortran compilers run smoothly; gcc was included in Xcode command line tools, while gfortran was installed from a separate source (path: /usr/local/bin/gfortran).

我试图读几个其他答案,但没有人似乎匹配这个问题。

I tried to read several other answers but no one seemed to match this issue.

推荐答案

您可以在Fortran中使用lldb。举个例子。

You can use lldb with Fortran. Take an example program.

      PROGRAM test

      IMPLICIT NONE

      INTEGER                :: i
      INTEGER, DIMENSION(10) :: array

      DO i = 1, 10
         array(i) = i
      END DO

      END PROGRAM

您可以在lldb中运行此功能

You can run this in 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等价物

There is one caveat. lldb doesn't understand Fortran natively but you can still use the C equivalents. For instance if you want to inspect the fortran array index array(3) you need to use the C equivalent of

(lldb) p array[2]
(int) $1 = 3
(lldb)

具有C或C ++等价物的所有内容都可以正常工作。派生类型将像structs等一样运行。所有常规的lldb命令都可以正常工作。您可以更改堆栈帧。你可以设置断点,你可以步骤说明等等,这一切都会奏效。

Everything that has a C or C++ equivalent will work. Derived types will act like structs, etc... All the regular lldb commands will work. You can change stack frames. You can set break points, you can step instructions, etc... it will all just work.

这篇关于在Mac OS上使用gdb进行Fortran调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆