am 7133f863: Merge "improved CallStack a bit" into jb-mr2-dev

* commit '7133f8638e105548f6cca66a0ba9a6951993b7de':
  improved CallStack a bit
This commit is contained in:
Mathias Agopian 2013-03-22 04:33:20 +00:00 committed by Android Git Automerger
commit dbbf209e66
7 changed files with 21 additions and 24 deletions

View File

@ -35,6 +35,8 @@ public:
}; };
CallStack(); CallStack();
CallStack(const char* logtag, int32_t ignoreDepth=1,
int32_t maxDepth=MAX_DEPTH);
CallStack(const CallStack& rhs); CallStack(const CallStack& rhs);
~CallStack(); ~CallStack();
@ -53,8 +55,8 @@ public:
void update(int32_t ignoreDepth=1, int32_t maxDepth=MAX_DEPTH); void update(int32_t ignoreDepth=1, int32_t maxDepth=MAX_DEPTH);
// Dump a stack trace to the log // Dump a stack trace to the log using the supplied logtag
void dump(const char* prefix = 0) const; void dump(const char* logtag, const char* prefix = 0) const;
// Return a string (possibly very long) containing the complete stack trace // Return a string (possibly very long) containing the complete stack trace
String8 toString(const char* prefix = 0) const; String8 toString(const char* prefix = 0) const;

View File

@ -246,9 +246,7 @@ BpMemoryHeap::~BpMemoryHeap() {
if (VERBOSE) { if (VERBOSE) {
ALOGD("UNMAPPING binder=%p, heap=%p, size=%d, fd=%d", ALOGD("UNMAPPING binder=%p, heap=%p, size=%d, fd=%d",
binder.get(), this, mSize, mHeapId); binder.get(), this, mSize, mHeapId);
CallStack stack; CallStack stack(LOG_TAG);
stack.update();
stack.dump("callstack");
} }
munmap(mBase, mSize); munmap(mBase, mSize);

View File

@ -530,9 +530,7 @@ bool Region::validate(const Region& reg, const char* name, bool silent)
} }
if (result == false && !silent) { if (result == false && !silent) {
reg.dump(name); reg.dump(name);
CallStack stack; CallStack stack(LOG_TAG);
stack.update();
stack.dump("");
} }
return result; return result;
} }

View File

@ -30,6 +30,11 @@ CallStack::CallStack() :
mCount(0) { mCount(0) {
} }
CallStack::CallStack(const char* logtag, int32_t ignoreDepth, int32_t maxDepth) {
this->update(ignoreDepth+1, maxDepth);
this->dump(logtag);
}
CallStack::CallStack(const CallStack& rhs) : CallStack::CallStack(const CallStack& rhs) :
mCount(rhs.mCount) { mCount(rhs.mCount) {
if (mCount) { if (mCount) {
@ -96,7 +101,7 @@ void CallStack::update(int32_t ignoreDepth, int32_t maxDepth) {
mCount = count > 0 ? count : 0; mCount = count > 0 ? count : 0;
} }
void CallStack::dump(const char* prefix) const { void CallStack::dump(const char* logtag, const char* prefix) const {
backtrace_symbol_t symbols[mCount]; backtrace_symbol_t symbols[mCount];
get_backtrace_symbols(mStack, mCount, symbols); get_backtrace_symbols(mStack, mCount, symbols);
@ -104,7 +109,9 @@ void CallStack::dump(const char* prefix) const {
char line[MAX_BACKTRACE_LINE_LENGTH]; char line[MAX_BACKTRACE_LINE_LENGTH];
format_backtrace_line(i, &mStack[i], &symbols[i], format_backtrace_line(i, &mStack[i], &symbols[i],
line, MAX_BACKTRACE_LINE_LENGTH); line, MAX_BACKTRACE_LINE_LENGTH);
ALOGD("%s%s", prefix, line); ALOG(LOG_DEBUG, logtag, "%s%s",
prefix ? prefix : "",
line);
} }
free_backtrace_symbols(symbols, mCount); free_backtrace_symbols(symbols, mCount);
} }

View File

@ -110,7 +110,7 @@ public:
char inc = refs->ref >= 0 ? '+' : '-'; char inc = refs->ref >= 0 ? '+' : '-';
ALOGD("\t%c ID %p (ref %d):", inc, refs->id, refs->ref); ALOGD("\t%c ID %p (ref %d):", inc, refs->id, refs->ref);
#if DEBUG_REFS_CALLSTACK_ENABLED #if DEBUG_REFS_CALLSTACK_ENABLED
refs->stack.dump(); refs->stack.dump(LOG_TAG);
#endif #endif
refs = refs->next; refs = refs->next;
} }
@ -124,16 +124,14 @@ public:
char inc = refs->ref >= 0 ? '+' : '-'; char inc = refs->ref >= 0 ? '+' : '-';
ALOGD("\t%c ID %p (ref %d):", inc, refs->id, refs->ref); ALOGD("\t%c ID %p (ref %d):", inc, refs->id, refs->ref);
#if DEBUG_REFS_CALLSTACK_ENABLED #if DEBUG_REFS_CALLSTACK_ENABLED
refs->stack.dump(); refs->stack.dump(LOG_TAG);
#endif #endif
refs = refs->next; refs = refs->next;
} }
} }
if (dumpStack) { if (dumpStack) {
ALOGE("above errors at:"); ALOGE("above errors at:");
CallStack stack; CallStack stack(LOG_TAG);
stack.update();
stack.dump();
} }
} }
@ -269,9 +267,7 @@ private:
ref = ref->next; ref = ref->next;
} }
CallStack stack; CallStack stack(LOG_TAG);
stack.update();
stack.dump();
} }
} }

View File

@ -222,9 +222,7 @@ static int gl_no_context() {
char value[PROPERTY_VALUE_MAX]; char value[PROPERTY_VALUE_MAX];
property_get("debug.egl.callstack", value, "0"); property_get("debug.egl.callstack", value, "0");
if (atoi(value)) { if (atoi(value)) {
CallStack stack; CallStack stack(LOG_TAG);
stack.update();
stack.dump();
} }
} }
return 0; return 0;

View File

@ -78,9 +78,7 @@ void egl_tls_t::setErrorEtcImpl(
char value[PROPERTY_VALUE_MAX]; char value[PROPERTY_VALUE_MAX];
property_get("debug.egl.callstack", value, "0"); property_get("debug.egl.callstack", value, "0");
if (atoi(value)) { if (atoi(value)) {
CallStack stack; CallStack stack(LOG_TAG);
stack.update();
stack.dump();
} }
} }
tls->error = error; tls->error = error;