Xcode / Cocoa:调试和发布版本之间的区别是什么? [英] Xcode / Cocoa : What are the differences between debug and release builds?

查看:98
本文介绍了Xcode / Cocoa:调试和发布版本之间的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Cocoa应用程序的调试版本和发行版版本之间的区别是什么?
我知道调试版本包含调试的其他信息,但是有什么不同?

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?

推荐答案

调试版本将包含调试符号,可以由调试器使用。发布版本通常不包含调试符号,所以如果你得到一个崩溃转储,你将得到一堆十六进制地址,而不是有用的符号名称。

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.

调试构建不使用优化( -O0 with gcc)编译,而发布构建使用优化(通常 -O2 -O3 )。优化使得调试更加困难。如果你试图调试一个发布应用程序,调试器会很困惑,因为汇编语句不再与HLL语句匹配,语句重新排序,函数内联,循环被展开等。

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.

调试和发布版本还定义了不同的预处理符号,有些代码基于这些(例如,数组边界检查,断言等)有条件地编译,虽然这是高度依赖于应用程序的。一个典型的例子是释放模式的 #define NDEBUG ,这会导致断言被移除。

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.

这篇关于Xcode / Cocoa:调试和发布版本之间的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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