Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 .

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 ?

like image 332
Yamen Ajjour Avatar asked Nov 12 '22 13:11

Yamen Ajjour


1 Answers

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.)
like image 120
Ryan V. Bissell Avatar answered Nov 15 '22 06:11

Ryan V. Bissell