3

I've made some changes to the csipsimple app for android, and I want to debug its native code. I'm using the ADT bundle v21.1 to develop (eclipse 3.7, cdt 8.1) under Ubuntu 12.10.

I came across this tutorial for native debugging under eclipse but it didn't work for me (see my question Debugging native code in android under eclipse fails). I'm now trying the ARM DS-5 solution with no additional luck. I also came across this nvidia solution but am not sure whether it's worth the effort. I didn't try the Sequoyah plugin yet since it looks outdated.

Can anyone please guide me to a good stable gui debugging tool or method for debugging native code in Android on a device (my device is htc dream).

Community
  • 1
  • 1
david-hoze
  • 1,045
  • 15
  • 31
  • I'm still using Sequoyah on the most recent android sdk and it's working just fine for native debugging. – JonnyBoy Jun 14 '13 at 21:45

3 Answers3

8

No one likes this answer, but ndk-gdb is very reliable. It can be a pain to use but once you get going its not so bad.

The basic debugging method will be:

  1. Set a breakpoint in Eclipse on the line where you load the native library.
  2. Start debugging in Eclipse
  3. Step over the load library line. Do not resume!!
  4. On the command line, start ndk-gdb
  5. Set your breakpoints in gdb. Enter 'c' for continue
  6. Return to Eclipse and continue

Voila! Your C breakpoints will be hit!

Of course you need to have everything set up in the terminal... And I'd suggest printing out a gdb cheat sheet if you're unfamiliar.

krsteeve
  • 1,794
  • 4
  • 19
  • 29
2

Been debugging native code in Eclipse for a long while (year++) using only the default android tools.

Some tips that might help.

  • Keep the jni content in the main application project (not a separate library project)
  • Create a running java application first before adding any native code
  • "Add Native Support" with just the default CPP file it generates then close and reopen eclipse (it should automatically try and build the native side). The native code needs to build successfully at least once for it all to be happy. Once that succeeds, then add any additional sources and update the MK files etc.
  • terminal is your friend ... and ndk-gdb is too!
  • add a 'hang 10' ... a ten second delay (in java) after loading native library (allows debugger to attach)
  • step through code slowly to allow the network communication to keep up
  • Reduce the number of ABI's so as not to confuse the debugger

Have fun!

DevByStarlight
  • 1,070
  • 13
  • 17
0

Might not be the best solution since I have not tried the others, but Nvidia Debug Manager for Android is pretty good so far and easy to use. It comes with Tegra Android Development Pack which can be obtained from: https://developer.nvidia.com/tegra-android-development-pack

eozgonul
  • 810
  • 6
  • 12
  • Does it work on non-Tegra devices? – WindRider Jun 13 '14 at 10:48
  • 1
    It works on non-Tegra devices, though you might get a warning stating that your device is non-Tegra but it does not block anything. – eozgonul Jun 13 '14 at 11:21
  • Damn. It requires Eclipse 4.3 and i hate it so much. – WindRider Jun 13 '14 at 21:01
  • You can also switch to Visual Studio. – eozgonul Jun 16 '14 at 06:41
  • I'm on Ubuntu. Anyway, I've managed to install ARM DS-5 debugger. It kicks ass! The installation of the Eclipse plugin was a bit hard and tricky, but there is a way. It gives an Eclipse dependency error, but if you uncheck "Show only the latest versions" and choose the previous plugin version, it runs. That's just for the record if anyone stumbles on the same error. – WindRider Jun 16 '14 at 08:11