我使用这篇文章中的答案 ( Using GDB to debug an MPI program in Fortran ) 在我的 Mac 上调试 MPI Fortran 程序。我尝试实现 Vladimir F 给出的答案。但是,之后:
gdb -pid <the_pid_you_got_from_getpid>
调试器打开,我收到以下消息:
warning: unhandled dyld version (15)
0x00007fffb6f2ef46 in ?? ()
And when I tried:
(gdb) info locals
我收到“没有可用的符号表信息”
。结果我无法将 gdb 附加到正在运行的进程。
我正在使用 MacOS 10.12 (Sierra)、gdb 8.0,并使用为 ifort 配置的 mpif90(版本:17.0.4)进行编译。
对于我的问题可能是什么原因有什么想法吗?
最佳答案
如果您不太热衷于 gdb(事实上,gdb 在 mac 操作系统中作为默认工具链的一部分已被弃用),您可以使用 lldb。
因此,对于这样的代码:
program main
use mpi
integer error
integer id
integer p
call MPI_Init ( error )
call MPI_Comm_size ( MPI_COMM_WORLD, p, error )
call MPI_Comm_rank ( MPI_COMM_WORLD, id, error )
write (*,*) 'Hello: ', id, '/', p
call MPI_Finalize ( error )
stop
end
和这样的编译
mpif90 -g -o fort ./fort.f90
您应该能够按照以下方式启动 lldb
mpirun -np 2 xterm -e lldb ./fort
这将为您提供两个独立的 xterm,并运行 lldb
请注意,对于 xterm,您需要安装 XQuartz ( https://www.xquartz.org )
更新:
我不确定这是否有助于解决这个特定问题,但您始终可以尝试从源代码编译 GDB。请参阅此处了解如何操作的说明: Building GDB on macOS Sierra
然后,您可以使用 xterm 和 gdb 以及您的 MPI 代码运行 mpirun,如下所示
mpirun -np 2 xterm -e gdb ./mpi_sample
现在,您可以看到 dyld 版本仍然存在警告,但代码似乎工作正常。
但是,问题仍然是,ifort 编译的代码会发生什么:( 在我的例子中,我使用的是:
mpifort --version
GNU Fortran (GCC) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gdb --version
GNU gdb (GDB) 8.0
Copyright (C) 2017 Free Software Foundation, Inc.
mpirun --version
mpirun (Open MPI) 2.0.2
关于debugging - 使用 GDB 在 Fortran 中调试 MPI 程序(在 MAC 上),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44831138/