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.

Version 2 (modified by michaelz, 12 years ago) (diff)

Added steps on configuring gdb and starting a debug session.

debugging native code in Android.

(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 the android ndk directory. There should be a file ndk-gdb. Copy it, name the copy ndk-gdb-eclipse, and remove the following, last line:

$GDBCLIENT -x native_path $GDBSETUP

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.
  • Select the build tab, and disable Build before launch.
  • Hit Apply, Close.
  • (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 Android/libim.pidgin.libpurple.so as C/C++ Application name (or just click on Search project... to find it)
    • Select Disable auto build
  • 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.
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!