从 Qt Creator 附加到 Android 进程 [英] Attach to Android process from Qt Creator

查看:110
本文介绍了从 Qt Creator 附加到 Android 进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Qt Creator 开发了一个 Android 动态库,即一个 .so 文件.这个 .so 文件随后被一个 Android 应用程序使用,但它是在 Eclipse 中开发的.

我需要调试我的本机代码,但由于它是一个库,我无法从 Qt Creator 启动应用程序,我必须附加到已经运行的进程.

现在,如果它是一个桌面应用程序,我会使用 Debug->Start Debugging->Attach to Running Application,但是我如何附加到一个 Android 进程,这将是在模拟器上运行还是在连接的手机上运行,​​哪个更像是远程调试?

我认为我应该使用Debug->Start Debugging->Attach to Running Debug Server:

但是,我不确定具体步骤是什么 - 如何为 ADB 启动调试服务器,以及连接到哪个端口?

解决方案

所以看起来可能有另一种方法来设置可以正确连接的调试器.

http://lists.qt-project.org/pipermail/qt-creator/2012-June/001017.html

<块引用>

使用此版本的 gdb 设置工具链,并设置您的项目以使用它.在工具 -> 选项 -> 调试器 -> GDB 中,在附加启动命令"

...

<块引用>

我使用调试 -> 开始调试 -> 附加到远程.所有字段都是那里(solib-absolute-prefix 是 sysroot 的别名,位置调试信息"是solib-search-path),最后几个配置"已存储,因此您可以轻松调用它们.我有要在目标上手动启动 gdbserver,请设置一个快捷方式以打开附加到远程"对话框,它对我来说效果很好.

它很旧(2012 年 6 月),但它更详细地介绍了 gdbserver 如何启动以及调试器的设置以及连接到 Qt 中的进程.它还提到了一些相关的环境变量:

<块引用>

set solib-absolute-prefix $ANDROID_SRC/out/target/product/MYPRODUCT/symbols/设置 solib-search-path $ANDROID_SRC/out/target/product/MYPRODUCT/symbols/system/lib/

希望有所帮助.

I use Qt Creator to develop an Android dynamic library, i.e. a .so file. This .so file is then used by an Android application, but that is developed in Eclipse.

I need to debug my native code, but since it's a library, I can't start the application from Qt Creator, I must attach to the already running process.

Now, if it were a desktop application, I'd use Debug->Start Debugging->Attach to Running Application, but how do I attach to an Android process, which would be running on the emulator or on a connected phone, which is more like remote-debugging?

I think that I should use Debug->Start Debugging->Attach to Running Debug Server:

However, I'm not sure what the exact steps are - how do I start a debug server for ADB, and which port do I connect to?

解决方案

So it looks like there may be another way to set up a debugger that can connect properly.

http://lists.qt-project.org/pipermail/qt-creator/2012-June/001017.html

Set a toolchain with this version of gdb, and set your project to use it. In Tools -> Options -> Debugger -> GDB insert your commands in "Additional Startup Commands"

...

I use Debug -> Start Debugging -> Attach to Remote. All the fields are there (solib-absolute-prefix is an alias for sysroot, and "location of debugging information" is solib-search-path), and the last few "configurations" are stored, so you can call them back easily. I have to start gdbserver on the target manually, set a shortcut to open the 'attach to remote' dialog, and it is been working great for me so for.

It's old (June 2012), but it goes into better detail about how the gdbserver is started and the setup for a debugger and attaching to a process in Qt. It also mentions some of the relevant environment variables:

set solib-absolute-prefix $ANDROID_SRC/out/target/product/MYPRODUCT/symbols/
set solib-search-path $ANDROID_SRC/out/target/product/MYPRODUCT/symbols/system/lib/

Hope that helps.

这篇关于从 Qt Creator 附加到 Android 进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆