简体   繁体   English

如何从Android应用程序调试共享库[单独的项目]

[英]how to debug a shared libarary [ separate project] from android application

I am developing an android application and using intensive c++ code in the project , First I put the c++ source code in the project and used the following guide to have the NDK capability of Native Debugging in the Android application . 我正在开发一个Android应用程序并在项目中使用密集的c ++代码,首先,我将c ++源代码放在项目中,并使用以下指南在Android应用程序中具有本机调试的NDK功能。

http://tools.android.com/recent/usingthendkplugin http://tools.android.com/recent/usingthendkplugin

but after weaks of development I decided to separate the Native code in a standalone project and use the output SO in the Android Application . 但是在开发的弱点之后,我决定在独立项目中分离Native代码并使用Android应用程序中的输出SO。

My Question Is how can I debug a SO library which is the result of a separate project in an Android Application ? 我的问题我如何调试SO库,这是Android应用程序中单独项目的结果?

Use nkd-gdb for this (your .so will have to be included in the APK that you installed for your application, in the normal location for app-specific .so files) It is part of the NDK. 使用nkd-gdb(您的.so必须包含在为应用程序安装的APK中,在特定于应用程序的.so文件的正常位置)它是NDK的一部分。 See $NDK/docs/NDK-GDB.html 请参阅$ NDK / docs / NDK-GDB.html

But, be warned: nkd-gdb will only attach GDB to your .so sometime after the application has started. 但是,请注意:nkd-gdb只会在应用程序启动后的某个时间将GDB附加到您的.so。 So, you might miss some breakpoints. 所以,你可能会错过一些断点。 I know of 2 ways to solve that problem, outside of an IDE plugin: 我知道在IDE插件之外解决该问题的两种方法:

  1. Place an infinite loop at the earliest entry-point of your .so, then use GDB to break out of that infinite loop, after you have set your breakpoints 在.so的最早入口点放置一个无限循环,然后在设置断点后使用GDB突破无限循环
  2. Download my pending update to ndk-gdb, which fixes this problem, from https://android-review.googlesource.com/#/c/48029/ (One person has reported having problems with my fix, so it is not approved for AOSP yet... but I have never reproduced their problem. Please let me know if you use it, and whether it works for you or not.) https://android-review.googlesource.com/#/c/48029/下载我的挂起更新到ndk-gdb,它解决了这个问题(一个人报告说我的修复有问题,所以它没有被批准用于AOSP还没......但我从未复制过他们的问题。如果您使用它,请告诉我,以及它是否适合您。)

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

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