无法在 GDB 中提取发生 FPE 的值

Unable to extract in GDB the values where FPE is occuring

我采纳了这个问题 Gfortran does not tell me what sort of FPE it is 的评论中给出的建议,即启动 GDB ,在该行设置断点并检查操作的值。一开始我的程序是基于 Fort运行 77 代码(我计划在 运行 完成这个 "test case" 一个理想的 CFD 数据测试后将它迁移到 F90)并在 Ubuntu 16.04 LTS。我使用 gfort运行 4.8.5 编译器(如果需要可以升级到 5.x)。

程序是这样编译的

gfortran -Wall -O0 -c -g -fbacktrace -ffpe-trap=invalid,denormal,zero,overflow,underflow ${tool}.f ${ncdf_incs}

现在我在程序所在的目录中启动gdb然后我输入

break inv_cart.f:1221

这是 FPE 发生的地方(除以零错误)。当我这样做时,我收到这条消息 -

  Make breakpoint based on future shared library load (y/n) ?

所以我搜索了这个问题并且我之前得到了这个 Q/A - How to set breakpoints with shared libraries 这就是我所做的

set breakpoint pending on
break inv_cart.f:1221

更新

我有一个疏忽。在我 运行 中断后,我收到此错误消息

No symbol table is loaded. Use the "file" command
Breakpoint 1 (inv_cart.f:1221) is pending. 

更新结束

在我这样做之后,我得到了与我在 gdb 中 运行 inv_cart 或独立时得到的相同的错误。

Program received signal SIGFPE - arithmetic exception

后跟内存地址和几个问号,后跟 ()。 所以我退出 gdb 然后它告诉我有一个调试会话仍然处于活动状态。

所以我的问题仍然存在 - 如何获取发生 FPE 的值?

这是更新后的一个简单问题,我已经注意到了。

我查了这个问题 - gdb no symbol table is loaded 然后我继续做了

file inv_cart 

最后符号 table 被加载,令我高兴的是我通过 gdb 再次 运行 程序并且能够打印发生 FPE 的代码段的值。