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?
Qt for Android enables you to develop Qt applications for Android devices, and supports a wide range of features and use-cases. To download and install Qt for Android, follow the instructions on the Getting Started with Qt for Android page. To build Qt from source, see Building from Source.
In order to use Qt for Android, you need the following: Java Development Kit (JDK) provided by AdoptOpenJDK for all platforms, is required to build Android apps. Other alternatives such as OpenJDK for Linux or Java SE Development Kit for Windows are also supported.
Note: In Qt Creator, select Projects > Build > Build Steps > Build Android APK > Open package location after build to build the application's . apk and open the directory containing the package.
Qt is a cross-platform application development framework widely used for developing applications that can run on a wide range of hardware platforms with little to no change in the underlying codebase.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With