简体   繁体   English

单独的“调试”和“发布”版本?

[英]Separate 'debug' and 'release' builds?

I think it's better to release the version of the software which your developers actually tested; 我认为最好发布开发人员实际测试过的软件版本。 I therefore tend to delete the 'debug' target from the project/makefile, so that there's only one version that can be built (and tested, and debugged, and released). 因此,我倾向于从项目/ makefile中删除“调试”目标,因此只能构建(测试,调试和发布)一个版本。

For a similar reason, I don't use 'assertions' (see also Are assertions always bad? ...). 由于类似的原因,我不使用“断言”(另请参见断言是否总是不好? ...)。

One person there argued that the reason for a 'debug' version is that it's easier to debug: but, I counter-argued that you may eventually want to support and debug whatever it is you released, and so you need to build a release which you can if necessary debug ... this may mean enabling debug symbols, and disabling some optimizations, even in the 'release' build. 那里的一个人认为,“调试”版本的原因是调试起来更容易:但是,我反驳说,您最终可能希望支持和​​调试所发布的内容,因此您需要构建一个发布版本,您可以在必要时进行调试...这可能意味着启用调试符号并禁用某些优化,即使在“发行版”版本中也是如此。

Someone else said that "this is such a bad idea"; 有人说“这真是个坏主意”。 it's a policy I evolved some years ago, having been burned by: 这是我几年前制定的政策,但遭到了以下方面的追捧:

  • Some developers' testing their debug but not release versions 一些开发人员正在测试其调试版本,但没有发布版本
  • Some developers' writing bugs which show up only in the release version 一些开发人员的写作错误,仅在发行版中显示
  • The company's releasing the release version after inadequate testing (is it ever entirely adequate?) 该公司在测试不足后发布了发行版本( 是否完全足够?)
  • Being called on to debug the release version 被调用以调试发行版

Since then I've seen more than one other development shop follow this practice (ie not have separate debug and release builds). 从那时起,我已经看到其他多家开发商店都遵循这种做法(即没有单独的调试和发布版本)。

What's your policy? 你有什么政策?

Having separate debug and release builds is a good idea, because it does make development easier. 拥有单独的调试和发行版本是一个好主意,因为它确实使开发更容易。

But debug builds should be for development only, not for testing. 但是调试版本应该仅用于开发,而不是用于测试。 You test release builds only. 您仅测试发布版本。 And you don't use developers to test those builds, you use testers. 而且您不使用开发人员来测试那些构建,而是使用测试人员。

It's a simple policy that gives the best of both worlds, IMO. 这是一项简单的政策,兼顾了两者的优点。

Edit: In response to a comment, I think it's obvious that debug and release builds (can) generate different code. 编辑:针对评论,我认为很明显,调试和发布版本(可以)生成不同的代码。 Think "-DDEBUG" vs. "-DNDEBUG", and "#if defined(DEBUG)", etc. 考虑“ -DDEBUG”与“ -DNDEBUG”以及“ #if defined(DEBUG)”等。

So it's vital that you test the code that you end up shipping. 因此,测试最终交付的代码至关重要。 If you do generate different code in debug and release builds, that means testing twice - regardless of whether or not it's tested by the same person. 如果您确实在调试和发行版本中生成了不同的代码,则意味着要进行两次测试-不管是否由同一个人测试过。

Debug symbols are not that big an issue, however. 但是,调试符号并不是一个大问题。 Always build with debugging symbols, keep a copy of the unstripped binary, but release a stripped binary. 始终使用调试符号进行构建,保留未剥离的二进制文件的副本,但释放剥离的二进制文件。 As long as you tag each binary with a build number somehow, you should always be able to identify which unstripped binary corresponds to the stripped binary that you have to debug... 只要您以某种方式用构建号标记每个二进制文件,您就应该始终能够确定哪个未剥离的二进制文件与您必须调试的剥离的二进制文件相对应。

How to strip binaries and load symbols in your debugger from an external source is platform-dependent. 如何从外部源中剥离二进制文件并在调试器中加载符号取决于平台。

This might be minor, but it adds up to what others have said here. 这可能很小,但这加起来了其他人在这里所说的话。 One of the advantages of having QA test release builds is that over time the built in debugging and logging capabilities of your software will advance due to the needs of developers who need to figure out why things are going wrong in QA. 建立QA测试版本的优点之一是,随着时间的推移,软件开发人员的内置调试和日志记录功能将随着开发人员的需求而发展,这些开发人员需要弄清楚为什么QA中出现问题。

The more the developers need to debug release builds, the better tools you'll have later when customers start having issues. 开发人员越需要调试发布版本,则当客户开始遇到问题时,您将拥有更好的工具。 Of course, no reason for developers to work on release builds as part of the development cycle. 当然,作为开发周期的一部分,开发人员没有理由进行发行版本的工作。

Also, I don't know any software company that has long enough cycles to afford the overhead of switching QA from debug to release builds halfway through a version's testing period. 另外,我不知道有哪个软件公司具有足够长的周期来承担将QA从调试切换到发布的开销,而该公司在版本的测试期中途才完成。 Having to do a full QA cycle is something that all too often happens pretty rarely. 必须执行完整的质量检查周期通常很少发生。

Our policy is to have developers work on Debug builds, but EVERYONE else (QA, BAs, sales etc) runs the release version. 我们的政策是让开发人员从事Debug构建,但其他所有人(质量保证,BA,销售等)都运行发行版。 Yesterday I had to fix a bug that only showed up in the release build it, was obvious what was happening simply BECAUSE it only showed up in release 昨天我不得不修复一个仅出现在发行版中的错误,构建该程序是显而易见的,因为它只出现在发行版中

It's first one here in this shop, and I've been here 18 months or so. 这是这家商店的第一个,我来这里已有18个月左右。

Where things get hairy is when the Release build does different things to the debug build - Yes, I have been to Hell and seen this in some very old, very ropy production code. 令人毛骨悚然的地方是Release版本与调试版本做不同的事情-是的,我去过地狱,并在一些非常古老,非常笨拙的生产代码中看到了这一点。

I see no reason why not to have both if the only difference between the configurations are debug symbols and optimisations. 如果配置之间的唯一区别是调试符号和优化,我认为没有理由不同时拥有两者。

so you need to build a release which you can if necessary debug ... this may mean enabling debug symbols, and disabling some optimizations, even in the 'release' build. 因此,您需要构建一个发行版,必要时可以进行调试...这可能意味着即使在“发行版”构建中,也要启用调试符号并禁用某些优化。

Ummm... it sounds like you're doing a debug build to me... right? 嗯...听起来您正在对我进行调试...对吧?

The part where you went wrong is this statement: 您出错的部分是以下语句:

I think it's better to release the version of the software which your developers actually tested 我认为最好发布开发人员实际测试过的软件版本

Developers don't test code. 开发人员不测试代码。 Tests test code. 测试测试代码。

Your unit tests should test ALL build configurations. 您的单元测试应该测试所有构建配置。 Do not make your developers work with one hand tied behind their back - let them use all the debugging tools they have at there disposal. 不要让开发人员只用一只手绑在背后,而是让他们使用那里可用的所有调试工具。 A Debug build is one of these. 调试版本就是其中之一。

Regarding asserts: the use of assertions greatly depends on whether or not you program by contract. 关于断言:断言的使用很大程度上取决于您是否按合同进行编程。 If you do, then assertions merely check the contract in a debug build. 如果这样做,则断言仅在调试版本中检查合同。

As per my answer in the linked thread, we also use the same build for debug and release for very similar reasons. 根据我在链接线程中的回答,出于非常相似的原因,我们还使用相同的构建进行调试和发布。 The 10%-20% performance gains from the optimiser tend to be very minor when compared to manual optimisations at algorithm level. 与算法级别的手动优化相比,从优化器获得的10%-20%的性能提升往往很小。 A single build removes many potential bugs. 单个版本可以消除许多潜在的错误。 Specifically; 特别;

  • Uninitialised variables and small buffer overflows may end up with very different results in debug and optimised release builds. 未初始化的变量和较小的缓冲区溢出可能最终导致调试和优化发行版的结果截然不同。

  • Even with the symbolic information available, debugging an optimised release can be difficult as the object doesn't match the source, eg variables may have been optimised out and code may have been re-arranged. 即使有可用的符号信息,由于对象与源不匹配,调试优化发行版也可能很困难,例如,变量可能已被优化,代码可能已重新排列。 Thus bugs reported in tested release builds can be more difficult, and hence time-consuming, to track down. 因此,在经过测试的发行版中报告的错误可能更难追踪,因此非常耗时。

Having compared unoptimised and optimised builds under automated regression tests, the performance gains provided by the optimisation don't provide enough extra value to have two builds in my case. 在自动回归测试下比较了未优化和优化的构建之后,在我的案例中,优化提供的性能提升没有提供足够的额外价值来拥有两个构建。 It is may be worth noting that the software that I develop is very CPU hungry (eg creating and manipulating large surface models). 可能值得注意的是,我开发的软件非常占用CPU(例如,创建和处理大型曲面模型)。

When developing with Java, I hate non-debug versions. 使用Java开发时,我讨厌非调试版本。 When an exception is thrown, you get no line information which makes it hard or even impossible to track bugs down. 引发异常时,您不会获得任何行信息,这使得很难甚至根本无法跟踪错误。 Also, the runtime difference between debug and non-debug is around 5% with Java 5 or later, so this is really no issue and with todays hard disks, size doesn't matter anymore. 而且,在Java 5或更高版本中,调试和非调试之间的运行时差异约为5%,因此这实际上没有问题,对于当今的硬盘,大小不再重要。

On the plus side using debug versions: 使用调试版本的好处是:

  • Stack traces contain all the information you need 堆栈跟踪包含您需要的所有信息
  • Variables can be examined 可以检查变量
  • If you have a problem in production, you can simply attach to the running process without having to stop the server first to install a debug version. 如果您在生产中遇到问题,则可以简单地附加到正在运行的进程,而不必先停止服务器来安装调试版本。
  • You won't get caught by clever optimization bugs 您不会被聪明的优化错误所困扰
  • The build is more simple (just one artifact) 构建更简单(仅一个工件)

Developers work with debug builds, QA and everyone else uses the release version, which we call "production". 开发人员使用调试版本,QA进行工作,其他所有人都使用发行版,我们将其称为“生产”。 The main advantage to this is that in the debug build, we can add lots of extra code and assertions. 这样做的主要优点是,在调试版本中,我们可以添加许多额外的代码和断言。 Some objects contain extra pieces of information that have no use except when viewing code in the debugger. 有些对象包含多余的信息,除非在调试器中查看代码,否则这些信息无用。 Some objects validate themselves periodically to make sure that all the state information is consistent. 一些对象会定期验证自己,以确保所有状态信息都是一致的。 These things make the debug version much slower, but they have helped us find no end of bugs that would have been hell to find in the production build. 这些事情使调试版本变慢了很多,但它们帮助我们找到了在生产环境中无法发现的所有错误。

As I said, all of our QA and performance testing uses production builds, and we do occasionally run into problems that show up in production but not in debug. 就像我说的,我们所有的质量保证和性能测试都使用生产版本,并且偶尔会遇到在生产中出现但在调试中没有出现的问题。 But they're relatively rare, and as a developer, the advantages of debugging a debug build rather than a production build far outweigh that problem. 但是它们相对较少,并且作为开发人员,调试调试版本而不是生产版本的优势远远超过了这个问题。

I think it depends on the project size and what type of build system and testing that you are using. 我认为这取决于项目规模以及所使用的构建系统和测试的类型。

If you have an automated build system in place, and it's simple to run unit and functional tests on a given build, then you should never have any problems with multiple build types. 如果您拥有一个自动构建系统,并且在给定构建上运行单元和功能测试很简单,那么对于多种构建类型,您永远都不会有任何问题。

出于您在问题中列出的所有原因,我一直订阅“运送您要调试的东西,以便您可以调试所运送的东西”的方法。

In my opinion this discussion missing a very important point: 我认为该讨论缺少非常重要的一点:

It really depends upon what kind of project it is! 这实际上取决于它是哪种项目!

If you create a native (C/C++) project you will in effect be forced to create debug builds, simply because compiler optimizations can make debugging near impossible in some cases. 如果您创建本机(C / C ++)项目,则实际上将被迫创建调试版本,这仅仅是因为编译器优化可能使调试在某些情况下几乎变得不可能。

If you create web applications you might rather wish to simply have one build (although "build" is rather misleading for some web applications) that can enable logging features during runtime. 如果创建Web应用程序,您可能希望仅拥有一个可以在运行时启用日志记录功能的构建(尽管“ build”对于某些Web应用程序具有误导性)。

Although a native C++ project and a PHP web application are obviously not all kinds of project that exist, I hope my point got across. 尽管本机C ++项目和PHP Web应用程序显然不是存在的所有项目,但我希望我能理解我的观点。

PS: When developing for C#, you run into a border case since although using a debug build disables compiler optimizations, in my experience you will not run into nearly as much differences as with C++ PS:在为C#开发时,您会遇到麻烦,因为尽管使用调试版本会禁用编译器优化,但根据我的经验,您不会遇到与C ++差不多的差异

here we develop in debug mode and do all unit testing in release mode. 在这里,我们以调试模式进行开发,并以发布模式进行所有单元测试。 we are a small shop with just a few (under 12) application to support ranging from Classic ASP, ASP.Net, VB.Net, and C#. 我们是一家小商店,只有几个(不到12个)应用程序,可以支持Classic ASP,ASP.Net,VB.Net和C#。 We also have a dedicated person to handle all testing, debugged problems are thrown back to the developers. 我们还有专职人员来处理所有测试,将调试后的问题交还给开发人员。

We always build both, never even considered not doing so. 我们总是建立两者,甚至从未考虑过不这样做。 Enabling debug options increases your code size and slows performance, possibly not an issue with your type of software when testing but what if the customer is running your code plus 5 other apps... 启用调试选项会增加代码大小并降低性能,这可能不是测试时软件类型的问题,但是如果客户正在运行您的代码以及其他5个应用程序该怎么办...

The issues with testing can be sorted out by using automated testing so you're release build can be effortlessly tested when you think you're ready to release. 可以使用自动化测试来解决测试问题,以便在您准备发布时可以轻松地测试发布版本。 The failure of your developers or company to properly test release builds is not a failure in the idea of release and debug builds but in your developers and or company. 开发人员或公司未能正确测试发布版本的失败并不是发布和调试版本的思想失败,而是开发人员和/或公司的失败。

On your last point, I have never been called upon to debug a release build, just to fix it... 关于您的最后一点,我从未被要求调试发布版本,只是为了修复它...

It's a tradeoff. 这是一个权衡。 Given that CPU cycles are cheap and getting cheaper while human cycles remain expensive, it makes a lot of sense to maintain only a single version of a large, complex program -- the debug(gable) version. 鉴于CPU周期便宜并且越来越便宜,而人工周期却很昂贵,因此仅维护大型复杂程序的单个版本(调试(山墙)版本)在很大程度上是有意义的。

Always using assertions always is a safer policy than never using them. 始终使用断言总是比不使用断言更安全的策略。 If producing separate debug and release versions, re-enable whatever #define d symbols you need to guarantee that assertions are enabled in the release version also. 如果生成单独的调试和发行版本,请重新启用所需的任何#define d符号,以确保在发行版本中也启用了断言。

I think the tradeoff is simple: yes, with only a release build, you really test what's actually being shipped. 我认为折衷很简单:是的,只有发行版本,您才能真正测试实际交付的产品。 On the other hand, you do pay a price in ease of debugging for your developers and/or performance for the user, so it's up to you to check both cases. 另一方面,您确实要为开发人员的调试和/或用户的性能降低付出代价,因此您需要检查这两种情况。

On most medium- to large-size projects, ease of debugging will ensure a better product for your users in the end. 在大多数中型到大型项目中,易于调试将最终确保为用户提供更好的产品。

See this What's your most controversial programming opinion? 看到这里您最有争议的编程观点是什么?

quote: 引用:

Opinion: Never ever have different code between "debug" and "release" builds 意见:“调试”和“发布”版本之间永远不会有不同的代码

The main reason being that release code almost never gets tested. 主要原因是发布代码几乎从未经过测试。 Better to have the same code running in test as it is in the wild. 最好在野外运行相同的代码以进行测试。

By removing the "debug target", you are forcing developers to debug on the release version of the software. 通过删除“调试目标”,您将迫使开发人员在软件的发行版本上进行调试。 What that probaly means in practice is two things: 实际上,这可能意味着两件事:

1) "release builds" will have optimizations disabled (otherwised developers can't use a debugger) 1)“发布版本”将禁用优化功能(否则,开发人员无法使用调试器)

2) No builds will have special PREPROCESSOR macros altering their execution. 2)没有任何构建将具有特殊的PREPROCESSOR宏来更改其执行。

So what you will really be doing is merging the release and debug configurations rather than eliminating just the "debug" mode. 因此,您真正要做的是合并发行和调试配置,而不是仅消除“调试”模式。

I personally have done this with iOS development with no ill-effects. 我个人是通过iOS开发完成此操作的,没有任何不良影响。 The amount of time spent in our written code is less than 1% of what is really happening, so the optimizations were not significant contributors. 在我们编写的代码中花费的时间少于实际发生的时间的1%,因此优化并不是重要的贡献者。 In this case, they really did seem to cause an increase in bugs, but even if they didn't, the idea of testing one way, then giving to QA with different code introduces just one more factor to consider with issues. 在这种情况下,它们确实确实导致了bug的增加,但是即使不是,它们也是如此,以一种方法进行测试,然后使用不同的代码进行质量检查的想法,仅引入了一个考虑问题的因素。

On the other hand, there are cases where the optimizations are necessary, where they are useful, and even where there is enough time for testing both. 另一方面,在某些情况下,优化是必要的,它们是有用的,甚至有足够的时间来测试这两者。 Usually, the changes between debug and release are so minor that it doesn't cause anyone any issues at all. 通常,调试和发布之间的更改很小,以至于根本不会引起任何问题。

If you've got a real QA group who can be counted on to fully test the thing, I'd say make debug builds until you get close to the release, and then make sure a full QA cycle is done on the same build that's going out the door. 如果您有一个真正的QA小组可以指望它进行全面的测试,那么我会说制作调试版本,直到您接近发行版为止,然后确保在相同的版本上完成完整的QA周期。走出去。

Although in at least one case we released something that still had some debug code in it. 尽管在至少一种情况下,我们发布了仍然包含一些调试代码的东西。 The only consequence was it ran a tiny bit slower and the log files were pretty damn big. 唯一的结果是运行速度稍慢并且日志文件非常大。

In my company we have both Debug and Release. 在我的公司中,我们同时具有Debug和Release。 - The developers use the debug version to properly find and fix bugs. -开发人员使用调试版本正确查找和修复错误。 - We are using TDD and so we have a big test suite that we run on our server that tests both debug and release build configurations as well as 64/32 builds we have as well. -我们正在使用TDD,因此我们在服务器上运行了一个大型测试套件,用于测试调试和发布版本配置以及我们拥有的64/32版本。

So if using the "debug" configuration helps a developer to find a bug faster there is no reason not to use it - when the code goes into the server (to be further tested) or reviewed we use the "Release" one. 因此,如果使用“调试”配置有助于开发人员更快地发现错误,则没有理由不使用它-当代码进入服务器(待进一步测试)或检查代码时,我们将使用“发布”。

I learned to build the release version with .PDB files long ago so that I could debug the release version. 很久以前,我学会了使用.PDB文件构建发行版本,以便可以调试发行版本。 What a lot of programmers tend to forget is that when you run the debug version, with all the optimizations turned off, you are debugging a different program altogether. 许多程序员往往会忘记的是,当您运行调试版本时,如果关闭了所有优化功能,则您将完全调试另一个程序。 It may behave like the release build (for the most part), but it is still a different program than the release build. 它的行为可能与发行版本相似(大部分情况下),但它仍然是与发行版本不同的程序。

In addition, debugging the release build is not that difficult. 此外,调试发布版本并不困难。 And if you get a crash dump, you have to be able to do it anyway. 而且,如果您有故障转储,则无论如何都必须能够做到。

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

相关问题 Q / A,发布版本与调试版本和断言 - Q/A, Release builds vs Debug builds, and Assertions 是否有可能使用零成本的assert()使得在调试和发行版本之间不必修改代码? - Is it possible to have a zero-cost assert() such that code should not have to be modified between debug and release builds? 测试版本构建 - Testing Release Builds OSX-如何调试分布式版本? - OSX - How to debug distributed builds? 如何编写调试和发布配置的测试 - How to write tests for debug and release configurations 在releseUnitTest中使用调试资产,而不是发布应用程序资产 - Use debug assets in releseUnitTest instead of the release app assets 测量ASP.NET应用程序的调试与发布 - Measuring debug vs release of ASP.NET applications 为什么Android调试版本比android发布版本更多地用于Appium自动化测试中? - Why does android debug build is mostly used in Appium automation testing than the android release build? 应该与QA共享哪个版本进行测试? 签名发布apk或Signed debug apk? - Which build should be shared with QA for testing? Signed release apk or Signed debug apk? 如何在TeamCity中重新组合构建? - How to recombine builds in TeamCity?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM