Print caller stack may help you to analyze the program and find out the caller stack more easily.
You can write your code like this:
Java: Exception e = new Exception(); Log.e(TAG,"xxx",e);
C++ file: #include <utils/Callstack.h>
android::CallStack stack; stack.update(1,30); stacn.dump("xxx");
Then you can see the function's caller stack in Android main log file.
C file: #include <corkscrew/backtrace.h>
#define MAX_DEPTH 31 static backtrace_frame_t mStack[MAX_DEPTH];
void csupdate(int32_t ignoreDepth, int32_t maxDepth) { void csdump(const char* prefix)\ get_backtrace_symbols(mStack, mCount, symbols);
for (i = 0; i < mCount; i++) {
free_backtrace_symbols(symbols, mCount);
void myFunc() { csupdate(1, 30); csdump("myprefix"); } In Android.mk, add libcorkscrew, as below LOCAL_SHARED_LIBRARIES := libxxx libyyy libcorkscrew |
|