简体   繁体   English

如何使用cmake调试Qt-Android应用程序构建?

[英]How to debug an Qt-Android application build with cmake?

I want to debug a Qt based Android application which is build using cmake (instead of qmake). 我想调试使用cmake(而不是qmake)构建的基于Qt的Android应用程序。

The androiddeployqt command bundles the apk and adds gdbserver . androiddeployqt命令捆绑了apk并添加了gdbserver Then I can launch the gdb server via: 然后,我可以通过以下方式启动gdb服务器:

adb shell run-as com.package.name /data/data/com.package.name/lib/libgdbserver.so --once :5055 --attach $PID

and also I forward the port to my desktop via adb forward tcp:5055 tcp:5055 我也通过adb forward tcp:5055 tcp:5055端口将端口转发到我的桌面adb forward tcp:5055 tcp:5055

Attaching gdb from Qt-Creator succeeds but something seems to be missing. Qt-Creator附加gdb成功,但是似乎丢失了一些东西。 I am not shown any symbols and the number of displayed threads is not coherent. 没有显示任何符号,并且显示的线程数不一致。

I finally managed to get it running. 我终于设法使其运行。 For future documentation, here is what I was missing: I needed the libraries of my application as well as the Qt libraries build in debug mode. 对于将来的文档,这是我所缺少的:我需要应用程序的库以及以调试模式构建的Qt库。 Further more I needed the executables and libraries from the phone. 此外,我还需要手机中的可执行文件和库。 I fetched them via 我是通过

adb pull /system/bin  ./
adb pull /system/lib  ./

adb creates subfolders when pulling and that was one of my problems: All these files need to be stored in one single folder – so I moved them. adb在拉动时会创建子文件夹,这是我的问题之一:所有这些文件都需要存储在一个文件夹中-因此我将它们移动了。

Finally I needed to make gdb use the collected files via 最后,我需要让gdb通过以下方式使用收集的文件

set auto-solib-add on
set solib-search-path /tmp/adb

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

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