简体   繁体   English

生成NaN浮点数时停止调试器

[英]Stopping the debugger when a NaN floating point number is produced

I have an C++ program. 我有一个C ++程序。 Somewhere in the program (hard to reproduce, but reproduceable) a caclculation results in a float beeing set to a NaN. 在程序的某处(难以重现,但可重现),caclculation导致浮动设置为NaN。 Since a floating point operation involving a NaN results in a NaN, this spreads fast. 由于涉及NaN的浮点运算导致NaN,因此传播速度很快。

Is there any way I can setup the compiler (gcc 4.4) or the debuger (gdb) to stop when a floating point operation results in a NaN? 有什么方法可以设置编译器(gcc 4.4)或debuger(gdb)在浮点运算导致NaN时停止? That would be extremely useful. 那将非常有用。

Thanks! 谢谢! Nathan 弥敦道

PS: It might matter: I am working under ubuntu linux 10.10. PS:可能很重要:我在ubuntu linux 10.10下工作。

您可以启用浮点异常 - 请参阅glibc控制函数 - 然后在生成NaN值时获得SIGFPE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM