gpt4 book ai didi

xcode - 如何在 Xcode 中启用 Clang Address Sanitizer?

转载 作者:行者123 更新时间:2023-12-01 10:38:16 25 4
gpt4 key购买 nike

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

Session 413: Advanced Debugging and the Address Sanitizer

如何为您的 Xcode 项目启用 Clang Address Sanitizer?

最佳答案

Address Sanitizer 已作为新功能添加到 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.

Enable Address Sanitizer

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.

关于xcode - 如何在 Xcode 中启用 Clang Address Sanitizer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32150924/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com