在使用gdb来调试带有Ada库的C++代码时遇到了困难

bri*_*lcd 1 c++ linux gcc gdb ada

由于各种原因,我无法详细说明,但这里是我正在使用的基本架构

  • 我有一个C++框架,它使用我构建的C++目标文件来执行动态模拟.
  • C++库调用了一个用Ada编写的共享(.so)库.

据我所知,Ada库(它是一个非常重要的代码集合)在边缘情况下产生异常,但是我在隔离产生异常的函数时遇到了麻烦.

这是我正在使用的:

  • CentOS 4.8(最终版)
  • gcc 3.4.6(w/gnat)
  • gdb 6.3.0.0-1.162.el4rh

这是我在正常执行下得到的错误:

terminate called without an active exception
raised PROGRAM_ERROR : unhandled signal
Run Code Online (Sandbox Code Playgroud)

我可以让gdb在返回到C++时立即捕获异常,但是我无法让它抓住Ada代码.我已确保编译所有内容-g,但这似乎没有帮助解决问题.

当我试图捕捉/打破信号/异常gdb(礼貌告诉我Catch of signal not yet implemented)时,我明白了:

[Thread debugging using libthread_db enabled]
[New thread -1208371520 (LWP 14568)]
terminate called without an active exception
Program received signal SIGABRT, Aborted.
[Switching to thread -1208371520 (LWP 14568)]
0x001327a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
Run Code Online (Sandbox Code Playgroud)

我相信这terminate called [...]条线来自框架.当我尝试捕获那个中断,然后运行一个backtrace(bt),我得到这样的东西:

#0  0x001327a2 in gdb makes me want to flip tables.
#1  0x00661825 in raise () from /lib/tls/libc.so.6
#2  0x00663289 in abort () from /lib/tls/libc.so.6
#3  0x0061123e in __gnu_cxx: __verbose_terminate_handler () from /usr/lib/libstdc++.so.6
#4  0x0060eed1 in __xac_call_unexpected () from /usr/lib/libstdc++.so.6
#5  0x0060ef06 in std::terminate () from /usr/lib/libstdc++.so.6
#6  0x0060f0a3 in __xax_rethrow () from /usr/lib/libstdc++.so.6
#7  0x001fe526 in cpputil::ExceptionBase::Rethrow (scope=@0xbfe67470) at ExceptionBase.cpp:140
Run Code Online (Sandbox Code Playgroud)

那时,它进入了框架代码.

我已经在线阅读了几本指南,教程和手册,但我有点不知所措.我希望这里有人可以帮助我指出正确的方向.

Mar*_*c C 6

听起来你能够编译Ada源代码.假设是这种情况,在通过其执行调用异常的子程序中,在转发异常信息的末尾添加一个异常处理程序:

when E : others =>
    Ada.Text_IO.Put_Line(Ada.Exceptions.Exception_Information(E));
    raise;
Run Code Online (Sandbox Code Playgroud)

您还需要在包中添加"with"的Ada.Exceptions.和Ada.Text_IO,如果它还没有出现.

我不确定你会从那个版本的GNAT中得到什么,但它可能是你可以使用addr2line解码的调用地址.