如何使用gdb在g ++代码中查找浮点异常

neu*_*cer 2 c++ debugging gdb g++

我有一个没有用户输入的g ++程序.某个程序被中断并显示"浮点异常".gdb可以帮助我在我的代码中找到导致这种情况的原因吗?怎么样?

Ste*_*hen 11

你可以在这里和Gnu的网站上获得GDB的帮助.

但基本是这样的:

$ gdb ./your_program             // start gdb on the program
> run                            // run the program
> run argv1 argv2                // or run it with command line arguments
(floating point exception)       // let it run until exception occurs
> bt                             // bt will show the stack trace
Run Code Online (Sandbox Code Playgroud)

以下是一些关于如何确保它在浮点异常上停止的gdb设置.