如何从Android应用程序调试共享的libarary [单独的项目] [英] how to debug a shared libarary [ separate project] from android application

查看:178
本文介绍了如何从Android应用程序调试共享的libarary [单独的项目]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Android应用程序,并在项目中使用密集的c ++代码,
首先我将c ++源代码放在项目中,并使用以下指南在Android应用程序中具有本机调试的NDK功能。



http://tools.android.com/最近/ usingthendkplugin



但在开发不足之后,我决定在独立项目中分离本机代码,并在Android应用程序中使用输出SO。



我的问题如何调试一个SO库,这是Android应用程序中单独项目的结果?

解决方案

使用nkd-gdb进行此操作(您的.so将必须包含在您为应用程序安装的APK中,位于正常位置应用程序特定的.so文件)它是NDK的一部分。请参阅$ NDK / docs / NDK-GDB.html



但是,请注意:应用程序启动后,nkd-gdb只会将GDB附加到.so。所以,你可能会错过一些断点。我知道在IDE插件之外的两种方法来解决这个问题:


  1. 在你的最早入门点放置一个无限循环.so,然后使用GDB突破这个无限循环,在您设置了断点之后

  2. 将我的待处理更新下载到ndk-gdb,从而修复了这个问题,从 https://android-review.googlesource.com/#/c/48029/ (一人们已经报告了我的修复问题,所以它没有被AOSP批准...但是我从来没有转载他们的问题,请让我知道,如果你使用它,它是否适用于你)。 >


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 .

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 .

My Question Is how can I debug a SO library which is the result of a separate project in an Android Application ?

解决方案

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. See $NDK/docs/NDK-GDB.html

But, be warned: nkd-gdb will only attach GDB to your .so sometime after the application has started. So, you might miss some breakpoints. I know of 2 ways to solve that problem, outside of an IDE plugin:

  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
  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.)

这篇关于如何从Android应用程序调试共享的libarary [单独的项目]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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