Trac is being migrated to new services! Issues can be found in our new YouTrack instance and WIKI pages can be found on our website.

debugging native code in Android.

Currently, this does not work. Those steps are just a start to get it working...

(setting this up is not needed to do java debugging, you just can't step into native functions.)

before starting

You should at first compile the library yourself.

Then go to your ndk directory and to toolchains/arm-linux-androideabi-4.4.3/prebuilt and copy the gdbserver file you find there to your libs/armeabi directory (there should already be a lot of .so-Files there).

in Eclipse

  • Open the External Tools Configuration Dialog.
  • Add a new Program by double-clicking on Program on the left side.
  • Select the ndk-gdb-eclipse script you just created.
  • As parameter, enter the right path to adb like:
    --adb=../android-sdk-linux/platform-tools/adb
    
  • Set the working directory to the directory of your client project.
  • Select the build tab, and disable Build before launch.
  • Hit Apply, Close.

Start your application in debug mode and when it is active, start the tool you just created. This will create some files you need for the next steps:

  • (skip for Testclient) Set android:debuggable="true" in your application definition in the AndroidManifest?.xml.
  • Open the debug configuration dialog.
  • Create a new Debug configuration by double-clicking on C/C++ Attach to Application
  • This needs to be done in the main tab:
    • Enter im.pidgin.libpurple as Project name
    • Enter <your app>/libs/armeabi/app_process as C/C++ Application name (or just click on Search project... to find it)
    • Select Disable auto build
    • Disable Run in Background.
  • Go to the debugger tab.
    • Select gdbserver as Debugger.
    • Enter ${ndk.root}/bin/arm-linux-androideabi-gdb in the GDB debugger filed.
    • As command file, select the gdb.setup file in the native directory.
    • In the connection tab, enter TCP as connection type, localhost as target and 5039 as port.
  • Hit apply.
  • Create a new Launch group by double-clicking on Launch group.
    • Add the Program launcher you created. You should set "Post launch action" to "Wait until terminated".
    • Add your Debug configuration we just created
    • Give it a nice name.
  • Close the dialog by hitting Apply and Close.

Start debugging

When you want to debug native code, do the following:

  • Add a breakpoint before initializing libpurple, e.g. in your Applications onCreate().
  • Start your application in the normal Android debug mode. It should pause at that breakpoint.
  • Then start your debug configuration, by clicking on Debug Configurations..., selecting the Launch group you created and hitting Debug.
Last modified 12 years ago Last modified on Jun 7, 2012, 5:36:07 PM
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!