如何 Qt - Qml 调试和/或分析?
需要在应用程序中编译哪些软件 Qt/QML 片段才能调试/分析 QML?
What software Qt/QML pieces are needed to compile in an app to be able to debug/profile QML?
我当前的应用是使用 cmake 构建的,并在嵌入式设备上运行.此外,我开始使用 Qt 4.8.3(直到现在 4.7.0).
My current app is build using cmake and runs on a embedded device. Furthermore, I'm starting to use Qt 4.8.3 (until now 4.7.0).
我想使用这些花哨/酷炫的功能(适用于嵌入式开发人员):
I would like to use these fancy/cool features (for an embedded developer):
http://doc.qt.digia.com/qtcreator/creator-qml-performance-monitor.html
我已经通过 qt-project 寻找帮助,但我不清楚是什么当您想要使用自定义构建环境调试/分析远程应用程序时所需的步骤.
I've searched trough qt-project looking for help, but I haven't got clear what are the steps needed when you want to debug/profile a remote app, with a customize build environment.
所以,我想知道是否需要以下任何步骤,在肯定的情况下,实际上需要的代码是什么.
So, I would like to know if it is needed any of the following steps, and in positive case, what is in fact the needed code.
- Qt 库./configure 特定选项.
- QtCreator 特定选项可附加/启动到远程应用程序.
- Cmake 包含最终应用程序可执行文件中所需的库.
欢迎任何帮助、链接等.
Any help, link, etc is welcomed.
推荐答案
使用 Qt 4.8,这变得非常简单.所有必需的库现在都是 Qt 本身的一部分,您不必自己为您的 Qt 版本构建调试库.
With Qt 4.8 this got pretty easy. All required libraries are now part of Qt itself and you don't have to build the debug library for your Qt version yourself.
我正在开发一个同样使用 CMake 构建的 Qt/QML 桌面应用程序.我必须完成以下步骤才能启用 QML 调试:
I'm developing a Qt/QML desktop application also built with CMake. I had to complete the following steps to enable QML debugging:
在我的应用程序的启动代码中包含调试启动器
Include the debugging enabler into my application's start-up code
#include <QtDeclarative/qdeclarativedebug.h>
/* [...] */
QDeclarativeDebuggingEnabler enabler;
将 QML_DISABLE_OPTIMIZER=1
添加到我的应用程序的执行环境中
Add QML_DISABLE_OPTIMIZER=1
to execution environment of my application
这可以在项目页面的执行选项卡中的 Qt Creator 中完成.
This can be done within Qt Creator in the execution tab of the projects page.
勾选 QML 调试复选框
Tick the checkbox for QML debugging also found in the execution tab
这为 Qt Creator 和嵌入在应用程序中的 QML 调试器组件之间的通信添加了所需的命令行参数
This adds the required command line parameters for the communication between Qt Creator and the QML debugger component embedded in the application
如果一切正常,应用程序在调试模式下启动时会显示以下输出:
If everything went fine the application greets you with the following output if started in debug mode:
Qml 调试已启用.只能在安全的环境中使用!
QDeclarativeDebugServer:正在等待端口 3768 上的连接...
QDeclarativeDebugServer: 已建立连接
Qml debugging is enabled. Only use this in a safe environment!
QDeclarativeDebugServer: Waiting for connection on port 3768...
QDeclarativeDebugServer: Connection established
之后我就可以设置断点和检查变量了.可通过分析页面访问的分析器也正常工作.
After that I was able to set breakpoints and inspect variables. Also the profiler accessible via the analyze page just worked.
当您开发嵌入式应用程序时,您的情况显然有点复杂.
Your case is obviously a little bit more complicated as your developing an embedded application.
Qt creator 不支持在嵌入式平台上部署和执行基于 CMake 的项目.你必须自己做.不要忘记将所需的参数传递给您的应用程序以配置 QML 调试:
Qt creator has no support for deploying and executing CMake-based projects on embedded platforms. You will have to do that yourself. Don't forget to pass the required arguments to your application to configure the QML debugging:
$ your-app -qmljsdebugger=port:3768,block
要将 Qt Creator 附加到远程运行的应用程序以进行分析会话,请使用 Qt Creator 主菜单中分析"菜单中的相应外部"条目.在调试">调试"下使用连接到调试服务器"进行调试的类似选项在哪里.
To attach Qt Creator to a remotely running application for a profiling session use the corresponding "External" entries in the "Analyze" menu in the Qt Creator main menu. Where is a likewise option for debugging with "Connect to Debug-Server" under "Debug" > "Debug".
相关文章