简体   繁体   中英

How are you debugging C++ for Android NDK?

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!

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!

为了进一步参考,我喜欢这个解决方案,它展示了如何使用gdb的图形衍生物,例如cgdb(http://cgdb.github.com/)和ddd(http://www.gnu.org/software/ddd/) ): http//mhandroid.wordpress.com/2011/01/23/using-cgdb-with-ndk-debug-and-cgdb-tutorial/

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM