java:
Log.d(TAG, "My Exception Log: " + new Exception());
打印不出来时,可采用下面方式:
import java.io.PrintWriter;
import java.io.StringWriter;
Exception e = new Exception("log_debug");
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
Log.d(TAG, "My Exception Log: " + e.getMessage() + "\nStack Trace:\n" + sw.toString());
C++:
adnroid.bp shared_libs 添加 "libutilscallstack",
#include <utils/CallStack.h>
CallStack cs;
cs.update();
cs.log("my trace log");
android::CallStack cs;
cs.update();
cs.log("my trace log");