简体   繁体   English

如何使用Android NDK进行命令行调试

[英]How can I do command line debugging using Android NDK

I am trying to debug a C++ Android application using Android NDK r20. 我正在尝试使用Android NDK r20调试C ++ Android应用程序。

The project used to use the old way of building using ndk-build and the android.mk file. 该项目过去使用的是使用ndk-build和android.mk文件进行构建的旧方法。

Now the project is migrated to using gradle and cmake. 现在,该项目已迁移到使用gradle和cmake。 Because of this, the ndk-gdb script no longer works, since it uses the old build system which expects an android.mk file. 因此,ndk-gdb脚本不再起作用,因为它使用了需要android.mk文件的旧构建系统。

So how am I supposed to debug from the command line using the latest ndk along with a gradle/cmake build system? 那么,我应该如何使用最新的ndk和gradle / cmake构建系统从命令行进行调试? Is there a new script that is provided? 是否提供了新的脚本?

ndk-gdb doesn't know how to do it out of the box right now. ndk-gdb不知道如何立即使用。 You can set up some symlinks in a gradle project to make the directory layout match a standalone ndk-build project which will let ndk-gdb work. 您可以在gradle项目中设置一些符号链接,以使目录布局与独立的ndk-build项目相匹配,这将使ndk-gdb工作。 See https://android.googlesource.com/platform/ndk/+/refs/heads/master/samples/NdkGdbSample/ for an example. 有关示例,请参见https://android.googlesource.com/platform/ndk/+/refs/heads/master/samples/NdkGdbSample/

ndk-gdb doesn't work at all with CMake though. ndk-gdb完全不适用于CMake。

See https://github.com/android-ndk/ndk/issues/1024 (I assume that's actually you that filed it). 参见https://github.com/android-ndk/ndk/issues/1024 (我认为实际上是您提起该文件)。 I don't know when we'll be able to do it, but what's described there is essentially what we'll do. 我不知道我们什么时候能够做到,但实际上描述的是我们要做的。 We'll keep the existing script, get it to work with gradle projects, and (eventually) switch it to lldb under the covers. 我们将保留现有脚本,使其与gradle项目一起使用,并(最终)在后台将其切换到lldb。

Using Android Studio is your best bet for native debugging on Android right now. 立即使用Android Studio是在Android上进行本机调试的最佳选择。

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

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