最佳做法和工具来调试的调试和发布版本的差异? [英] Best practices and tools for debugging differences between Debug and Release builds?

查看:139
本文介绍了最佳做法和工具来调试的调试和发布版本的差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过的帖子谈论什么可能的事业的调试和发布之间的差异版本,但我不认为任何人已经从一个发展的立足点是什么来解决这个问题最有效的方法解决

I've seen posts talk about what might cause differences between Debug and Release builds, but I don't think anybody has addressed from a development standpoint what is the most efficient way to solve the problem.

当一个错误出现在发布版本,但不是在调试就是我的valgrind通过在一个更好的分析,希望运行我的节目,我做的第一件事。如果发现没有, - 这以前发生在我身上 - 然后,我尝试在得到错误也浮现在调试版本的希望各种投入。如果失败,那么我会尝试跟踪更改找到最新版本的这两个版本在行为上出现分歧。最后我想我会求助于打印报表。

The first thing I do when a bug appears in the Release build but not in Debug is I run my program through valgrind in hopes of a better analysis. If that reveals nothing, -- and this has happened to me before -- then I try various inputs in hopes of getting the bug to surface also in the Debug build. If that fails, then I would try to track changes to find the most recent version for which the two builds diverge in behavior. And finally I guess I would resort to print statements.

是否有当调试和发布版本不同,有效地调试任何最好的软件工程实践?此外,什么工具是比Valgrind的一个更根本的层面运作有帮助调试这些情况?

Are there any best software engineering practices for efficiently debugging when the Debug and Release builds differ? Also, what tools are there that operate at a more fundamental level than valgrind to help debug these cases?

编辑:我注意到很多反应表明一些通用的好的做法,如单元测试和回归测试,这我同意是伟大的找到任何错误。但是,有没有专门针对此版本与调试问题的东西吗?例如,是否有这样的事,作为一个静态分析工具,说:哎,这个宏或本code或本节目的做法是危险的,因为它有可能导致您的调试之间的差异的潜在/发布版本?

I notice a lot of responses suggesting some general good practices such as unit testing and regression testing, which I agree are great for finding any bug. However, is there something specifically tailored to this Release vs. Debug problem? For example, is there such a thing as a static analysis tool that says "Hey, this macro or this code or this programming practice is dangerous because it has the potential to cause differences between your Debug/Release builds?"

推荐答案

两种配置的存在本身是从调试的角度来看问题。适当的工程将使得在地面上,并在空气中的系统行为相同的方式,并通过减少的方法,通过该系统可以告诉差数达到此

The very existence of two configurations is a problem from debugging point of view. Proper engineering would be such that the system on the ground and in the air behave the same way, and achieve this by reducing the number of ways by which the system can tell the difference.

调试和发布版本在三个方面有所不同:

Debug and Release builds differ in 3 aspects:


  • _DEBUG定义

  • 优化

  • 不同版本的标准库

各地最好的方法,我经常工作的方式,是这样的:

The best way around, the way I often work, is this:


  • 禁用优化性能不是关键的。调试是更重要的。最重要的是禁用功能自动内联,保持标准栈帧和可变重用优化。这些烦扰调试最。

  • 监控code对DEBUG依赖定义。切勿使用调试只断言,或DEBUG敏感的任何其他工具定义。

  • 默认情况下,编译和工作/释放。

这篇关于最佳做法和工具来调试的调试和发布版本的差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆