4

What are the options for debugging native code on Android? Is gdb the only debugger available? Is their a Visual Studio integration?

I've looked through the Android docs and done the googlesing but am not confident I found the right answer. Hopefully some SO pro's will save me the pain of trial and error.

But if my choices are gdb or printf's, I'll move to Mono for Android instead!

Solution! WinGDB is available for Android. Debugging with Visual Studio!

Chris Masterton
  • 2,197
  • 4
  • 24
  • 30

3 Answers3

5

I haven't tried this myself, but this blog post explains how to get NDK debugging working in Visual Studio.

Also, I've done a lot of looking into NDK debugging at work, and I haven't seen a mention of using a debugger other than gdb (but please don't take this as a fact, this is just from my experience). I have managed to successfully debug NDK through Eclipse, so at least you know it's possible! If you decide to go down that route, I can provide you with some links/documentation to get you started.


Edit: I have finally found the time to format and upload my NDK debugging documentation. It's not amazing right now (in terms of formatting etc.), but it has worked for a few people across all platforms. You can find it here. I hope it helps!
epochengine
  • 2,072
  • 17
  • 21
  • +1 but can you post the links/documentation you mentioned for the benefit of others reading this post please :) – Moog Jul 26 '11 at 22:31
  • Sorry for replying so late - I've been very busy. Yes, sure, I'll post stuff here over the weekend :) – epochengine Jul 29 '11 at 08:28
  • @Merlin I don't know if you get notified of my edit, so I'm commenting here to let you know I've linked to the guide. Sorry it took so long, and I hope it helps. – epochengine Aug 05 '11 at 14:13
  • the link ( You can find it "here") is dead – ransh Apr 01 '17 at 18:14
0

For further reference, I like this solution that shows how to use graphical derivatives of gdb, such as cgdb (http://cgdb.github.com/) and ddd (http://www.gnu.org/software/ddd/): http://mhandroid.wordpress.com/2011/01/23/using-cgdb-with-ndk-debug-and-cgdb-tutorial/

user1284631
  • 4,446
  • 36
  • 61
0

I found these macro defs but beyond that I cannot say.

#include <android/log.h>

#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, "libnav",
__VA_ARGS__)
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG  , "libnav",
__VA_ARGS__)
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO   , "libnav",
__VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN   , "libnav",
__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR  , "libnav",
__VA_ARGS__)

#endif // ANDROID_ALOG_H 

UPDATE

Apparently you can use DDD either as a plugin to eclipse as found on Code Maemo

or run under Cygwin, you will find some useful links in Debugging Android NDK, under windows

Additionally there are some very useful plugins

CDT plugin for eclipse

Sequoya plugin

The installation and configuration of the stack is detailed in How-to debug native code with Android

Community
  • 1
  • 1
Moog
  • 10,193
  • 2
  • 40
  • 66
  • I'm after a definitive answer on whether gdb is the only debugger for native code. Sorry my original post was not very clear. Thanks Merlin. – Chris Masterton Jul 25 '11 at 23:38
  • I have provided additional information but it l ooks like everything centres around gdb – Moog Jul 26 '11 at 00:00
  • My understanding is that gdb is the supported debugger. But the tutorials I have found all seem either out of date or just plain wrong. I have yet to see a tutorial that works with NDK r5b and the current Eclipse. – Scott C Wilson Jul 26 '11 at 00:06