Android NDK pretty prints

I am using Android NDK with Eclipse + CDT running on OSX.

I would like to be able to debug the contents of the STD library. I saw several tutorials on using Python scripts to enable this "beautiful print". The problem is that they all use gdb by default, and not the one provided by Android NDK, so they all do not work for me.

How to debug STD library using Android NDK?

+6
source share
1 answer

If you just need to debug, and not do some of the tools already selected, 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) 

Using:

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

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

+4
source

Source: https://habr.com/ru/post/971231/


All Articles