How do you enable Clang Address Sanitizer in Xcode?

。_饼干妹妹 提交于 2019-12-20 03:09:07

问题


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

Session 413: Advanced Debugging and the Address Sanitizer

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


回答1:


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 will then shown this change to your .xcscheme file:

enableAddressSanitizer = "YES"

From the New Features in Xcode 7 document:

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

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.

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.



来源:https://stackoverflow.com/questions/32150924/how-do-you-enable-clang-address-sanitizer-in-xcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!