1 cpp层加打印和打印调用栈
#include <log/log.h>
ALOGE("xxx.\n");
ALOGE("%s:%s:%d tag:%d", __FILE__,__FUNCTION__,__LINE__,command);
#include <utils/CallStack.h>
android::CallStack stack;
stack.update();
stack.log("getStack:", ANDROID_LOG_ERROR, "pre");
Android.mk:
LOCAL_SHARED_LIBRARIES += libutils
// 注意:Android P是LOCAL_SHARED_LIBRARIES += libutilscallstack
// 否则如下错误 error: undefined reference to 'android::CallStack::update(int, int)'
2 address2line
案例: