使用 Xcode 分析 C++
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1984877/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Profiling C++ with Xcode
提问by asdf
is it possible to profile C++ apps with Xcode so one gets;
是否可以使用 Xcode 来分析 C++ 应用程序,以便获得;
- memory leaks like with valgrind
- possible errors before running the program
- 内存泄漏就像 valgrind
- 运行程序前可能出现的错误
Thanks, I am very new to mac and xcode
谢谢,我对 mac 和 xcode 很陌生
Where can one find a good tutorial for this?
在哪里可以找到一个很好的教程?
采纳答案by mloskot
Regarding memory leaks, run XCode and then launch Start with Performance Tool
-> Leaks
关于内存泄漏,运行 XCode 然后启动Start with Performance Tool
->Leaks
Alternatively and necessarily for old pre-Panther users of XCode, it is possible to debug with guard malloc
, detailed explanation in the Mac development docs, but here is a quick walk-through.
或者,对于 XCode 的前 Panther 老用户来说,可以使用 guard 进行调试,malloc
Mac 开发文档中的详细解释,但这里是一个快速演练。
回答by pau.estalella
You have a tool called Instruments, a free Apple tool included in XCode, that catches most of those errors.
您有一个名为Instruments 的工具,它是 XCode 中包含的免费 Apple 工具,可以捕获大部分错误。
回答by mloskot
Instruments is a great tool, as @pau.estalella says. Valgrind support for Mac OS X is now in the main Valgrind repository, courtesy of Greg Parker.
正如@pau.estalella 所说,仪器是一个很好的工具。Valgrind 对 Mac OS X 的支持现在位于主要的 Valgrind 存储库中,由 Greg Parker 提供。
回答by iamamac
possible errors before running the program
运行程序前可能出现的错误
Xcode 3.2 now comes with static analysis tool powered by Clang, which will detect logicalerrors such as unreleased memory at compile time.
Xcode 3.2 现在带有由Clang提供支持的静态分析工具,它将在编译时检测逻辑错误,例如未释放的内存。
It is just in Build > Build and Analyze menu.
它只是在构建 > 构建和分析菜单中。
Read Apple's documentationto get more detail.
阅读Apple 的文档以获取更多详细信息。
回答by High Performance Mark
This is a bit outside my current core competencies, but I've spotted a tool called Shark on my Mac which offers profiling and optimisation support. There are other Xcode tools too. But I've not yet used any of them for real. And I have no experience of valgrind on the Mac.
这有点超出我目前的核心能力,但我在我的 Mac 上发现了一个名为 Shark 的工具,它提供分析和优化支持。还有其他 Xcode 工具。但我还没有真正使用它们中的任何一个。而且我没有在 Mac 上使用 valgrind 的经验。
Not much of an answer, I know.
没有太多答案,我知道。