简体   繁体   English

使用英特尔Vtune从Qt Creator配置应用程序

[英]Using Intel Vtune to profile Application from Qt Creator

I want to profile application from QtCreator using Vtune on Windows 7 . 我想在Windows 7上使用Vtune从QtCreator配置应用程序 But Vtune is basicaly made for Visual Studio Apps, so I have to make the link between my function's names and the instruction in release build. 但是Vtune基本上是为Visual Studio应用程序制作的,所以我必须在我的函数名称和发布版本中的指令之间建立链接。 Actually I have only pseudo names func@address in Hotspots ,its not usable. 实际上我在Hotspots中只有伪名称func @ address,它不可用。

By exploring the "Getting Started" from Intel Vtune I find that I must enable the Debug Information in my release build but How to perform that in QtCreator? 通过探索英特尔Vtune的“入门”,我发现我必须在我的发布版本中启用调试信息,但如何在QtCreator中执行该操作?

From 'Using Debug Information' File: 从'使用调试信息'文件:

To provide accurate performance data and enable source analysis, the Intel® VTune™ Amplifier requires debug information for the binary files it analyzes. 为了提供准确的性能数据并启用源分析,英特尔®VTune™放大器需要其分析的二进制文件的调试信息。 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. 如果它没有在二进制文件中找到调试信息,则VTune Amplifier静态地识别函数边界并将热点地址分配给这些函数的生成的伪名称func @ address。

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. 在Windows *操作系统上,PDB文件提供调试信息。 Make sure both your system and application libraries/executable have PDB files. 确保您的系统和应用程序库/可执行文件都有PDB文件。 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. 默认情况下,Microsoft Visual Studio * IDE不会在发布模式下生成PDB信息。 For better results with the VTune Amplifier, enable symbol generation manually. 为了使用VTune放大器获得更好的结果,请手动启用符号生成。 For system libraries, use the Microsoft* Symbol Server to download the required PDB files from the Microsoft* web site. 对于系统库,请使用Microsoft * Symbol Server从Microsoft *网站下载所需的PDB文件。 Follow the steps below to ensure the VTune Amplifier uses debug information for both system and your own libraries. 按照以下步骤确保VTune Amplifier使用系统和您自己的库的调试信息。

I try some methods like: -edit the file.pro to change the release build 我尝试了一些方法,例如:-edit file.pro来更改发布版本

QMAKE_CXXFLAGS_RELEASE += -g
QMAKE_CFLAGS_RELEASE += -g
QMAKE_LFLAGS_RELEASE =
  • profile the Debug build. 配置Debug构建。

but it doesn't change anything, i still haven't the function name printed 但它没有改变任何东西,我仍然没有打印功能名称

Any input is much appreciated. 任何输入都非常感谢。

Yes, for VTune (or other similar profiling tools) you need "release build" (ie optimization switched ON) with debug information switched ON as well. 是的,对于VTune(或其他类似的分析工具),您需要“释放构建”(即优化开启),同时调试信息也会打开。 QTCreator doesn't create this kind of release+debug configuration by default. QTCreator默认情况下不会创建此类发布+调试配置。

For Windows MS compiler toolchain case it implies that you have to supplement Release configuration with additional /Zi compilation and /DEBUG linker options. 对于Windows MS编译器工具链,它意味着您必须使用其他 / Zi编译和/ DEBUG链接器选项来补充 Release配置。

In order to propagate these additional options in QTCreator use following steps (see also screen-shot below): 为了在QTCreator中传播这些附加选项,请使用以下步骤 (另请参见下面的屏幕截图):

  • Open qtcreator project file (***.pro) in editor 在编辑器中打开qtcreator项目文件(***。pro)
  • Add following lines before "TARGET" 在“TARGET”之前添加以下行

QMAKE_CXXFLAGS+=-Zi QMAKE_LFLAGS+=/DEBUG QMAKE_CXXFLAGS+=-Zi QMAKE_LFLAGS+=/DEBUG

  • Now, when building your project, these options will be automatically applied to both Debug and Release configuration (Debug already has it, so it should not be a problem) 现在,在构建项目时,这些选项将自动应用于Debug和Release配置(Debug已经拥有它,因此它应该不是问题)
  • Now you can profile your release build using VTune 现在,您可以使用VTune配置发布版本

Few more minor notes: 几个小调

  1. Similar procedure (with QMAKE_CXXFLAGS) is also applicable to MinGW/GCC or any other toolchains with appropriate options (-g, -gdwarf-2, etc) 类似的程序(使用QMAKE_CXXFLAGS)也适用于MinGW / GCC或任何其他具有适当选项的工具链(-g,-gdwarf-2等)
  2. If you don't want to impact all configurations, there are QT project pragmas allowing to conditionalize QMAKE_CXXFLAGS between configurations 如果您不想影响所有配置,那么有QT项目编译指示允许在配置之间条件化QMAKE_CXXFLAGS
  3. If you want to profile QT standard libraries internals, then you will additionally have to link with debug versions of QT libraries, by adjusting QMAKE_LFLAGS with extra options like /DQT***; 如果您想要分析QT标准库的内部,那么您还需要通过调整QMAKE_LFLAGS和/ DQT ***等额外选项来链接QT库的调试版本。 you can learn these from looking at QT "compiler output" window when building default Debug configurations. 在构建默认的Debug配置时,您可以通过查看QT“编译器输出”窗口来学习这些内容。

QT创建者屏幕截图

  1. Make sure you use VTun eupdate 7 or later 确保使用VTun eupdate 7或更高版本
  2. If you are using default MinGW toolchain make sure you use DWARF debug format by passing -gdwarf-2 (or -g3 -gdwarf-2) 如果您使用默认的MinGW工具链,请确保通过传递-gdwarf-2(或-g3 -gdwarf-2)来使用DWARF调试格式
  3. If you are using MSVC toolchain /Zi shuld be passed to the compiler and /DEBUG to the linker 如果您正在使用MSVC工具链/ Zi shuld将传递给编译器和/ DEBUG到链接器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM