c++ - 使用 Intel Vtune 从 Qt Creator 分析应用程序

标签 c++ windows qt profiling intel-vtune

我想在 Windows 7 上使用 Vtune 从 QtCreator 分析应用程序。但是 Vtune 基本上是为 Visual Studio Apps 制作的,所以我必须在我的函数名称和发布版本中的指令之间建立联系。 其实我在热点里只有假名func@address,不能用。

通过探索 Intel Vtune 的“入门”,我发现我必须在我的发布版本中启用调试信息,但如何在 QtCreator 中执行它?

来自“使用调试信息”文件:

To provide accurate performance data and enable source analysis, the Intel® VTune™ Amplifier requires debug information for the binary files it analyzes. If it does not find debug information in the binaries, the VTune Amplifier statically identifies function boundaries and assigns hotspot addresses to generated pseudo names func@address for such functions.

If debug information is absent, the Call Stack pane may not unwind the call stack correctly for user-mode sampling and tracing analysis types. Additionally in some cases, it can take significantly more time to finalize the results for modules that do not have debug information.

On Windows* operating systems, PDB files provide debug information. Make sure both your system and application libraries/executable have PDB files. Compile your target with optimizations and start profiling its performance.

By default, the Microsoft Visual Studio* IDE does not generate PDB information in the Release mode. For better results with the VTune Amplifier, enable symbol generation manually. For system libraries, use the Microsoft* Symbol Server to download the required PDB files from the Microsoft* web site. Follow the steps below to ensure the VTune Amplifier uses debug information for both system and your own libraries.

我尝试了一些方法,例如:-编辑 file.pro 以更改发布版本

QMAKE_CXXFLAGS_RELEASE += -g
QMAKE_CFLAGS_RELEASE += -g
QMAKE_LFLAGS_RELEASE =
  • 分析调试版本。

但它没有改变任何东西,我仍然没有打印函数名称

非常感谢任何输入。

最佳答案

是的,对于 VTune(或其他类似的分析工具),您需要“发布版本”(即打开优化),同时打开调试信息。 QTCreator 默认不创建这种发布+调试配置。

对于 Windows MS 编译器工具链情况,这意味着您必须使用附加/Zi 编译和/DEBUG 链接器选项补充发布配置。

为了在 QTCreator 中传播这些附加选项使用以下步骤(另请参见下面的屏幕截图):

  • 在编辑器中打开 qtcreator 项目文件 (***.pro)
  • 在“TARGET”之前添加以下几行

QMAKE_CXXFLAGS+=-Zi QMAKE_LFLAGS+=/DEBUG

  • 现在,在构建项目时,这些选项将自动应用于 Debug 和 Release 配置(Debug 已经有了,所以应该不是问题)
  • 现在您可以使用 VTune 分析您的发布版本

还有一些次要笔记:

  1. Similar procedure (with QMAKE_CXXFLAGS) is also applicable to MinGW/GCC or any other toolchains with appropriate options (-g, -gdwarf-2, etc)
  2. 如果您不想影响所有配置,可以使用 QT 项目编译指示在配置之间对 QMAKE_CXXFLAGS 进行条件化
  3. 如果你想分析 QT 标准库的内部结构,那么你还必须链接到 QT 库的调试版本,方法是使用/DQT*** 等额外选项调整 QMAKE_LFLAGS;您可以在构建默认调试配置时通过查看 QT“编译器输出”窗口来了解这些。

QT creator Screen-shot

关于c++ - 使用 Intel Vtune 从 Qt Creator 分析应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22786506/

相关文章:

c++ - QSqlTableModel::insertRecord() 使用非默认连接名称的 QSqlDatabase 失败

linux - QT 维护工具在 Linux 上的文件路径位置是什么?

c++ - 默认参数中的 undefined variable 不好吗?

c++ - cppcheck生成xml转储文件

c++ - Qt 文件调整大小在 Linux 中表现怪异

windows - 在 Windows 上通过 ssh 连接到 mercurial

c++函数返回模板类型检查

c++ - 为什么我们应该为 C++ 应用程序构建 64 位目标?

python - 将文本编码为 win32api.SendMessage() 的 WPARAM

c++ - 如何使用 QPaint 创建这样的圆圈