Android NDK pretty printing
Asked Answered
B

1

6

I'm using Android NDK with Eclipse + CDT, running on OSX.

I would like to be able to debug the content of the STD library. I've seen several tutorials about using Python scripts to enable this "pretty printing". The problem is that all of them are using the default gdb, and not the one provided by the Android NDK, so all of them are failing for me.

How can I debug the STD library using Android NDK?

Babushka answered 23/6, 2014 at 11:5 Comment(2)
Interesting question, I have looked for such a possibility for a long time! Still no answer despite the bounty :-/.Liverwort
I'm also looking for how to do pretty printing for Android NDKSeizing
A
4

If you need to just debug, rather than make some already chosen tool work, I can share this code:

dlog.h:

#include <android/log.h>
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG  , "~~~~~~", __VA_ARGS__)
#define DLOG(...) __android_log_print(ANDROID_LOG_DEBUG  , "~~~~~~", __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR  , "~~~~~~", __VA_ARGS__)
#define ELOG(...) __android_log_print(ANDROID_LOG_ERROR  , "~~~~~~", __VA_ARGS__)

I define both DLOG and LOGD to avoid having to remember the order ))

in Android.mk:

include $(CLEAR_VARS)
LOCAL_MODULE := ...
LOCAL_SRC_FILES += ...
LOCAL_LDLIBS := -llog      # <=========== link with liblog.so
include $(BUILD_SHARED_LIBRARY)

Usage:

DLOG("this is a test %s 0x%x","whoa!",1234);

You see these messages in the same place where you see the Log.d() output, I prefer adb logcat or adb logcat | grep something.

Argument answered 23/6, 2014 at 14:14 Comment(1)
Thanks for the answer but is not what I'm looking for. I don't want to have to write DLOG everyplace. I need to be able to check, for instance, a std::vector in a moment given, debuging with eclipse. Right now, it is just showing the memory directions.Babushka

© 2022 - 2024 — McMap. All rights reserved.