使用dbx捕获AIX上的C++异常

Catch C++ exceptions on AIX with dbx

本文关键字:C++ 异常 上的 AIX dbx 捕获 使用      更新时间:2023-10-16

我有一个C++应用程序,它在AIX机器上为某些输入数据终止,并显示"错误分配"错误消息。

有没有一种方法可以在dbx中运行程序,并在抛出异常时捕获它?我在IBM的文档中没有看到任何关于它的内容。

如果您的C++应用程序是用XL C/C++编译的,请在__DoThrowV6上设置断点。

$ cat throw.C
int foo(int x)
{
   if (x < 0)
      throw 99;
   return x+1;
}
int main()
{
   int y;
   y = -5;
   try
   {
     foo(y);
   }
   catch(...)
   {
   }
   return 0;
}
$ xlC -g -o throw throw.C
$ dbx ./throw
Type 'help' for help.
reading symbolic information ...
(dbx) stop in __DoThrowV6
[1] stop in __DoThrowV6
(dbx) run
[1] stopped in __DoThrowV6 at 0xd1be7e00
0xd1be7e00 (__DoThrowV6)    7c0802a6        mflr   r0
(dbx) where
__DoThrowV6() at 0xd1be7e00
foo(int)(x = -5), line 4 in "throw.C"
main(), line 14 in "throw.C"
(dbx)

__DoThrowV6是在抛出异常时调用的,因此从调用堆栈中可以看到该异常是从源文件抛出的第4行抛出的。C