地址消毒劑已添加的新功能在Xcode 7
使用Runtime Sanitization
>Enable Address Sanitizer
標誌在你的計劃,啓用該選項。然後
git會顯示此更改您的.xcscheme
文件:
enableAddressSanitizer = "YES"
從New Features in 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 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.
我得到了一個錯誤太:'鐺:錯誤:不支持的選項'-faddress-sanitizer'。然而,在'clang --help'中,我可以看到這個選項 – Guillaume 2013-04-21 11:17:55
@gaige:問題在於蘋果正在部署**舊的**版本的Clang,它仍然使用舊的「-faddress-sanitizer」。稍後加入新的'-fsanitize = address',當添加其他殺菌劑時。 – 0xC0000022L 2014-02-25 14:43:09
@ 0xC0000022L對不起,當我說「你需要從一個更新的源代碼構建clang」時,我認爲我在上面提到了這點。無可否認,它並沒有明確表示蘋果的版本較舊,但它確實建議從較新版本開始構建。我會更新語言以使其更清楚。 – gaige 2014-02-25 20:20:46