Xcode / Cocoa:调试和发布版本之间有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/761628/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode / Cocoa : What are the differences between debug and release builds?
提问by TalkingCode
What are the differences between debug and release builds for a Cocoa application? I know the debug version contains additional information for debugging but what else is different?
Cocoa 应用程序的调试版本和发布版本之间有什么区别?我知道调试版本包含用于调试的附加信息,但还有什么不同?
回答by Adam Rosenfield
Debug builds will contain debugging symbols which can be used by a debugger. Release builds often do not contain debugging symbols, so if you get a crash dump, all you'll get are a bunch of hexadecimal addresses instead of useful symbol names.
调试版本将包含调试器可以使用的调试符号。发布版本通常不包含调试符号,因此如果您获得故障转储,您将获得的只是一堆十六进制地址而不是有用的符号名称。
Debug builds are not compiled with optimization (-O0
with gcc), whereas release builds are compiled with optimization (typically -O2
or -O3
). Optimization makes debugging much, much harder. If you attempt to debug a release application, the debugger will get very confused, since assembly statements no longer match up with HLL statements, statements get reordered, functions get inlined, loops get unrolled, etc.
调试版本不是通过优化(-O0
使用 gcc)编译的,而发布版本是通过优化(通常是-O2
或-O3
)编译的。优化使调试变得更加困难。如果您尝试调试发布应用程序,调试器会变得非常困惑,因为汇编语句不再与 HLL 语句匹配,语句被重新排序,函数被内联,循环被展开等。
Debug and release builds also defined different preprocessor symbols, and some code is conditionally compiled based on those (for example, array bounds checks, assertions, etc.), although that is highly application-dependent. A typical example would be to #define NDEBUG
for release mode, which causes assertions to be removed.
调试和发布版本还定义了不同的预处理器符号,并且一些代码是基于这些符号有条件地编译的(例如,数组边界检查、断言等),尽管这高度依赖于应用程序。一个典型的例子是 to #define NDEBUG
for release 模式,这会导致断言被删除。
回答by cocoafan
In Tiger, Debug builds are "zero linked". This is it is optimized for you environment only and is not really a complete build.
在 Tiger 中,调试版本是“零链接”的。这是它仅针对您的环境进行了优化,并不是真正的完整构建。