如何在Xcode中启用Clang Address Sanitizer? [英] How do you enable Clang Address Sanitizer in Xcode?

查看:394
本文介绍了如何在Xcode中启用Clang Address Sanitizer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如在WWDC 2015上宣布的那样,Clang Address Sanitizer正在引入Xcode和OS X。

As announced at WWDC 2015, Clang Address Sanitizer is being brought to Xcode and OS X.

会议413:高级调试和地址清理器

如何为Xcode项目启用Clang Address Sanitizer

How do you enable Clang Address Sanitizer for your Xcode project?

推荐答案

Address Sanitizer已作为Xcode 7中的新功能添加。

Address Sanitizer has been added as a new feature in Xcode 7.

在方案中使用运行时清理> 启用地址清理器标志来启用该选项。

Use the Runtime Sanitization > Enable Address Sanitizer flag in your scheme to enable the option.

git会在您的 .xcscheme 文件中显示此更改:

git will then shown this change to your .xcscheme file:

enableAddressSanitizer = "YES"

来自 Xcode 7中的新功能文档:


地址Saniti zer。 Xcode 7可以使用旨在使用地址清理器捕获和调试内存损坏的工具来构建您的应用。

Address Sanitizer. Xcode 7 can build your app with instrumentation designed to catch and debug memory corruption using the address sanitizer.

Objective-C和C代码易受内存损坏问题(例如堆栈)的影响以及堆缓冲区溢出和释放后使用问题。当发生这些内存冲突时,您的应用程序可能会意外崩溃或显示异常行为。内存损坏问题很难跟踪,因为崩溃和奇怪的行为通常很难重现,并且原因可能离问题的根源很远。

Objective-C and C code is susceptible to memory corruption issues such as stack and heap buffer overruns and use-after-free issues. When these memory violations occur, your app can crash unpredictably or display odd behavior. Memory corruption issues are difficult to track down because the crashes and odd behavior are often hard to reproduce and the cause can be far from the origin of the problem.


您可以在构建方案中启用地址清理器。启用后,将在应用程序中内置添加的检测工具,以立即捕获违反内存的情况,使您可以在发生问题的地方立即检查问题。还提供了其他诊断信息,例如错误地址和堆上有效对象之间的关系以及分配/取消分配信息,可帮助您快速查明和解决问题。

You enable the address sanitizer in the build scheme. Once enabled, added instrumentation is built into the app to catch memory violations immediately, enabling you to inspect the problem right at the place where it occurs. Other diagnostic information is provided as well, such as the relationship between the faulty address and a valid object on the heap and allocation/deallocation information, which helps you pinpoint and fix the problem quickly.

地址清理器非常高效-足够快,可以定期使用,也可以用于交互式应用程序。它在OS X,模拟器和iOS设备上受支持。

Address sanitizer is efficient—fast enough to be used regularly, as well as with interactive applications. It is supported on OS X, in the Simulator, and on iOS devices.

这篇关于如何在Xcode中启用Clang Address Sanitizer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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